1PERLCHEAT(1)           Perl Programmers Reference Guide           PERLCHEAT(1)
2
3
4

NAME

6       perlcheat - Perl 5 Cheat Sheet
7

DESCRIPTION

9       This 'cheat sheet' is a handy reference, meant for beginning Perl
10       programmers. Not everything is mentioned, but 195 features may already
11       be overwhelming.
12
13   The sheet
14         CONTEXTS  SIGILS  ref        ARRAYS        HASHES
15         void      $scalar SCALAR     @array        %hash
16         scalar    @array  ARRAY      @array[0, 2]  @hash{'a', 'b'}
17         list      %hash   HASH       $array[0]     $hash{'a'}
18                   &sub    CODE
19                   *glob   GLOB       SCALAR VALUES
20                           FORMAT     number, string, ref, glob, undef
21         REFERENCES
22         \      reference       $$foo[1]       aka $foo->[1]
23         $@%&*  dereference     $$foo{bar}     aka $foo->{bar}
24         []     anon. arrayref  ${$$foo[1]}[2] aka $foo->[1]->[2]
25         {}     anon. hashref   ${$$foo[1]}[2] aka $foo->[1][2]
26         \()    list of refs
27                                SYNTAX
28         OPERATOR PRECEDENCE    foreach (LIST) { }     for (a;b;c) { }
29         ->                     while   (e) { }        until (e)   { }
30         ++ --                  if      (e) { } elsif (e) { } else { }
31         **                     unless  (e) { } elsif (e) { } else { }
32         ! ~ \ u+ u-            given   (e) { when (e) {} default {} }
33         =~ !~
34         * / % x                 NUMBERS vs STRINGS  FALSE vs TRUE
35         + - .                   =          =        undef, "", 0, "0"
36         << >>                   +          .        anything else
37         named uops              == !=      eq ne
38         < > <= >= lt gt le ge   < > <= >=  lt gt le ge
39         == != <=> eq ne cmp ~~  <=>        cmp
40         &
41         | ^             REGEX MODIFIERS       REGEX METACHARS
42         &&              /i case insensitive   ^      string begin
43         || //           /m line based ^$      $      str end (bfr \n)
44         .. ...          /s . includes \n      +      one or more
45         ?:              /x /xx ign. wh.space  *      zero or more
46         = += last goto  /p preserve           ?      zero or one
47         , =>            /a ASCII    /aa safe  {3,7}  repeat in range
48         list ops        /l locale   /d  dual  |      alternation
49         not             /u Unicode            []     character class
50         and             /e evaluate /ee rpts  \b     boundary
51         or xor          /g global             \z     string end
52                         /o compile pat once   ()     capture
53         DEBUG                                 (?:p)  no capture
54         -MO=Deparse     REGEX CHARCLASSES     (?#t)  comment
55         -MO=Terse       .   [^\n]             (?=p)  ZW pos ahead
56         -D##            \s  whitespace        (?!p)  ZW neg ahead
57         -d:Trace        \w  word chars        (?<=p) ZW pos behind \K
58                         \d  digits            (?<!p) ZW neg behind
59         CONFIGURATION   \pP named property    (?>p)  no backtrack
60         perl -V:ivsize  \h  horiz.wh.space    (?|p|p)branch reset
61                         \R  linebreak         (?<n>p)named capture
62                         \S \W \D \H negate    \g{n}  ref to named cap
63                                               \K     keep left part
64         FUNCTION RETURN LISTS
65         stat      localtime    caller         SPECIAL VARIABLES
66          0 dev    0 second      0 package     $_    default variable
67          1 ino    1 minute      1 filename    $0    program name
68          2 mode   2 hour        2 line        $/    input separator
69          3 nlink  3 day         3 subroutine  $\    output separator
70          4 uid    4 month-1     4 hasargs     $|    autoflush
71          5 gid    5 year-1900   5 wantarray   $!    sys/libcall error
72          6 rdev   6 weekday     6 evaltext    $@    eval error
73          7 size   7 yearday     7 is_require  $$    process ID
74          8 atime  8 is_dst      8 hints       $.    line number
75          9 mtime                9 bitmask     @ARGV command line args
76         10 ctime               10 hinthash    @INC  include paths
77         11 blksz               3..10 only     @_    subroutine args
78         12 blcks               with EXPR      %ENV  environment
79

ACKNOWLEDGEMENTS

81       The first version of this document appeared on Perl Monks, where
82       several people had useful suggestions. Thank you, Perl Monks.
83
84       A special thanks to Damian Conway, who didn't only suggest important
85       changes, but also took the time to count the number of listed features
86       and make a Perl 6 version to show that Perl will stay Perl.
87

AUTHOR

89       Juerd Waalboer <#####@juerd.nl>, with the help of many Perl Monks.
90

SEE ALSO

92       ·   <http://perlmonks.org/?node_id=216602> - the original PM post
93
94       ·   <http://perlmonks.org/?node_id=238031> - Damian Conway's Perl 6
95           version
96
97       ·   <http://juerd.nl/site.plp/perlcheat> - home of the Perl Cheat Sheet
98
99
100
101perl v5.28.2                      2018-11-01                      PERLCHEAT(1)
Impressum