0% found this document useful (0 votes)
77 views

Perl Quick Reference Card

This document provides a summary of Perl operator precedence and regular expression syntax. It lists the associativity, arity, and precedence class of various Perl operators. It also summarizes file test operators, quote constructs, translation escapes, pattern modifiers, quantifiers, sequences and other regular expression syntax in Perl.

Uploaded by

api-3744861
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Perl Quick Reference Card

This document provides a summary of Perl operator precedence and regular expression syntax. It lists the associativity, arity, and precedence class of various Perl operators. It also summarizes file test operators, quote constructs, translation escapes, pattern modifiers, quantifiers, sequences and other regular expression syntax in Perl.

Uploaded by

api-3744861
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Perl Quick Reference Card Operator Precedence (continued) 87 tr/// Modifiers 156

Associativiy Arity Precedence Class /c Complement SEARCHLIST.


version 0.01 – editor: John Bokma – freelance programmer Right 3 ?: /d Delete found but unreplaced characters.
DRAFT VERSION, check: http://johnbokma.com/perl/ /s Squash duplicate replaced characters.
Right 2 = += -= *= and so on
Backslashed Character Escapes 61
Left 2 , =>
General Regex Metacharacters 159
\n Newline (usually LF) \e ESC character
Right 0+ List operators (rightward)
\r Carriage return (usually CR) \033 ESC in octal Symbol Atomic Meaning
Right 1 not
\t Horizontal tab \x7f DEL in hexadecimal \… Varies De-meta next nonalphanumeric character, meta
Left 2 and
\f Form feed \cC Control-C next alphanumeric character (maybe).
Left 2 or xor
\b Backspace \x{263a} Unicode (smiley) …|… No Alternation (match one or the other).
\a Alert (bell) \N{NAME} Named character File Test Operators 98 (…) Yes Grouping (treat as a unit).
-r File is readable by effective UID/GID. […] Yes Character class (match one character from a set).
Translation Escapes 61
-w File is writable by effective UID/GID.
\u Force next character to uppercase (“titlecase” in Unicode).
-x File is executable by effective UID/GID. ^ No True at beginning of string (or after a newline,
\l Force next character to lowercase.
-o File is owned by effective UID/GID. maybe).
\U Force all following characters to uppercase
-R File is readable by real UID/GID. . Yes Match one character (except newline, normally).
\L Force all following characters to lowercase
-W File is writable by real UID/GID. $ No True at end of string (or before any newline,
\Q Backslash all following nonalphanumeric characters.
-X File is executable by real UID/GID. maybe).
\E End \U, \L, or \Q.
-O File is owned by real UID/GID.
Quote Constructs 63 -e File exists. Regex Quantifiers 159-160
-z File has zero size Quantifier Atomic Meaning
Customary Generic Meaning Interpolates
-s File has nonzero size (returns size). * No Match 0 or more times (maximal).
-f File is a plain file. + No Match 1 or more times (maximal).
'' q// Literal string No
-d File is a directory. ? No Match 0 or 1 time (maximal).
"" qq// Literal string Yes
-l File is a symbolic link. {COUNT} No Match exactly COUNT times.
`` qx// Command execution Yes
-p File is a named pipe (FIFO). {MIN,} No Match at least MIN times (maximal).
() qw// Word list No
-S File is a socket. {MIN,MAX} No Match at least MIN but not more than MAX
// m// Pattern match Yes
-b File is a block special file. times (maximal).
s/// s/// Pattern substitution Yes
-c File is a character special file.
y/// tr/// Character translation No
-t Filehandle is open to a tty. *? No Match 0 or more times (minimal).
"" qr// Regular expression Yes +? No Match 1 or more times (minimal).
-u File has setuid bit set.
Note: no interpolation is done if you use single quotes for delimiters. -g File has setgid bit set. ?? No Match 0 or 1 time (minimal).
-k File has sticky bit set. {MIN,}? No Match at least MIN times (minimal).
Operator Precedence 87 -T File is a text file. {MIN,MAX}? No Match at least MIN but not more than MAX
Associativiy Arity Precedence Class -B File is a binary file (opposite of -T). times (minimal).
None 0 Terms, and list operators (leftward) -M Age of file (at startup) in (fractional) days since modification.
Extended Regex Sequences 160
Left 2 -> -A Age of file (at startup) in (fractional) days since last access.
Extension Atomic Meaning
None 1 ++ -- -C Age of file (at startup) in (fractional) days since inode change.
Right 2 ** (?#…) No Comment, discard.
Right 1 ! ~ > and unary + and unary - Pattern Modifiers 147 (?:…) Yes Cluster-only parentheses, no capturing.
Left 2 =~ !~ /i Ignore alphabetic case distinctions (case insensitive). (?imsx-imsx) No Enable/disable pattern modifiers.
Left 2 */%x /s Let . match newline and ignore deprecated $* variable. (?imsx-imsx:…) Yes Cluster-only parentheses plus modifiers.
Left 2 +-. /m Let ^ and $ match next embedded \n. (?=…) No True if lookahead assertion succeeds.
Left 2 << >> /x Ignore (most) whitespace and permit comments in pattern. (?!…) No True if lookahead assertion fails.
Right 0,1 Named unary operators /o Compile pattern only once. (?<=…) No True if lookbehind assertion succeeds.
None 2 < > <= >= lt gt le ge (?<!…) No True if lookbehind assertion fails.
Additional m// Modifiers 150 (?>…) Yes Match nonbacktracking subpattern.
None 2 == != <=> eq ne cmp
/g Globally find all matches. (?{…}) No Execute embedded Perl code.
Left 2 &
/cg Allow continued search after failed /g match. (??{…}) Yes Match regex from embedded Perl code.
Left 2 |^
Left 2 (?(…)…|…) Yes Match with if-then-else pattern.
&& Additional s/// Modifiers 153
Left 2 || (?(…)…) Yes Match with if-then pattern.
/g Replace globally, that is, all occurences.
None 2 .. ... /e Evaluate the right side as an expression.

You might also like