...
Please comment if you know some more good ones.
Perl Basics
Perl Data Types
- Scalar -> $variable
- Array -> @array
- Associative Array (hash) -> %hash
- Combinations to make complex types easily (looks confusing but very powerful)
- Array of hashes $array[$i]->{$key}
- Hash of hashes $hash{$key}{$var}
- Multi-dimensional $var->{$key}->[0]->{$thing}
Use it!
Code Block |
---|
use strict; |
Perl if statement
Code Block |
---|
use strict;
my $string = "this is a string";
if ( $string eq "string" ) {
print "$string is the same as \"string\"\n";
}
elsif ( $string =~ /string/ ) {
print "regex match $string has \"string\" in it\n";
}
elsif ( $string == 100 ) {
print "$string is the number 100\n";
}
else {
print "Else Nothing\n";
}
|