Execution of expressions can depend on other expressions using one of the modifiers
if, unless, while or until, e.g.:
| + - * / |
Addition, subtraction, multiplication, division. |
| % |
Modulo division |
| | & ^ |
Bitwise or, bitwise and, bitwise exclusive or. |
| >> << |
Bitwise shift right, bitwise shift left. |
| ** |
Exponentiation. |
| . |
Concatenation of two strings. |
| x |
Returns a string or array consisting of the left
operand (an array or a string) repeated the number of times specified by the
right operand. |
|
All of the above operators also have an assignment operator,
e.g. ".=". |
| ++ -- |
Auto-increment (magical on strings), auto-decrement. |
| ? : |
Alternation (if-then-else) operator. |
| || && |
Logical or, logical and. |
| == != |
Numeric equality, inequality. |
| eq ne |
String equality, inequality. |
| < > |
Numeric less than, greater than. |
| lt gt |
String less than, greater than. |
| <= >= |
Numeric less (greater) than or equal. |
| le ge |
String less (greater) than or equal. |
| <=> |
Numeric compare. Returns -1, 0, 1. |
| cmp |
String compare. Returns -1, 0, 1. |
| =~ !~ |
Search pattern, substitution, or translation (negated). |
| .. |
Enumeration, also input line range operator. |
| , |
Comma operator. |
| -r -w -x -o |
File is readable/writable/executable/owned by effective uid. |
| -R -W -X -O |
File is readable/writable/executable/owned by real uid. |
| -e -z -s |
File exists/has zero/non-zero size. |
| -f -d |
File is a plain file, a directory. |
| -l -S -p |
File is a symbolic link, a socket, a named pipe (FIFO). |
| -b -c |
File is a block/character special file. |
| -u -g -k |
File has a setuid/setgid/sticky bit set. |
| -t |
Tests if filehandle (STDIN by default) is opened to a tty. |
| -T -B |
File is a text/non-text (binary) file.
-T and -B return TRUE on a null file,
or a file at EOF when testing a filehandle. |
| -M -A -C |
File creation / access / inode change time.
Measured in days since this program started.
See also $^T in section
"Special Variables". |
| atan2(Y,X) |
Returns the arctangent of Y/X in the range -pi to pi. |
| cos(EXPR)* |
Returns the cosine of EXPR (expressed in radians). |
| exp(EXPR)* |
Returns e to the power of EXPR. |
| int(EXPR)* |
Returns the integer portion of EXPR. |
| log(EXPR)* |
Returns natural logarithm (base e) of EXPR. |
| rand[(EXPR)*] |
Returns a random fractional number between 0 and the value of EXPR.
If EXPR is omitted, returns a value between 0 and 1. |
| sin(EXPR)* |
Returns the sine of EXPR (expressed in radians). |
| sqrt(EXPR)* |
Returns the square root of EXPR. |
| srand[(EXPR)*] |
Sets the random number seed for the rand operator. |
| time |
Returns the number of seconds since January 1, 1970. Suitable for
feeding to gmtime and localtime. |
| passwd |
| Info is ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell). |
| endpwent |
Ends lookup processing. |
| getpwent |
Gets next info. |
| getpwnam(NAME) |
Gets info by name. |
| getpwuid(UID) |
Gets info by uid. |
| setpwent |
Resets lookup processing. |
|
| group |
| Info is 4-item array: ($name, $passwd, $gid, $members). |
| endgrent |
Ends lookup processing. |
| getgrgid(GID) |
Gets info by group id. |
| getgrnam(NAME) |
Gets info by name. |
| getgrent |
Gets next info. |
| setgrent |
Resets lookup processing. |
|
| hosts |
| Info is ($name, $aliases, $addrtype, $length, @addrs). |
| endhostent |
Ends lookup processing. |
| gethostbyaddr(ADDR, ADDRTYPE) |
Gets info by address. |
| gethostbyname(NAME) |
Gets info by name. |
| gethostent |
Gets next info. |
| sethostent(STAYOPEN) |
Resets lookup processing. |
|
| networks |
| Info is ($name, $aliases, $addrtype, $net). |
| endnetent |
Ends lookup processing. |
| getnetbyaddr(ADDR, TYPE) |
Gets info by address and type. |
| getnetbyname(NAME) |
Gets info by name. |
| getnetent |
Gets next info. |
| setnetent(STAYOPEN) |
Resets lookup processing. |
|
| services |
| Info is ($name, $aliases, $port, $proto). |
| endservent |
Ends lookup processing. |
| getservbyname(NAME, PROTO) |
Gets info by name. |
| getservbyport(PORT, PROTO) |
Gets info by port. |
| getservent |
Gets next info. |
| setservent(STAYOPEN) |
Resets lookup processing. |
|
| protocols |
| Info is ($name, $aliases, $proto). |
| endprotoent |
Ends lookup processing. |
| getprotobyname(NAME) |
Gets info by name. |
| getprotobynumber(NUMBER) |
Gets info by number. |
| getprotoent |
Gets next info. |
| setprotoent(STAYOPEN) |
Resets lookup processing. |
| . |
matches an arbitrary character, but not a newline. |
| (...) |
groups a series of pattern elements to a single element. |
| + |
matches the preceding pattern element one or more times |
| ? |
matches zero or one times |
| * |
matches zero or more times |
| {N, M} |
denotes the minimum N and maximum M match count.
{N} means exactly N times;
{N, } means at least N times. |
| [...] |
denotes a class of characters to match.
[^...] negates the class. |
| (...|...|...) |
matches one of the alternatives. |
| Non-alphanumerics can be escaped from their
special meaning using a \. |
| \w |
matches alphanumeric, including "_",
\W matches non-alphanumeric. |
| \b |
matches word boundaries, \B matches non-boundaries |
| \s |
matches whitespace, \S matches non-whitespace. |
| \d |
matches numeric, \D matches non-numeric |
| \n, \r, \f, \t etc.
have their usual meaning. |
| \w, \s and \d may be used within
character classes, \b denotes backspace in this context. |
| \1...\9 |
refer to matched sub-expressions, grouped with (),
inside the match. |
| \10 |
and up can also be used if the pattern matches that many sub-expressions. |
See also
| The following variables are global and should be
localized in subroutines: |
| $_ |
The default input and pattern-searching space. |
| $. |
The current input line number of the last filehandle that was read. |
| $/ |
The input record separator, newline by default. May be multi-character. |
| $, |
The output field separator for the print operator. |
| $" |
The separator which joins elements of arrays interpolated in strings. |
| $\ |
The output record separator for the print operator. |
| $# |
The output format for printed numbers.
Initial value is "%.20g". |
| $* |
Set to 1 to do multiline matching within a string,
0 to assume strings contain a single line.
Default is 0. |
| $? |
The status returned by the last `COMMAND`,
pipe close or system operator. |
| $] |
The perl version string (as displayed with perl -v),
or version number. |
| $[ |
The index of the first element in an array, and of the first character
in a substring. Default is 0. |
| $; |
The subscript separator for multi-dimensional array emulation.
Default is "\034". |
| $! |
If used in a numeric context, yields the current value of errno.
If used in a string context, yields the corresponding error string. |
| $@ |
The perl error message from the last eval or do EXPR
command. |
| $: |
The set of characters after which a string may be broken to
fill continuation fields (starting with "^") in a format. |
| $0 |
The name of the file containing the perl script being executed.
May be assigned to. |
| $$ |
The process number of the perl running this script.
Altered (in the child process) by fork. |
| $< |
The real uid of this process. |
| $> |
The effective uid of this process. |
| $( |
The real gid of this process. |
| $) |
The effective gid of this process. |
| $^D |
The debug flags as passed to perl using -D. |
| $^F |
The highest system file descriptor, ordinarily 2. |
| $^I |
In-place edit extension as passed to perl using -i. |
| $^P |
Internal debugging flag. |
| $^T |
The time (as delivered by time) when the program started.
This value is used by the file test operators "-M",
"-A" and "-C". |
| $^W |
The value if the -w option as passed to perl. |
| $^X |
The name by which this perl was invoked. |
| The following variables are context dependent
and need not be localized: |
| $% |
The current page number of the currently selected output channel. |
| $= |
The page length of the current output channel. Default is 60 lines. |
| $- |
The number of lines left on the page. |
| $~ |
The name of the current report format. |
| $^ |
The name of the current top-of-page format. |
| $| |
If set to nonzero, forces a flush after every write or print on the
currently selected output channel. Default is 0. |
| $ARGV |
The name of the current file when reading from <>. |
| The following variables are always local to the
current block: |
| $& |
The string matched by the last pattern match. |
| $` |
The string preceding what was matched by the last pattern match. |
| $' |
The string following what was matched by the last pattern match. |
| $+ |
The last bracket matched by the last search pattern. |
| $1...$9... |
Contains the subpattern from the corresponding set of parentheses in the
last pattern matched. $10... and up are only available if the match
contained that many sub-expressions. |
| h |
Prints out a help message. |
| T |
Stack trace. |
| s |
Single steps. |
| n |
Single steps around subroutine call. |
| r |
Returns form the current subroutine. |
| c [LINE] |
Continues (until LINE, or another breakpoint or exit). |
| RET key |
Repeats last s or n. |
| l [RANGE] |
Lists a range of lines. RANGE may be a number, start-end,
start+amount, or a subroutine name. If omitted, lists next window. |
| f FILE |
Switches to FILE and start listing it. |
| - |
Lists previous window. |
| w |
Lists window around current line. |
| l SUB |
Lists the named SUBroutine. |
| /PATTERN/ |
Forward search for PATTERN. |
| ?PATTERN? |
Backward search for PATTERN. |
| L |
List lines that have breakpoints or actions. |
| S |
List the names of all subroutines. |
| t |
Toggles trace mode. |
| b [LINE [CONDITION]] |
Sets breakpoint at LINE, default: current line. |
| b SUBNAME [CONDITION] |
Sets breakpoint at the subroutine. |
| d [LINE] |
Deletes breakpoint at the given line. |
| D |
Deletes all breakpoints. |
| a LINE COMMAND |
Sets an action for line. |
| A |
Deletes all line actions. |
| < COMMAND |
Sets an action to be executed before every debugger prompt. |
| > COMMAND |
Sets an action to be executed before every s, c or n
command. |
| V [PACKAGE [VARS]] |
Lists all variables in a package. Default package is main. |
| X [VARS] |
Like V, but assumes current package. |
| ! [[-]NUMBER] |
Redo a debugging command. Default is previous command. |
| H [-NUMBER] |
Displays the last -NUMBER commands of more than one letter. |
| q |
Quits. You may also use your EOF key character. |
| COMMAND |
Executes COMMAND as a perl statement. |
| p EXPR |
Prints EXPR. |
| = [ALIAS VALUE] |
Sets alias, or lists current aliases. |