| Divergence | if(CONDITION){}elsif(){}else{} |
| While Loop | while(CONDITION){} |
| Break Loop | last; |
| Continue Loop | next; |
| Redo Loop | redo; |
| For Loop | for($i=1;$i<10;$i++){} |
| Foreach Loop | foreach $x (@a){print $x;} |
| Concatenation | $z=$x.$y; |
| Length | $n = length(@x); |
| Substring | $y = substr($x,$start,$end); |
| Seek | $y = index($body,$key,$start); |
| Split | $y = split(/$delim/,$x); |
| Replace | $x =~ s/IN/OUT/g |
| Here Documentation |
$x = << SOME_END_TAG; xxxxx yyyyy SOME_END_TAG |
| Substitution | $x[$i]='test'; |
| Reference | $xi = $x[$i]; |
| Initialize | @x = (1, 2, 3, 4, 5, 6); |
| Concatenation | @z = (@x,'test1','test2',@y); |
| Pop from tail | $y = pop(@x); |
| Push in tail | push(@x,'newdata'); |
| Pop from head | $y = shift(@x); |
| Push in head | unshift(@x,'newdata'); |
| Number of Elements | $n = scalar(@x); |
| Create | $x{'name'}=>'taro'; |
| Reference | $name = $x{'name'}; |
| Initialize | %x = ('name'=>'taro', 'age'=>10); |
| Existence | if(exists($x{'name'})){} |
| Concatenation | %z = (%x,%y); |
| Deletion | delete($x{'name'}); |
| List keys | @k = keys(%x); |
| List values | @v = values(%x); |
| Numeric | 0 = false, other = true |
| String | "" = false, other = true |
| Remainder | % |
| Power | ** |
| Numerical Equal | == |
| Numerical Unqual | != |
| String Equal | eq |
| String Unqual | ne |
| String Greater as Number | gt |
| String Smaller as Number | lt |
| String Match | $x =~ /REGULAR_EXPRESSION/MODIFIER |
| String Unmatch | $x !~ /REGULAR_EXPRESSION/MODIFIER |
| String Repeat | $y = $x x $n; |
| And | and, && |
| Or | or, || |
| Not | not(), ! |
| floor | int($x) |
| Random from 0 to n: rand($n) |
| ESC | \e |
| TAB | \t |
| SPC | \s |
| Newpage | \f |
| Newline | \n |
| Rewriteline | \r |
| BELL | \a |
| Octadecimal | \0 |
| Hexadecimal | \x |
| All Decimal | \d |
| All Not Decimal | \D |
| All Alphabet | \w |
| All Not Alphabet | \W |
| All Control Char. | \c |
| All Not SPC | \S |
| Open for Read | open FILEHANDLE, "<$filename"; |
| Open for Write | open FILEHANDLE, ">$filename"; |
| Open for Append | open FILEHANDLE, ">>$filename"; |
| Read File | @list = <FILEHANDLE>; |
| Write File | print FILEHANDLE "somestring"; |
| Close File | close FILEHANDLE; |
| Making Directory | mkdir($dirname); |
| Changing Directory | chdir($dirname); |
| Remove Directory | rmdir($dirname); |
| Get Status | ($fsdevid, $inode, $filemode, $nlink, $userid, $groupid, $devid, $bytes, $atime, $mtime, $ctime, $blocksize, $nblocks) = stat($filename); |
| ls | @list = glob("LS_STRING"); |
| Head | /^somekey/ |
| Tail | /somekey$/ |
| Wildcard(0-inf) | somekey* |
| Wildcard(1-inf) | somekey+ |
| Wildcard(0-1) | somekey? |
| Wildcard(n) | somekey{n} |
| Wildcard(n-inf) | somekey{n,} |
| Wildcard(0-m) | somekey{n,m} |
| Or | somekey1|somekey2 |
| Commandline Arguments | @ARGV[0] ([0] means first parameter) |
| CGI form (GET) | %ENV |
| Current Second | $from1970 = $time(); |
| Humanized | ($sec,$min,$hour,$day,$mon,$year,$weekday,$summerday) = localtime(time()); $mon++; $year+=1900; |