The "Unknown:"s below indicate that an entry is incomplete.
{ ... }(1) | block (grouping statements, especially when statements are not expressions) |
nothing needed | breaking lines (useful when end-of-line and/or indentation has a special meaning) |
# | commenting (until end of line) |
< > <= >= | comparison |
lt gt le ge | comparison |
min minstr / max maxstr(2) | comparison (min / max (binary or more)) |
a <=> b | comparison (returns 3 values (i.e. inferior, equal or superior)) |
cmp | comparison (returns 3 values (i.e. inferior, equal or superior)) |
=pod ... =cut(3) | documentation comment |
== != | equality / inequality (shallow) |
incremental garbage collection => not needed | force garbage collection |
( ... ) | grouping expressions |
__LINE__ __FILE__ | information about the current line and file |
eval | runtime evaluation |
case-sensitive | tokens (case-sensitivity (keywords, variable identifiers...)) |
[_a-zA-Z0-9]+ | tokens (variable identifier regexp) |
CamelCase for modules, ALL_CAPS for constants, unclear for functions / variables | tokens (what is the standard way for scrunching together multiple words) |
do | use a block as a return value (when statements are not expressions) |
= | variable assignment or declaration (assignment) |
my / our / local / use vars | variable assignment or declaration (declaration) |
sub { my ($a, $b) = @_; ... } | anonymous function |
{ my ($a, $b) = @_; ... }(4) | anonymous function |
f(a,b,...) | function call |
&$f(a,b,...) or $f->(a,b,...) | function call |
f a, b, ... | function call |
f | function call (with no parameter) |
f() | function call (with no parameter) |
&$f or $f->() | function call (with no parameter) |
AUTOLOAD | function called when a function is not defined (in dynamic languages) |
sub f { ... } | function definition |
sub f { ... @_ } | function definition (variable number of arguments) |
return(5) | function return value (breaks the control flow) |
no syntax needed(6) | function return value (function body is the result) |
caller | runtime inspecting the caller information |
next / last | breaking control flow (continue / break) |
goto | breaking control flow (goto (unconditional jump)) |
redo/ | breaking control flow (redo / retry) |
return(5) | breaking control flow (returning a value) |
eval {a}; if ($@) ... | exception (catching) |
die | exception (throwing) |
if (c) {...} | if_then |
... if c | if_then |
c and ... | if_then |
c and ... | if_then |
if (c) {b1} elsif (c2) {b2} else {b3} | if_then_else |
c ? b1 : b2 | if_then_else |
unless | ifnot_then (unless) |
do {...} until c | loop (do something until condition) |
for | loop (for "a la C" (while + initialisation)) |
for (my $i = 10; $i >= 1; $i--) { ... } | loop (for each value in a numeric range, 1 decrement) |
foreach my $i (1 .. 10) { ... } | loop (for each value in a numeric range, 1 increment (see also the entries about ranges)) |
for (my $i = 1; $i <= 10; $i += 2) { ... } | loop (for each value in a numeric range, free increment) |
while (c) ... | loop (while condition do something) |
my %case = ( v1 => sub { ... }, v2 => sub { ... }, ); if ($case{val}) { $case{val}->() } else { ... } | multiple selection (switch) |
use Switch; switch ($val) { case v1 { ... } case v2 { ... } else ... })(7) | multiple selection (switch) |
, | sequence |
; | sequence |
$o->SUPER::method(...) | accessing parent method |
first parameter(8) | current instance |
ref | get the type/class corresponding to an object/instance/value |
can | has the method |
@ISA = qw(parent1 parent2) | inheritance |
DESTROY | manually call an object's destructor |
object->method(para) | method invocation |
object->method | method invocation (with no parameter) |
Storable::dclone | object cloning |
new class_name(...) | object creation |
isa | testing class membership |
package p; | declare |
@ISA = qw(Exporter); @EXPORT = qw(name1 name2 ...); | declare (selective export) |
use p(9) | import (everything into current namespace) |
use p;(10) | import (package (ie. load the package)) |
require p | import (package (ie. load the package)) |
use p qw(name1 name2 ...) | import (selectively) |
:: | package scope |
' | package scope |
chr | ascii to character |
ord | character to ascii |
Dumper | convert something to a string (see also string interpolation) |
"" . e | convert something to a string (see also string interpolation) |
x | duplicate n times |
substr | extract a substring |
index | locate a substring |
rindex | locate a substring (starting at the end) |
all strings allow multi-line strings | multi-line |
Storable::store | serialize (marshalling) |
simple print (on simple objects) | |
printf | simple print (printf-like) |
sprintf | sprintf-like |
Storable::retrieve | sprintf-like |
. | string concatenation |
eq ne | string equality & inequality |
length | string size |
"\n" | strings (end-of-line (without writing the real CR or LF character)) |
"... $v ..." | strings (with interpolation of variables) |
<<MARK ... $v ... MARK | strings (with interpolation of variables) |
qq(...(... $v ...)...), qq[...], qq{...}, qq<...>, qq/.../ | strings (with interpolation of variables) |
'...' | strings (with no interpolation of variables) |
<<'MARK' ... MARK | strings (with no interpolation of variables) |
q(...(...)...), q[...], q{...}, q<...>, q/.../ | strings (with no interpolation of variables) |
Storable::store | unserialize (un-marshalling) |
uc / lc | upper / lower case character |
uc / lc | uppercase / lowercase / capitalized string |
undef | false value |
0(11) | false value |
0.0 | false value |
"" | false value |
"0" | false value |
'' | false value |
() | false value |
! | logical not |
not(12) | logical not |
|| / && | logical or / and (short circuit) |
or / and | logical or / and (short circuit) |
anything not false | true value |
splice(@a, $i, 0, $e) | adding an element at index (side-effect) |
unshift | adding an element at the beginning (list cons) (side-effect) |
push | adding an element at the end (side-effect) |
reduce(13) | f(... f(f(init, e1), e2) ..., en) |
first(2) | find an element |
for | for each element do something |
foreach | for each element do something |
shift | get the first element and remove it |
pop | get the last element and remove it |
join(s, l) | join a list of strings in a string using a glue string |
grep | keep elements (matching) |
a[-1] | last element |
, | list concatenation |
[ a, b, c ](14) | list constructor |
( a, b, c ) | list constructor |
scalar @l | list size |
a[i] | list/array indexing |
reverse | reverse |
min minstr / max maxstr(2) | smallest / biggest element |
sort(15) | sort |
map | transform a list (or bag) in another one |
ARRAY | type name |
(a) | computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (1-uple) |
() | computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (empty tuple) |
t | computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (using a tuple for a function call) |
$h{k} | dictionary (access: read/write) |
{ a => b, c => d } | dictionary (constructor) |
{ a, b, c, d } | dictionary (constructor) |
exists $h{k} | dictionary (has the key ?) |
keys | dictionary (list of keys) |
values | dictionary (list of values) |
(%h1, %h2)(16) | dictionary (merge) |
delete $h{k} | dictionary (remove by key) |
HASH | dictionary (type name) |
|| | optional value (null coalescing) |
//(17) | optional value (null coalescing) |
undef | optional value (null value) |
v | optional value (value) |
v | optional value (value) |
a .. b | range (inclusive .. inclusive) |
\ | reference (pointer) (creation) |
$ @ % &(18) | reference (pointer) (dereference) |
->[...] ->{...} ->(...)(19) | reference (pointer) (dereference) |
( a, b, c ) | tuple constructor |
+ / - / * / / | addition / subtraction / multiplication / division |
& / | / ^ | bitwise operators (and / or / xor) |
~ | bitwise operators (bitwise inversion) |
<< / >> | bitwise operators (left shift / right shift / unsigned right shift) |
** | exponentiation (power) |
log10 | logarithm (base 10) |
log | logarithm (base e) |
% | modulo (modulo of -3 / 2 is 1) |
- | negation |
1000, 1000.0, 1E3(20) | numbers syntax (floating point) |
1_000, 10_00, 100_0 | numbers syntax (integer thousand-separator) |
0b1, 07, 0xf(21) | numbers syntax (integers in base 2, octal and hexadecimal) |
1000 | numbers syntax (integers) |
mathematical | operator priorities and associativities (addition vs multiplication) |
mathematical | operator priorities and associativities (exponentiation vs negation (is -3^2 equal to 9 or -9)) |
rand | random (random number) |
srand | random (seed the pseudo random generator) |
sqrt / exp / abs | square root / e-exponential / absolute value |
sin / cos / tan | trigonometry (basic) |
asin / acos / atan(22) | trigonometry (inverse) |
int / / floor / ceil | truncate / round / floor / ceil |