Debian Codegraph @

upstream/fedora-44/man1/perlcheat.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLCHEAT 1"
61 .TH PERLCHEAT 1 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perlcheat \- Perl 5 Cheat Sheet
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This \*(Aqcheat sheet\*(Aq is a handy reference, meant for beginning Perl
71 programmers. Not everything is mentioned, but 195 features may
72 already be overwhelming.
73 .SS "The sheet"
74 .IX Subsection "The sheet"
75 .Vb 10
76 \& CONTEXTS SIGILS ref ARRAYS HASHES
77 \& void $scalar SCALAR @array %hash
78 \& scalar @array ARRAY @array[0, 2] @hash{\*(Aqa\*(Aq, \*(Aqb\*(Aq}
79 \& list %hash HASH $array[0] $hash{\*(Aqa\*(Aq}
80 \& &sub CODE
81 \& *glob GLOB SCALAR VALUES
82 \& FORMAT number, string, ref, glob, undef
83 \& REFERENCES
84 \& \e reference $$foo[1] aka $foo\->[1]
85 \& $@%&* dereference $$foo{bar} aka $foo\->{bar}
86 \& [] anon. arrayref ${$$foo[1]}[2] aka $foo\->[1]\->[2]
87 \& {} anon. hashref ${$$foo[1]}[2] aka $foo\->[1][2]
88 \& \e() list of refs
89 \& SYNTAX
90 \& OPERATOR PRECEDENCE foreach (LIST) { } for (a;b;c) { }
91 \& \-> while (e) { } until (e) { }
92 \& ++ \-\- if (e) { } elsif (e) { } else { }
93 \& ** unless (e) { } elsif (e) { } else { }
94 \& ! ~ \e u+ u\- given (e) { when (e) {} default {} }
95 \& =~ !~
96 \& * / % x NUMBERS vs STRINGS FALSE vs TRUE
97 \& + \- . = = undef, "", 0, "0"
98 \& << >> + . anything else
99 \& named uops == != eq ne
100 \& < > <= >= lt gt le ge < > <= >= lt gt le ge
101 \& == != <=> eq ne cmp ~~ <=> cmp
102 \& &
103 \& | ^ REGEX MODIFIERS REGEX METACHARS
104 \& && /i case insensitive ^ string begin
105 \& || // /m line based ^$ $ str end (bfr \en)
106 \& .. ... /s . includes \en + one or more
107 \& ?: /x /xx ign. wh.space * zero or more
108 \& = += last goto /p preserve ? zero or one
109 \& , => /a ASCII /aa safe {3,7} repeat in range
110 \& list ops /l locale /d dual | alternation
111 \& not /u Unicode [] character class
112 \& and /e evaluate /ee rpts \eb boundary
113 \& or xor /g global \ez string end
114 \& /o compile pat once (p) capture
115 \& DEBUG (?:p) no capture
116 \& \-MO=Deparse REGEX CHARCLASSES (?#t) comment
117 \& \-MO=Terse . [^\en] (?=p) ZW pos ahead
118 \& \-D## \es whitespace (?!p) ZW neg ahead
119 \& \-d:Trace \ew word chars (?<=p) ZW pos behind \eK
120 \& \ed digits (?<!p) ZW neg behind
121 \& CONFIGURATION \epP named property (?>p) no backtrack
122 \& perl \-V:ivsize \eh horiz.wh.space (?|p|p)branch reset
123 \& \eR linebreak (?<n>p)named capture
124 \& \eS \eW \eD \eH negate \eg{n} ref to named cap
125 \& \eK keep left part
126 \& FUNCTION RETURN LISTS
127 \& stat localtime caller SPECIAL VARIABLES
128 \& 0 dev 0 second 0 package $_ default variable
129 \& 1 ino 1 minute 1 filename $0 program name
130 \& 2 mode 2 hour 2 line $/ input separator
131 \& 3 nlink 3 day 3 subroutine $\e output separator
132 \& 4 uid 4 month\-1 4 hasargs $| autoflush
133 \& 5 gid 5 year\-1900 5 wantarray $! sys/libcall error
134 \& 6 rdev 6 weekday 6 evaltext $@ eval error
135 \& 7 size 7 yearday 7 is_require $$ process ID
136 \& 8 atime 8 is_dst 8 hints $. line number
137 \& 9 mtime 9 bitmask @ARGV command line args
138 \& 10 ctime 10 hinthash @INC include paths
139 \& 11 blksz 3..10 only @_ subroutine args
140 \& 12 blcks with EXPR %ENV environment
141 .Ve
142 .SH ACKNOWLEDGEMENTS
143 .IX Header "ACKNOWLEDGEMENTS"
144 The first version of this document appeared on Perl Monks, where several
145 people had useful suggestions. Thank you, Perl Monks.
146 .PP
147 A special thanks to Damian Conway, who didn\*(Aqt only suggest important changes,
148 but also took the time to count the number of listed features and make a
149 Raku version to show that Perl will stay Perl.
150 .SH AUTHOR
151 .IX Header "AUTHOR"
152 Juerd Waalboer <#####@juerd.nl>, with the help of many Perl Monks.
153 .SH "SEE ALSO"
154 .IX Header "SEE ALSO"
155 .IP \(bu 4
156 <https://perlmonks.org/?node_id=216602> \- the original PM post
157 .IP \(bu 4
158 <https://perlmonks.org/?node_id=238031> \- Damian Conway\*(Aqs Raku version
159 .IP \(bu 4
160 <https://juerd.nl/site.plp/perlcheat> \- home of the Perl Cheat Sheet