home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _2ccc48aeb0f63150137c8a6014eb1903 < prev    next >
Text File  |  2004-06-01  |  4KB  |  94 lines

  1. =head1 NAME
  2.  
  3. perlcheat - Perl 5 Cheat Sheet
  4.  
  5. =head1 DESCRIPTION
  6.  
  7. This 'cheat sheet' is a handy reference, meant for beginning Perl
  8. programmers. Not everything is mentioned, but 194 features may
  9. already be overwhelming.
  10.  
  11. =head2 The sheet
  12.  
  13.   CONTEXTS  SIGILS             ARRAYS        HASHES
  14.   void      $scalar   whole:   @array        %hash
  15.   scalar    @array    slice:   @array[0, 2]  @hash{'a', 'b'}
  16.   list      %hash     element: $array[0]     $hash{'a'}
  17.             &sub
  18.             *glob    SCALAR VALUES
  19.                      number, string, reference, glob, undef
  20.   REFERENCES
  21.   \     references      $$foo[1]       aka $foo->[1]
  22.   $@%&* dereference     $$foo{bar}     aka $foo->{bar}
  23.   []    anon. arrayref  ${$$foo[1]}[2] aka $foo->[1]->[2]
  24.   {}    anon. hashref   ${$$foo[1]}[2] aka $foo->[1][2]
  25.   \()   list of refs
  26.                           NUMBERS vs STRINGS  LINKS
  27.   OPERATOR PRECEDENCE     =          =        perl.plover.com
  28.   ->                      +          .        search.cpan.org
  29.   ++ --                   == !=      eq ne         cpan.org
  30.   **                      < > <= >=  lt gt le ge   pm.org
  31.   ! ~ \ u+ u-             <=>        cmp           tpj.com
  32.   =~ !~                                            perldoc.com
  33.   * / % x                 SYNTAX
  34.   + - .                   for    (LIST) { }, for (a;b;c) { }
  35.   << >>                   while  ( ) { }, until ( ) { }
  36.   named uops              if     ( ) { } elsif ( ) { } else { }
  37.   < > <= >= lt gt le ge   unless ( ) { } elsif ( ) { } else { }
  38.   == != <=> eq ne cmp     for equals foreach (ALWAYS)
  39.   &
  40.   | ^              REGEX METACHARS            REGEX MODIFIERS
  41.   &&               ^     string begin         /i case insens.
  42.   ||               $     str. end (before \n) /m line based ^$
  43.   .. ...           +     one or more          /s . includes \n
  44.   ?:               *     zero or more         /x ign. wh.space
  45.   = += -= *= etc.  ?     zero or one          /g global
  46.   , =>             {3,7} repeat in range
  47.   list ops         ()    capture          REGEX CHARCLASSES
  48.   not              (?:)  no capture       .  == [^\n]
  49.   and              []    character class  \s == [\x20\f\t\r\n]
  50.   or xor           |     alternation      \w == [A-Za-z0-9_]
  51.                    \b    word boundary    \d == [0-9]
  52.                    \z    string end       \S, \W and \D negate
  53.   DO
  54.   use strict;        DON'T            LINKS
  55.   use warnings;      "$foo"           perl.com
  56.   my $var;           $$variable_name  perlmonks.org
  57.   open() or die $!;  `$userinput`     use.perl.org
  58.   use Modules;       /$userinput/     perl.apache.org
  59.                                       parrotcode.org
  60.   FUNCTION RETURN LISTS
  61.   stat      localtime    caller         SPECIAL VARIABLES
  62.    0 dev    0 second     0 package      $_    default variable
  63.    1 ino    1 minute     1 filename     $0    program name
  64.    2 mode   2 hour       2 line         $/    input separator
  65.    3 nlink  3 day        3 subroutine   $\    output separator
  66.    4 uid    4 month-1    4 hasargs      $|    autoflush
  67.    5 gid    5 year-1900  5 wantarray    $!    sys/libcall error
  68.    6 rdev   6 weekday    6 evaltext     $@    eval error
  69.    7 size   7 yearday    7 is_require   $$    process ID
  70.    8 atime  8 is_dst     8 hints        $.    line number
  71.    9 mtime               9 bitmask      @ARGV command line args
  72.   10 ctime  just use                    @INC  include paths
  73.   11 blksz  POSIX::      3..9 only      @_    subroutine args
  74.   12 blcks  strftime!    with EXPR      %ENV  environment
  75.  
  76. =head1 ACKNOWLEDGEMENTS
  77.  
  78. The first version of this document appeared on Perl Monks, where several
  79. people had useful suggestions. Thank you, Perl Monks.
  80.  
  81. A special thanks to Damian Conway, who didn't only suggest important changes,
  82. but also took the time to count the number of listed features and make a
  83. Perl 6 version to show that Perl will stay Perl.
  84.  
  85. =head1 AUTHOR
  86.  
  87. Juerd Waalboer <juerd@cpan.org>, with the help of many Perl Monks.
  88.  
  89. =head1 SEE ALSO
  90.  
  91.  http://perlmonks.org/?node_id=216602      the original PM post
  92.  http://perlmonks.org/?node_id=238031      Damian Conway's Perl 6 version
  93.  http://juerd.nl/site.plp/perlcheat        home of the Perl Cheat Sheet
  94.