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                                NUMBERS vs STRINGS    LINKS
28         OPERATOR PRECEDENCE    =          =          perldoc.perl.org
29         ->                     +          .           search.cpan.org
30         ++ --                  == !=      eq ne              cpan.org
31         **                     < > <= >=  lt gt le ge          pm.org
32         ! ~ \ u+ u-            <=>        cmp                p3rl.org
33         =~ !~                                           perlmonks.org
34         * / % x                SYNTAX
35         + - .                  foreach (LIST) { }     for (a;b;c) { }
36         << >>                  while   (e) { }        until (e)   { }
37         named uops             if      (e) { } elsif (e) { } else { }
38         < > <= >= lt gt le ge  unless  (e) { } elsif (e) { } else { }
39         == != <=> eq ne cmp ~~ given   (e) { when (e) {} default {} }
40         &
41         | ^             REGEX METACHARS          REGEX MODIFIERS
42         &&              ^      string begin      /i case insensitive
43         || //           $      str end (bfr \n)  /m line based ^$
44         .. ...          +      one or more       /s . includes \n
45         ?:              *      zero or more      /x ignore wh.space
46         = += -= *= etc  ?      zero or one       /p preserve
47         , =>            {3,7}  repeat in range   /a ASCII    /aa safe
48         list ops        |      alternation       /l locale   /d  dual
49         not             []     character class   /u Unicode
50         and             \b     word boundary     /e evaluate /ee rpts
51         or xor          \z     string end        /g global
52                         ()     capture           /o compile pat once
53         DEBUG           (?:p)  no capture
54          -MO=Deparse    (?#t)  comment           REGEX CHARCLASSES
55          -MO=Terse      (?=p)  ZW pos ahead      .   [^\n]
56          -D##           (?!p)  ZW neg ahead      \s  whitespace
57          -d:Trace       (?<=p) ZW pos behind \K  \w  word chars
58                         (?<!p) ZW neg behind     \d  digits
59         CONFIGURATION   (?>p)  no backtrack      \pP named property
60         perl -V:ivsize  (?|p|p)branch reset      \h  horiz.wh.space
61                         (?&NM) cap to name       \R  linebreak
62                                                  \S \W \D \H negate
63         FUNCTION RETURN LISTS
64         stat      localtime    caller         SPECIAL VARIABLES
65          0 dev    0 second      0 package     $_    default variable
66          1 ino    1 minute      1 filename    $0    program name
67          2 mode   2 hour        2 line        $/    input separator
68          3 nlink  3 day         3 subroutine  $\    output separator
69          4 uid    4 month-1     4 hasargs     $|    autoflush
70          5 gid    5 year-1900   5 wantarray   $!    sys/libcall error
71          6 rdev   6 weekday     6 evaltext    $@    eval error
72          7 size   7 yearday     7 is_require  $$    process ID
73          8 atime  8 is_dst      8 hints       $.    line number
74          9 mtime                9 bitmask     @ARGV command line args
75         10 ctime               10 hinthash    @INC  include paths
76         11 blksz               3..10 only     @_    subroutine args
77         12 blcks               with EXPR      %ENV  environment
78

ACKNOWLEDGEMENTS

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

AUTHOR

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

SEE ALSO

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