1: Perl 5 cheat sheet v6 by Juerd Waalboer, http://juerd.nl/
2: .
3: CONTEXTS SIGILS ARRAYS HASHES
4: void $scalar @array %hash
5: scalar @array @array[0, 2] @hash{'a', 'b'}
6: list %hash $array[0] $hash{'a'}
7: &sub
8: *glob SCALAR VALUES
9: number, string, reference, glob, undef
10: REFERENCES
11: \ references $$foo[1] aka $foo->[1]
12: $@%&* dereference $$foo{bar} aka $foo->{bar}
13: [] anon. arrayref ${$$foo[1]}[2] aka $foo->[1]->[2]
14: {} anon. hashref ${$$foo[1]}[2] aka $foo->[1][2]
15: \() list of refs
16: NUMBERS vs STRINGS LINKS
17: OPERATOR PRECEDENCE = = perl.plover.com
18: -> + . search.cpan.org
19: ++ -- == != eq ne cpan.org
20: ** < > <= >= lt gt le ge pm.org
21: ! ~ \ u+ u- <=> cmp tpj.com
22: =~ !~ perldoc.com
23: * / % x SYNTAX
24: + - . for (LIST) { }, for (a;b;c) { }
25: << >> while ( ) { }, until ( ) { }
26: named uops if ( ) { } elsif ( ) { } else { }
27: < > <= >= lt gt le ge unless ( ) { } elsif ( ) { } else { }
28: == != <=> eq ne cmp for equals foreach (ALWAYS)
29: &
30: | ^ REGEX METACHARS REGEX MODIFIERS
31: && ^ string begin /i case insensitive
32: || $ string end (before \n) /m line based ^$
33: .. ... + one or more /s dot includes \n
34: ?: * any amount /x ignore wh.space
35: = += -= *= etc. ? zero or one /g global
36: , => () capture
37: list ops (?:) no capture REGEX CHARCLASSES
38: not [] character class . == [^\n]
39: and | alternation \s == [\x20\f\t\r\n]
40: or xor {1,2} amount \w == [A-Za-z0-9_]
41: \b word boundary \d == [0-9]
42: \z string end \S, \W and \D negate
43: ALWAYS
44: use strict; NEVER unless pro LINKS
45: use warnings; "$foo" perl.com
46: my $var; $foo = "bar"; $$foo perlmonks.org
47: open() or die $!; `$userinput` use.perl.org
48: use Modules; /$userinput/ perl.apache.org
49:
50:
51: This is my christmas gift for all Perl newbies out there :)
52: Have fun!
53:
54: v1: initial version
55: v2: fixed per merlyn's suggestions
56: v3: added missing dollar signs
57: v4: changed per TheDamian's suggestions
58: v5: changed per TheDamian's suggestions
59:
60:
61: Note: It's hard to maintain two copies, so if you want
62: the most recent version, visit my homepage. Sorry!
63:
64: Update: If you have Perl 5.8.1 or later installed, try this
65: on a command line:
66:
67: perldoc perlcheat # :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl cheat sheet
by TheDamian (Vicar) on Nov 29, 2002 at 23:00 UTC | |
by Juerd (Abbot) on Nov 29, 2002 at 23:19 UTC | |
by TheDamian (Vicar) on Dec 02, 2002 at 01:33 UTC | |
by Juerd (Abbot) on Dec 02, 2002 at 07:42 UTC | |
|
•Re: Perl cheat sheet
by merlyn (Sage) on Nov 29, 2002 at 22:15 UTC | |
by Juerd (Abbot) on Nov 29, 2002 at 22:22 UTC | |
|
Re: Perl cheat sheet
by boo_radley (Parson) on Nov 30, 2002 at 01:45 UTC | |
by grantm (Parson) on Nov 30, 2002 at 19:18 UTC | |
by bivouac (Beadle) on Dec 12, 2002 at 19:05 UTC | |
by Aristotle (Chancellor) on Dec 14, 2002 at 22:57 UTC | |
by mooseboy (Pilgrim) on Nov 30, 2002 at 11:35 UTC | |
by Popcorn Dave (Abbot) on Nov 30, 2002 at 05:38 UTC | |
|
Re: Perl cheat sheet
by belg4mit (Prior) on Nov 30, 2002 at 02:45 UTC | |
by mattr (Curate) on Dec 01, 2002 at 15:32 UTC | |
|
Re: Perl cheat sheet
by DapperDan (Pilgrim) on Nov 30, 2002 at 17:37 UTC | |
by Juerd (Abbot) on Nov 30, 2002 at 19:52 UTC | |
|
Re: Perl cheat sheet
by theorbtwo (Prior) on Nov 30, 2002 at 03:01 UTC | |
by Juerd (Abbot) on Nov 30, 2002 at 13:24 UTC | |
by theorbtwo (Prior) on Nov 30, 2002 at 22:28 UTC | |
|
Re: Perl cheat sheet
by mce (Curate) on Dec 04, 2002 at 11:06 UTC | |
|
Re: Perl cheat sheet
by oakbox (Chaplain) on Jan 01, 2003 at 09:16 UTC | |
by Juerd (Abbot) on Jan 01, 2003 at 14:09 UTC | |
|
Re: Perl cheat sheet
by Thelonious (Scribe) on Feb 22, 2005 at 05:54 UTC | |
by holli (Abbot) on Feb 22, 2005 at 07:18 UTC | |
|
Re: Perl cheat sheet
by Anonymous Monk on Aug 21, 2006 at 18:57 UTC | |
by ikegami (Patriarch) on Aug 21, 2006 at 19:32 UTC | |
by ursus (Acolyte) on Jan 07, 2009 at 00:50 UTC | |
by ikegami (Patriarch) on Jan 07, 2009 at 01:24 UTC | |
by ursus (Acolyte) on Jan 07, 2009 at 06:10 UTC | |
by lodin (Hermit) on Jan 07, 2009 at 08:07 UTC | |
by ikegami (Patriarch) on Jan 07, 2009 at 09:23 UTC |