Table of Contents


Pattern MatchingResult
$a =~ /pat/matchTrue if $a contains pattern
$a =~ s/p/r/substitutionReplace contents of p with r in $a
$a =~ tr/a-z/A-Z/translationTranslate to corresponding characters

Return to Top

Logical OperatorsResult
$a && $bAndTrue if $a is true and $b is true
$a || $bOr$a if $a is true, otherwise $b
! $aNotTrue if $a is not true

Return to Top

Arithmetic OperatorsResult
$a + $bAddSum of $a and $b
$a - $bSubtractDifference of $a and $b
$a * $bMultiplyProduct of $a times $b
$a / $bDivideQuotient of $a divided by $b
$a % $bModulusRemainder of $a divided by $b
$a ** $bExponentiate$a to the power $b
++$a,$a++AutoincrementAdd 1 to $a
--$a,$a--AutodecrementSubtract 1 from $a
rand($a)RandomA random number in range 0 .. $a

Return to Top

String OperatorsResult
$a . $bConcatenationValues of $a and $b as one long string
$a x $bRepeatValue of $a strung together $b times
substr($a,$o,$l)SubstringSubstring at offset $o of length $l
index($a,$b)IndexOffset of string $b in string $a

Return to Top

Assignment OperatorsResult
$a = $bAssign$a gets the value of $b
$a += $bAdd toIncrease $a by $b
$a -= $bSubtract fromDecrease $a by $b
$a .= $bAppendAppend string $b to $a

Return to Top

File Test OperatorsResult
-r $aReadableFile name in $a is readable by effective uid
-w $aWritableWritable by effective uid
-x $aExecutableExecutable by effective uid
-o $aOwnedOwned by effective uid
-R $aReadableReadable by real uid
-W $aWritableWritable by real uid
-X $aExecutableExecutable by real uid
-O $aOwnedOwned by real uid
-e $aExistsFile exists
-z $aNon-zero sizeFile has non-zero size (returns size in bytes)
-s $aZero sizeFile has zero size
-f $aRegular fileFile is a regular file
-d $aDirectoryFile is a directory
-l $aSymbolic linkFile is a symbolic link
-p $aNamed pipeFile is a named pipe (FIFO)
-S $aSocketFile is a socket
-b $aBlockFile is a block special file
-c $aCharacterFile is a character special file
-u $aUIDFile has setuid bit set
-g $aGIDFile has setgid bit set
-k $aSticky bitFile has sticky bit set
-T $aText fileFile is a text file
-B $aBinaryFile is a binary file (opposite of -T)
-M $aModifyAge of file (at startup) in days since modification
-A $aLast AccessAge of file (at startup) in days since last access
-C $aInode changeAge of file (at startup) in days since inode change

Return to Top