Debian Codegraph @

upstream/opensuse-tumbleweed/man1/perlvar.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 "PERLVAR 1"
61 .TH PERLVAR 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 perlvar \- Perl predefined variables
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 .SS "The Syntax of Variable Names"
71 .IX Subsection "The Syntax of Variable Names"
72 Variable names in Perl can have several formats. Usually, they
73 must begin with a letter or underscore, in which case they can be
74 arbitrarily long (up to an internal limit of 251 characters) and
75 may contain letters, digits, underscores, or the special sequence
76 \&\f(CW\*(C`::\*(C'\fR or \f(CW\*(C`\*(Aq\*(C'\fR. In this case, the part before the last \f(CW\*(C`::\*(C'\fR or
77 \&\f(CW\*(C`\*(Aq\*(C'\fR is taken to be a \fIpackage qualifier\fR; see perlmod.
78 A Unicode letter that is not ASCII is not considered to be a letter
79 unless \f(CW"use\ utf8"\fR is in effect, and somewhat more complicated
80 rules apply; see "Identifier parsing" in perldata for details.
81 .PP
82 Perl variable names may also be a sequence of digits, a single
83 punctuation character, or the two\-character sequence: \f(CW\*(C`^\*(C'\fR (caret or
84 CIRCUMFLEX ACCENT) followed by any one of the characters \f(CW\*(C`[][A\-Z^_?\e]\*(C'\fR.
85 These names are all reserved for
86 special uses by Perl; for example, the all\-digits names are used
87 to hold data captured by backreferences after a regular expression
88 match.
89 .PP
90 Since Perl v5.6.0, Perl variable names may also be alphanumeric strings
91 preceded by a caret. These must all be written using the demarcated
92 variable form using curly braces such as \f(CW\*(C`${^Foo}\*(C'\fR;
93 the braces are \fBnot\fR optional. \f(CW\*(C`${^Foo}\*(C'\fR denotes the scalar variable
94 whose name is considered to be a control\-\f(CW\*(C`F\*(C'\fR followed by two \f(CW\*(C`o\*(C'\fR\*(Aqs.
95 (See "Demarcated variable names using braces" in perldata for more
96 information on this form of spelling a variable name or specifying
97 access to an element of an array or a hash).
98 These variables are
99 reserved for future special uses by Perl, except for the ones that
100 begin with \f(CW\*(C`^_\*(C'\fR (caret\-underscore). No
101 name that begins with \f(CW\*(C`^_\*(C'\fR will acquire a special
102 meaning in any future version of Perl; such names may therefore be
103 used safely in programs. \f(CW$^_\fR itself, however, \fIis\fR reserved.
104 .PP
105 Note that you also \fBmust\fR use the demarcated form to access subscripts
106 of variables of this type when interpolating, for instance to access the
107 first element of the \f(CW\*(C`@{^CAPTURE}\*(C'\fR variable inside of a double quoted
108 string you would write \f(CW"${^CAPTURE[0]}"\fR and NOT \f(CW"${^CAPTURE}[0]"\fR
109 which would mean to reference a scalar variable named \f(CW\*(C`${^CAPTURE}\*(C'\fR and
110 not index 0 of the magic \f(CW\*(C`@{^CAPTURE}\*(C'\fR array which is populated by the
111 regex engine.
112 .PP
113 Perl identifiers that begin with digits or
114 punctuation characters are exempt from the effects of the \f(CW\*(C`package\*(C'\fR
115 declaration and are always forced to be in package \f(CW\*(C`main\*(C'\fR; they are
116 also exempt from \f(CW\*(C`strict \*(Aqvars\*(Aq\*(C'\fR errors. A few other names are also
117 exempt in these ways:
118 .PP
119 .Vb 5
120 \& ENV STDIN
121 \& INC STDOUT
122 \& ARGV STDERR
123 \& ARGVOUT
124 \& SIG
125 .Ve
126 .PP
127 In particular, the special \f(CW\*(C`${^_XYZ}\*(C'\fR variables are always taken
128 to be in package \f(CW\*(C`main\*(C'\fR, regardless of any \f(CW\*(C`package\*(C'\fR declarations
129 presently in scope.
130 .SH "SPECIAL VARIABLES"
131 .IX Header "SPECIAL VARIABLES"
132 The following names have special meaning to Perl. Most punctuation
133 names have reasonable mnemonics, or analogs in the shells.
134 Nevertheless, if you wish to use long variable names, you need only say:
135 .PP
136 .Vb 1
137 \& use English;
138 .Ve
139 .PP
140 at the top of your program. This aliases all the short names to the long
141 names in the current package. Some even have medium names, generally
142 borrowed from \fBawk\fR. For more info, please see English.
143 .PP
144 Before you continue, note the sort order for variables. In general, we
145 first list the variables in case\-insensitive, almost\-lexicographical
146 order (ignoring the \f(CW\*(C`{\*(C'\fR or \f(CW\*(C`^\*(C'\fR preceding words, as in \f(CW\*(C`${^UNICODE}\*(C'\fR
147 or \f(CW$^T\fR), although \f(CW$_\fR and \f(CW@_\fR move up to the top of the pile.
148 For variables with the same identifier, we list it in order of scalar,
149 array, hash, and bareword.
150 .SS "General Variables"
151 .IX Subsection "General Variables"
152 .ie n .IP $ARG 8
153 .el .IP \f(CW$ARG\fR 8
154 .IX Item "$ARG"
155 .PD 0
156 .ie n .IP $_ 8
157 .el .IP \f(CW$_\fR 8
158 .IX Xref "$_ $ARG"
159 .IX Item "$_"
160 .PD
161 The default input and pattern\-searching space. The following pairs are
162 equivalent:
163 .Sp
164 .Vb 2
165 \& while (<>) {...} # equivalent only in while!
166 \& while (defined($_ = <>)) {...}
167 \&
168 \& /^Subject:/
169 \& $_ =~ /^Subject:/
170 \&
171 \& tr/a\-z/A\-Z/
172 \& $_ =~ tr/a\-z/A\-Z/
173 \&
174 \& chomp
175 \& chomp($_)
176 .Ve
177 .Sp
178 Here are the places where Perl will assume \f(CW$_\fR even if you don\*(Aqt use it:
179 .RS 8
180 .IP \(bu 3
181 The following functions use \f(CW$_\fR as a default argument:
182 .Sp
183 abs, alarm, chomp, chop, chr, chroot,
184 cos, defined, eval, evalbytes, exp, fc, glob, hex, int, lc,
185 lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, printf,
186 quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only),
187 rmdir, say, sin, split (for its second
188 argument), sqrt, stat, study, uc, ucfirst,
189 unlink, unpack.
190 .IP \(bu 3
191 All file tests (\f(CW\*(C`\-f\*(C'\fR, \f(CW\*(C`\-d\*(C'\fR) except for \f(CW\*(C`\-t\*(C'\fR, which defaults to STDIN.
192 See "\-X" in perlfunc
193 .IP \(bu 3
194 The pattern matching operations \f(CW\*(C`m//\*(C'\fR, \f(CW\*(C`s///\*(C'\fR and \f(CW\*(C`tr///\*(C'\fR (aka \f(CW\*(C`y///\*(C'\fR)
195 when used without an \f(CW\*(C`=~\*(C'\fR operator.
196 .IP \(bu 3
197 The default iterator variable in a \f(CW\*(C`foreach\*(C'\fR loop if no other
198 variable is supplied.
199 .IP \(bu 3
200 The implicit iterator variable in the \f(CWgrep()\fR and \f(CWmap()\fR functions.
201 .IP \(bu 3
202 The implicit variable of \f(CWgiven()\fR.
203 .IP \(bu 3
204 The default place to put the next value or input record
205 when a \f(CW\*(C`<FH>\*(C'\fR, \f(CW\*(C`readline\*(C'\fR, \f(CW\*(C`readdir\*(C'\fR or \f(CW\*(C`each\*(C'\fR
206 operation\*(Aqs result is tested by itself as the sole criterion of a \f(CW\*(C`while\*(C'\fR
207 test. Outside a \f(CW\*(C`while\*(C'\fR test, this will not happen.
208 .RE
209 .RS 8
210 .Sp
211 \&\f(CW$_\fR is a global variable.
212 .Sp
213 However, between perl v5.10.0 and v5.24.0, it could be used lexically by
214 writing \f(CW\*(C`my $_\*(C'\fR. Making \f(CW$_\fR refer to the global \f(CW$_\fR in the same scope
215 was then possible with \f(CW\*(C`our $_\*(C'\fR. This experimental feature was removed and is
216 now a fatal error, but you may encounter it in older code.
217 .Sp
218 Mnemonic: underline is understood in certain operations.
219 .RE
220 .ie n .IP @ARG 8
221 .el .IP \f(CW@ARG\fR 8
222 .IX Item "@ARG"
223 .PD 0
224 .ie n .IP @_ 8
225 .el .IP \f(CW@_\fR 8
226 .IX Xref "@_ @ARG"
227 .IX Item "@_"
228 .PD
229 Within a subroutine the array \f(CW@_\fR contains the parameters passed to
230 that subroutine. Inside a subroutine, \f(CW@_\fR is the default array for
231 the array operators \f(CW\*(C`pop\*(C'\fR and \f(CW\*(C`shift\*(C'\fR.
232 .Sp
233 See perlsub.
234 .ie n .IP $LIST_SEPARATOR 8
235 .el .IP \f(CW$LIST_SEPARATOR\fR 8
236 .IX Item "$LIST_SEPARATOR"
237 .PD 0
238 .IP "$""" 8
239 .IX Xref "$"" $LIST_SEPARATOR"
240 .PD
241 When an array or an array slice is interpolated into a double\-quoted
242 string or a similar context such as \f(CW\*(C`/.../\*(C'\fR, its elements are
243 separated by this value. Default is a space. For example, this:
244 .Sp
245 .Vb 1
246 \& print "The array is: @array\en";
247 .Ve
248 .Sp
249 is equivalent to this:
250 .Sp
251 .Vb 1
252 \& print "The array is: " . join($", @array) . "\en";
253 .Ve
254 .Sp
255 Mnemonic: works in double\-quoted context.
256 .ie n .IP $PROCESS_ID 8
257 .el .IP \f(CW$PROCESS_ID\fR 8
258 .IX Item "$PROCESS_ID"
259 .PD 0
260 .ie n .IP $PID 8
261 .el .IP \f(CW$PID\fR 8
262 .IX Item "$PID"
263 .IP $$ 8
264 .IX Xref "$$ $PID $PROCESS_ID"
265 .PD
266 The process number of the Perl running this script. Though you \fIcan\fR set
267 this variable, doing so is generally discouraged, although it can be
268 invaluable for some testing purposes. It will be reset automatically
269 across \f(CWfork()\fR calls.
270 .Sp
271 Note for Linux and Debian GNU/kFreeBSD users: Before Perl v5.16.0 perl
272 would emulate POSIX semantics on Linux systems using LinuxThreads, a
273 partial implementation of POSIX Threads that has since been superseded
274 by the Native POSIX Thread Library (NPTL).
275 .Sp
276 LinuxThreads is now obsolete on Linux, and caching \f(CWgetpid()\fR
277 like this made embedding perl unnecessarily complex (since you\*(Aqd have
278 to manually update the value of $$), so now \f(CW$$\fR and \f(CWgetppid()\fR
279 will always return the same values as the underlying C library.
280 .Sp
281 Debian GNU/kFreeBSD systems also used LinuxThreads up until and
282 including the 6.0 release, but after that moved to FreeBSD thread
283 semantics, which are POSIX\-like.
284 .Sp
285 To see if your system is affected by this discrepancy check if
286 \&\f(CW\*(C`getconf GNU_LIBPTHREAD_VERSION | grep \-q NPTL\*(C'\fR returns a false
287 value. NTPL threads preserve the POSIX semantics.
288 .Sp
289 Mnemonic: same as shells.
290 .ie n .IP $PROGRAM_NAME 8
291 .el .IP \f(CW$PROGRAM_NAME\fR 8
292 .IX Item "$PROGRAM_NAME"
293 .PD 0
294 .ie n .IP $0 8
295 .el .IP \f(CW$0\fR 8
296 .IX Xref "$0 $PROGRAM_NAME"
297 .IX Item "$0"
298 .PD
299 Contains the name of the program being executed.
300 .Sp
301 On some (but not all) operating systems assigning to \f(CW$0\fR modifies
302 the argument area that the \f(CW\*(C`ps\*(C'\fR program sees. On some platforms you
303 may have to use special \f(CW\*(C`ps\*(C'\fR options or a different \f(CW\*(C`ps\*(C'\fR to see the
304 changes. Modifying the \f(CW$0\fR is more useful as a way of indicating the
305 current program state than it is for hiding the program you\*(Aqre
306 running.
307 .Sp
308 Note that there are platform\-specific limitations on the maximum
309 length of \f(CW$0\fR. In the most extreme case it may be limited to the
310 space occupied by the original \f(CW$0\fR.
311 .Sp
312 In some platforms there may be arbitrary amount of padding, for
313 example space characters, after the modified name as shown by \f(CW\*(C`ps\*(C'\fR.
314 In some platforms this padding may extend all the way to the original
315 length of the argument area, no matter what you do (this is the case
316 for example with Linux 2.2).
317 .Sp
318 Note for BSD users: setting \f(CW$0\fR does not completely remove "perl"
319 from the \fBps\fR\|(1) output. For example, setting \f(CW$0\fR to \f(CW"foobar"\fR may
320 result in \f(CW"perl: foobar (perl)"\fR (whether both the \f(CW"perl: "\fR prefix
321 and the " (perl)" suffix are shown depends on your exact BSD variant
322 and version). This is an operating system feature, Perl cannot help it.
323 .Sp
324 In multithreaded scripts Perl coordinates the threads so that any
325 thread may modify its copy of the \f(CW$0\fR and the change becomes visible
326 to \fBps\fR\|(1) (assuming the operating system plays along). Note that
327 the view of \f(CW$0\fR the other threads have will not change since they
328 have their own copies of it.
329 .Sp
330 If the program has been given to perl via the switches \f(CW\*(C`\-e\*(C'\fR or \f(CW\*(C`\-E\*(C'\fR,
331 \&\f(CW$0\fR will contain the string \f(CW"\-e"\fR.
332 .Sp
333 On Linux as of perl v5.14.0 the legacy process name will be set with
334 \&\f(CWprctl(2)\fR, in addition to altering the POSIX name via \f(CW\*(C`argv[0]\*(C'\fR as
335 perl has done since version 4.000. Now system utilities that read the
336 legacy process name such as ps, top and killall will recognize the
337 name you set when assigning to \f(CW$0\fR. The string you supply will be
338 cut off at 16 bytes, this is a limitation imposed by Linux.
339 .Sp
340 Wide characters are invalid in \f(CW$0\fR values. For historical reasons,
341 though, Perl accepts them and encodes them to UTF\-8. When this
342 happens a wide\-character warning is triggered.
343 .Sp
344 Mnemonic: same as \fBsh\fR and \fBksh\fR.
345 .ie n .IP $REAL_GROUP_ID 8
346 .el .IP \f(CW$REAL_GROUP_ID\fR 8
347 .IX Item "$REAL_GROUP_ID"
348 .PD 0
349 .ie n .IP $GID 8
350 .el .IP \f(CW$GID\fR 8
351 .IX Item "$GID"
352 .IP $( 8
353 .IX Xref "$( $GID $REAL_GROUP_ID"
354 .PD
355 The real gid of this process. If you are on a machine that supports
356 membership in multiple groups simultaneously, gives a space separated
357 list of groups you are in. The first number is the one returned by
358 \&\f(CWgetgid()\fR, and the subsequent ones by \f(CWgetgroups()\fR, one of which may be
359 the same as the first number.
360 .Sp
361 However, a value assigned to \f(CW$(\fR must be a single number used to
362 set the real gid. So the value given by \f(CW$(\fR should \fInot\fR be assigned
363 back to \f(CW$(\fR without being forced numeric, such as by adding zero. Note
364 that this is different to the effective gid (\f(CW$)\fR) which does take a
365 list.
366 .Sp
367 You can change both the real gid and the effective gid at the same
368 time by using \f(CWPOSIX::setgid()\fR. Changes
369 to \f(CW$(\fR require a check to \f(CW$!\fR
370 to detect any possible errors after an attempted change.
371 .Sp
372 Mnemonic: parentheses are used to \fIgroup\fR things. The real gid is the
373 group you \fIleft\fR, if you\*(Aqre running setgid.
374 .ie n .IP $EFFECTIVE_GROUP_ID 8
375 .el .IP \f(CW$EFFECTIVE_GROUP_ID\fR 8
376 .IX Item "$EFFECTIVE_GROUP_ID"
377 .PD 0
378 .ie n .IP $EGID 8
379 .el .IP \f(CW$EGID\fR 8
380 .IX Item "$EGID"
381 .IP $) 8
382 .IX Xref "$) $EGID $EFFECTIVE_GROUP_ID"
383 .PD
384 The effective gid of this process. If you are on a machine that
385 supports membership in multiple groups simultaneously, gives a space
386 separated list of groups you are in. The first number is the one
387 returned by \f(CWgetegid()\fR, and the subsequent ones by \f(CWgetgroups()\fR,
388 one of which may be the same as the first number.
389 .Sp
390 Similarly, a value assigned to \f(CW$)\fR must also be a space\-separated
391 list of numbers. The first number sets the effective gid, and
392 the rest (if any) are passed to \f(CWsetgroups()\fR. To get the effect of an
393 empty list for \f(CWsetgroups()\fR, just repeat the new effective gid; that is,
394 to force an effective gid of 5 and an effectively empty \f(CWsetgroups()\fR
395 list, say \f(CW\*(C` $) = "5 5" \*(C'\fR.
396 .Sp
397 You can change both the effective gid and the real gid at the same
398 time by using \f(CWPOSIX::setgid()\fR (use only a single numeric argument).
399 Changes to \f(CW$)\fR require a check to \f(CW$!\fR to detect any possible errors
400 after an attempted change.
401 .Sp
402 \&\f(CW$<\fR, \f(CW$>\fR, \f(CW$(\fR and \f(CW$)\fR can be set only on
403 machines that support the corresponding \fIset[re][ug]\fR\f(BIid()\fR routine. \f(CW$(\fR
404 and \f(CW$)\fR can be swapped only on machines supporting \f(CWsetregid()\fR.
405 .Sp
406 Mnemonic: parentheses are used to \fIgroup\fR things. The effective gid
407 is the group that\*(Aqs \fIright\fR for you, if you\*(Aqre running setgid.
408 .ie n .IP $REAL_USER_ID 8
409 .el .IP \f(CW$REAL_USER_ID\fR 8
410 .IX Item "$REAL_USER_ID"
411 .PD 0
412 .ie n .IP $UID 8
413 .el .IP \f(CW$UID\fR 8
414 .IX Item "$UID"
415 .IP $< 8
416 .IX Xref "$< $UID $REAL_USER_ID"
417 .PD
418 The real uid of this process. You can change both the real uid and the
419 effective uid at the same time by using \f(CWPOSIX::setuid()\fR. Since
420 changes to \f(CW$<\fR require a system call, check \f(CW$!\fR after a change
421 attempt to detect any possible errors.
422 .Sp
423 Mnemonic: it\*(Aqs the uid you came \fIfrom\fR, if you\*(Aqre running setuid.
424 .ie n .IP $EFFECTIVE_USER_ID 8
425 .el .IP \f(CW$EFFECTIVE_USER_ID\fR 8
426 .IX Item "$EFFECTIVE_USER_ID"
427 .PD 0
428 .ie n .IP $EUID 8
429 .el .IP \f(CW$EUID\fR 8
430 .IX Item "$EUID"
431 .IP $> 8
432 .IX Xref "$> $EUID $EFFECTIVE_USER_ID"
433 .PD
434 The effective uid of this process. For example:
435 .Sp
436 .Vb 2
437 \& $< = $>; # set real to effective uid
438 \& ($<,$>) = ($>,$<); # swap real and effective uids
439 .Ve
440 .Sp
441 You can change both the effective uid and the real uid at the same
442 time by using \f(CWPOSIX::setuid()\fR. Changes to \f(CW$>\fR require a check
443 to \f(CW$!\fR to detect any possible errors after an attempted change.
444 .Sp
445 \&\f(CW$<\fR and \f(CW$>\fR can be swapped only on machines
446 supporting \f(CWsetreuid()\fR.
447 .Sp
448 Mnemonic: it\*(Aqs the uid you went \fIto\fR, if you\*(Aqre running setuid.
449 .ie n .IP $SUBSCRIPT_SEPARATOR 8
450 .el .IP \f(CW$SUBSCRIPT_SEPARATOR\fR 8
451 .IX Item "$SUBSCRIPT_SEPARATOR"
452 .PD 0
453 .ie n .IP $SUBSEP 8
454 .el .IP \f(CW$SUBSEP\fR 8
455 .IX Item "$SUBSEP"
456 .IP $; 8
457 .IX Xref "$; $SUBSEP SUBSCRIPT_SEPARATOR"
458 .PD
459 The subscript separator for multidimensional array emulation. If you
460 refer to a hash element as
461 .Sp
462 .Vb 1
463 \& $foo{$x,$y,$z}
464 .Ve
465 .Sp
466 it really means
467 .Sp
468 .Vb 1
469 \& $foo{join($;, $x, $y, $z)}
470 .Ve
471 .Sp
472 But don\*(Aqt put
473 .Sp
474 .Vb 1
475 \& @foo{$x,$y,$z} # a slice\-\-note the @
476 .Ve
477 .Sp
478 which means
479 .Sp
480 .Vb 1
481 \& ($foo{$x},$foo{$y},$foo{$z})
482 .Ve
483 .Sp
484 Default is "\e034", the same as SUBSEP in \fBawk\fR. If your keys contain
485 binary data there might not be any safe value for \f(CW$;\fR.
486 .Sp
487 Consider using "real" multidimensional arrays as described
488 in perllol.
489 .Sp
490 Mnemonic: comma (the syntactic subscript separator) is a semi\-semicolon.
491 .ie n .IP $a 8
492 .el .IP \f(CW$a\fR 8
493 .IX Item "$a"
494 .PD 0
495 .ie n .IP $b 8
496 .el .IP \f(CW$b\fR 8
497 .IX Xref "$a $b"
498 .IX Item "$b"
499 .PD
500 Special package variables when using \f(CWsort()\fR, see "sort" in perlfunc.
501 Because of this specialness \f(CW$a\fR and \f(CW$b\fR don\*(Aqt need to be declared
502 (using \f(CW\*(C`use vars\*(C'\fR, or \f(CWour()\fR) even when using the \f(CW\*(C`strict \*(Aqvars\*(Aq\*(C'\fR
503 pragma. Don\*(Aqt lexicalize them with \f(CW\*(C`my $a\*(C'\fR or \f(CW\*(C`my $b\*(C'\fR if you want to
504 be able to use them in the \f(CWsort()\fR comparison block or function.
505 .ie n .IP %ENV 8
506 .el .IP \f(CW%ENV\fR 8
507 .IX Xref "%ENV"
508 .IX Item "%ENV"
509 The hash \f(CW%ENV\fR contains your current environment. Setting a
510 value in \f(CW\*(C`ENV\*(C'\fR changes the environment for any child processes
511 you subsequently \f(CWfork()\fR off.
512 .Sp
513 As of v5.18.0, both keys and values stored in \f(CW%ENV\fR are stringified.
514 .Sp
515 .Vb 7
516 \& my $foo = 1;
517 \& $ENV{\*(Aqbar\*(Aq} = \e$foo;
518 \& if( ref $ENV{\*(Aqbar\*(Aq} ) {
519 \& say "Pre 5.18.0 Behaviour";
520 \& } else {
521 \& say "Post 5.18.0 Behaviour";
522 \& }
523 .Ve
524 .Sp
525 Previously, only child processes received stringified values:
526 .Sp
527 .Vb 2
528 \& my $foo = 1;
529 \& $ENV{\*(Aqbar\*(Aq} = \e$foo;
530 \&
531 \& # Always printed \*(Aqnon ref\*(Aq
532 \& system($^X, \*(Aq\-e\*(Aq,
533 \& q/print ( ref $ENV{\*(Aqbar\*(Aq} ? \*(Aqref\*(Aq : \*(Aqnon ref\*(Aq ) /);
534 .Ve
535 .Sp
536 This happens because you can\*(Aqt really share arbitrary data structures with
537 foreign processes.
538 .ie n .IP $OLD_PERL_VERSION 8
539 .el .IP \f(CW$OLD_PERL_VERSION\fR 8
540 .IX Item "$OLD_PERL_VERSION"
541 .PD 0
542 .IP $] 8
543 .IX Xref "$] $OLD_PERL_VERSION"
544 .PD
545 The revision, version, and subversion of the Perl interpreter, represented
546 as a decimal of the form 5.XXXYYY, where XXX is the version / 1e3 and YYY
547 is the subversion / 1e6. For example, Perl v5.10.1 would be "5.010001".
548 .Sp
549 This variable can be used to determine whether the Perl interpreter
550 executing a script is in the right range of versions:
551 .Sp
552 .Vb 1
553 \& warn "No PerlIO!\en" if "$]" < 5.008;
554 .Ve
555 .Sp
556 When comparing \f(CW$]\fR, numeric comparison operators should be used, but the
557 variable should be stringified first to avoid issues where its original
558 numeric value is inaccurate.
559 .Sp
560 See also the documentation of \f(CW\*(C`use VERSION\*(C'\fR and
561 \&\f(CW\*(C`require VERSION\*(C'\fR for a convenient way to fail if the running Perl
562 interpreter is too old.
563 .Sp
564 See "$^V" for a representation of the Perl version as a version
565 object, which allows more flexible string comparisons.
566 .Sp
567 The main advantage of \f(CW$]\fR over \f(CW$^V\fR is that it works the same on any
568 version of Perl. The disadvantages are that it can\*(Aqt easily be compared
569 to versions in other formats (e.g. literal v\-strings, "v1.2.3" or
570 version objects) and numeric comparisons are subject to the binary
571 floating point representation; it\*(Aqs good for numeric literal version
572 checks and bad for comparing to a variable that hasn\*(Aqt been
573 sanity\-checked.
574 .Sp
575 The \f(CW$OLD_PERL_VERSION\fR form was added in Perl v5.20.0 for historical
576 reasons but its use is discouraged. (If your reason to use \f(CW$]\fR is to
577 run code on old perls then referring to it as \f(CW$OLD_PERL_VERSION\fR would
578 be self\-defeating.)
579 .Sp
580 Mnemonic: Is this version of perl in the right bracket?
581 .ie n .IP $SYSTEM_FD_MAX 8
582 .el .IP \f(CW$SYSTEM_FD_MAX\fR 8
583 .IX Item "$SYSTEM_FD_MAX"
584 .PD 0
585 .IP $^F 8
586 .IX Xref "$^F $SYSTEM_FD_MAX"
587 .IX Item "$^F"
588 .PD
589 The maximum system file descriptor, ordinarily 2. System file
590 descriptors are passed to \f(CWexec()\fRed processes, while higher file
591 descriptors are not. Also, during an
592 \&\f(CWopen()\fR, system file descriptors are
593 preserved even if the \f(CWopen()\fR fails (ordinary file descriptors are
594 closed before the \f(CWopen()\fR is attempted). The close\-on\-exec
595 status of a file descriptor will be decided according to the value of
596 \&\f(CW$^F\fR when the corresponding file, pipe, or socket was opened, not the
597 time of the \f(CWexec()\fR.
598 .ie n .IP @F 8
599 .el .IP \f(CW@F\fR 8
600 .IX Xref "@F"
601 .IX Item "@F"
602 The array \f(CW@F\fR contains the fields of each line read in when autosplit
603 mode is turned on. See perlrun for the \fB\-a\fR switch. This
604 array is package\-specific, and must be declared or given a full package
605 name if not in package main when running under \f(CW\*(C`strict \*(Aqvars\*(Aq\*(C'\fR.
606 .ie n .IP @INC 8
607 .el .IP \f(CW@INC\fR 8
608 .IX Xref "@INC"
609 .IX Item "@INC"
610 The array \f(CW@INC\fR contains the list of places that the \f(CW\*(C`do EXPR\*(C'\fR,
611 \&\f(CW\*(C`require\*(C'\fR, or \f(CW\*(C`use\*(C'\fR constructs look for their library files. It
612 initially consists of the arguments to any \fB\-I\fR command\-line
613 switches, followed by the default Perl library, probably
614 \&\fI/usr/local/lib/perl\fR.
615 Prior to Perl 5.26, \f(CW\*(C`.\*(C'\fR \-which represents the current directory, was included
616 in \f(CW@INC\fR; it has been removed. This change in behavior is documented
617 in \f(CW\*(C`PERL_USE_UNSAFE_INC\*(C'\fR and it is
618 not recommended that \f(CW\*(C`.\*(C'\fR be re\-added to \f(CW@INC\fR.
619 If you need to modify \f(CW@INC\fR at runtime, you should use the \f(CW\*(C`use lib\*(C'\fR pragma
620 to get the machine\-dependent library properly loaded as well:
621 .Sp
622 .Vb 2
623 \& use lib \*(Aq/mypath/libdir/\*(Aq;
624 \& use SomeMod;
625 .Ve
626 .Sp
627 You can also insert hooks into the file inclusion system by putting Perl
628 code directly into \f(CW@INC\fR. Those hooks may be subroutine references,
629 array references or blessed objects. See "require" in perlfunc for details.
630 .ie n .IP %INC 8
631 .el .IP \f(CW%INC\fR 8
632 .IX Xref "%INC"
633 .IX Item "%INC"
634 The hash \f(CW%INC\fR contains entries for each filename included via the
635 \&\f(CW\*(C`do\*(C'\fR, \f(CW\*(C`require\*(C'\fR, or \f(CW\*(C`use\*(C'\fR operators. The key is the filename
636 you specified (with module names converted to pathnames), and the
637 value is the location of the file found. The \f(CW\*(C`require\*(C'\fR
638 operator uses this hash to determine whether a particular file has
639 already been included.
640 .Sp
641 If the file was loaded via a hook (e.g. a subroutine reference, see
642 "require" in perlfunc for a description of these hooks), this hook is
643 by default inserted into \f(CW%INC\fR in place of a filename. Note, however,
644 that the hook may have set the \f(CW%INC\fR entry by itself to provide some more
645 specific info.
646 .ie n .IP $INC 8
647 .el .IP \f(CW$INC\fR 8
648 .IX Xref "$INC"
649 .IX Item "$INC"
650 As of 5.37.7 when an \f(CW@INC\fR hook is executed the index of the \f(CW@INC\fR
651 array that holds the hook will be localized into the \f(CW$INC\fR variable.
652 When the hook returns the integer successor of its value will be used to
653 determine the next index in \f(CW@INC\fR that will be checked, thus if it is
654 set to \-1 (or \f(CW\*(C`undef\*(C'\fR) the traversal over the \f(CW@INC\fR array will be
655 restarted from its beginning.
656 .Sp
657 Normally traversal through the \f(CW@INC\fR array is from beginning to end
658 (\f(CW\*(C`0 .. $#INC\*(C'\fR), and if the \f(CW@INC\fR array is modified by the hook the
659 iterator may be left in a state where newly added entries are skipped.
660 Changing this value allows an \f(CW@INC\fR hook to rewrite the \f(CW@INC\fR array
661 and tell Perl where to continue afterwards. See "require" in perlfunc for
662 details on \f(CW@INC\fR hooks.
663 .ie n .IP $INPLACE_EDIT 8
664 .el .IP \f(CW$INPLACE_EDIT\fR 8
665 .IX Item "$INPLACE_EDIT"
666 .PD 0
667 .IP $^I 8
668 .IX Xref "$^I $INPLACE_EDIT"
669 .IX Item "$^I"
670 .PD
671 The current value of the inplace\-edit extension. Use \f(CW\*(C`undef\*(C'\fR to disable
672 inplace editing.
673 .Sp
674 Mnemonic: value of \fB\-i\fR switch.
675 .ie n .IP @ISA 8
676 .el .IP \f(CW@ISA\fR 8
677 .IX Xref "@ISA"
678 .IX Item "@ISA"
679 Each package contains a special array called \f(CW@ISA\fR which contains a list
680 of that class\*(Aqs parent classes, if any. This array is simply a list of
681 scalars, each of which is a string that corresponds to a package name. The
682 array is examined when Perl does method resolution, which is covered in
683 perlobj.
684 .Sp
685 To load packages while adding them to \f(CW@ISA\fR, see the parent pragma. The
686 discouraged base pragma does this as well, but should not be used except
687 when compatibility with the discouraged fields pragma is required.
688 .IP $^M 8
689 .IX Xref "$^M"
690 .IX Item "$^M"
691 By default, running out of memory is an untrappable, fatal error.
692 However, if suitably built, Perl can use the contents of \f(CW$^M\fR
693 as an emergency memory pool after \f(CWdie()\fRing. Suppose that your Perl
694 were compiled with \f(CW\*(C`\-DPERL_EMERGENCY_SBRK\*(C'\fR and used Perl\*(Aqs malloc.
695 Then
696 .Sp
697 .Vb 1
698 \& $^M = \*(Aqa\*(Aq x (1 << 16);
699 .Ve
700 .Sp
701 would allocate a 64K buffer for use in an emergency. See the
702 \&\fIINSTALL\fR file in the Perl distribution for information on how to
703 add custom C compilation flags when compiling perl. To discourage casual
704 use of this advanced feature, there is no English long name for
705 this variable.
706 .Sp
707 This variable was added in Perl 5.004.
708 .IP ${^MAX_NESTED_EVAL_BEGIN_BLOCKS} 8
709 .IX Item "${^MAX_NESTED_EVAL_BEGIN_BLOCKS}"
710 This variable determines the maximum number \f(CW\*(C`eval EXPR\*(C'\fR/\f(CW\*(C`BEGIN\*(C'\fR or
711 \&\f(CW\*(C`require\*(C'\fR/\f(CW\*(C`BEGIN\*(C'\fR block nesting that is allowed. This means it also
712 controls the maximum nesting of \f(CW\*(C`use\*(C'\fR statements as well.
713 .Sp
714 The default of 1000 should be sufficiently large for normal working
715 purposes, and if you must raise it then you should be conservative
716 with your choice or you may encounter segfaults from exhaustion of
717 the C stack. It seems unlikely that real code has a use depth above
718 1000, but we have left this configurable just in case.
719 .Sp
720 When set to \f(CW0\fR then \f(CW\*(C`BEGIN\*(C'\fR blocks inside of \f(CW\*(C`eval EXPR\*(C'\fR or
721 \&\f(CW\*(C`require EXPR\*(C'\fR are forbidden entirely and will trigger an exception
722 which will terminate the compilation and in the case of \f(CW\*(C`require\*(C'\fR
723 will throw an exception, or in the case of \f(CW\*(C`eval\*(C'\fR return the error in
724 \&\f(CW$@\fR as usual.
725 .Sp
726 Consider the code
727 .Sp
728 .Vb 1
729 \& perl \-le\*(Aqsub f { eval "BEGIN { f() }"; } f()\*(Aq
730 .Ve
731 .Sp
732 each invocation of \f(CWf()\fR will consume considerable C stack, and this
733 variable is used to cause code like this to die instead of exhausting
734 the C stack and triggering a segfault. Needless to say code like this is
735 unusual, it is unlikely you will actually need to raise the setting.
736 However it may be useful to set it to 0 for a limited time period to
737 prevent BEGIN{} blocks from being executed during an \f(CW\*(C`eval EXPR\*(C'\fR.
738 .Sp
739 Note that setting this to 1 would NOT affect code like this:
740 .Sp
741 .Vb 1
742 \& BEGIN { $n += 1; BEGIN { $n += 2; BEGIN { $n += 4 } } }
743 .Ve
744 .Sp
745 The reason is that BEGIN blocks are executed immediately after they are
746 completed, thus the innermost will execute before the ones which contain
747 it have even finished compiling, and the depth will not go above 1. In
748 fact the above code is equivalent to
749 .Sp
750 .Vb 3
751 \& BEGIN { $n+=4 }
752 \& BEGIN { $n+=2 }
753 \& BEGIN { $n+=1 }
754 .Ve
755 .Sp
756 which makes it obvious why a ${^MAX_EVAL_BEGIN_DEPTH} of 1 would not
757 block this code.
758 .Sp
759 Only \f(CW\*(C`BEGIN\*(C'\fR\*(Aqs executed inside of an \f(CW\*(C`eval\*(C'\fR or \f(CW\*(C`require\*(C'\fR (possibly via
760 \&\f(CW\*(C`use\*(C'\fR) are affected.
761 .ie n .IP $OSNAME 8
762 .el .IP \f(CW$OSNAME\fR 8
763 .IX Item "$OSNAME"
764 .PD 0
765 .IP $^O 8
766 .IX Xref "$^O $OSNAME"
767 .IX Item "$^O"
768 .PD
769 The name of the operating system under which this copy of Perl was
770 built, as determined during the configuration process. For examples
771 see "PLATFORMS" in perlport.
772 .Sp
773 The value is identical to \f(CW$Config{\*(Aqosname\*(Aq}\fR. See also Config
774 and the \fB\-V\fR command\-line switch documented in perlrun.
775 .Sp
776 In Windows platforms, \f(CW$^O\fR is not very helpful: since it is always
777 \&\f(CW\*(C`MSWin32\*(C'\fR, it doesn\*(Aqt tell the difference between
778 95/98/ME/NT/2000/XP/CE/.NET. Use \f(CWWin32::GetOSName()\fR or
779 \&\fBWin32::GetOSVersion()\fR (see Win32 and perlport) to distinguish
780 between the variants.
781 .Sp
782 This variable was added in Perl 5.003.
783 .ie n .IP %SIG 8
784 .el .IP \f(CW%SIG\fR 8
785 .IX Xref "%SIG"
786 .IX Item "%SIG"
787 The hash \f(CW%SIG\fR contains signal handlers for signals. For example:
788 .Sp
789 .Vb 6
790 \& sub handler { # 1st argument is signal name
791 \& my($sig) = @_;
792 \& print "Caught a SIG$sig\-\-shutting down\en";
793 \& close(LOG);
794 \& exit(0);
795 \& }
796 \&
797 \& $SIG{\*(AqINT\*(Aq} = \e&handler;
798 \& $SIG{\*(AqQUIT\*(Aq} = \e&handler;
799 \& ...
800 \& $SIG{\*(AqINT\*(Aq} = \*(AqDEFAULT\*(Aq; # restore default action
801 \& $SIG{\*(AqQUIT\*(Aq} = \*(AqIGNORE\*(Aq; # ignore SIGQUIT
802 .Ve
803 .Sp
804 Using a value of \f(CW\*(AqIGNORE\*(Aq\fR usually has the effect of ignoring the
805 signal, except for the \f(CW\*(C`CHLD\*(C'\fR signal. See perlipc for more about
806 this special case. Using an empty string or \f(CW\*(C`undef\*(C'\fR as the value has
807 the same effect as \f(CW\*(AqDEFAULT\*(Aq\fR.
808 .Sp
809 Here are some other examples:
810 .Sp
811 .Vb 7
812 \& $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not
813 \& # recommended)
814 \& $SIG{"PIPE"} = \e&Plumber; # just fine; assume current
815 \& # Plumber
816 \& $SIG{"PIPE"} = *Plumber; # somewhat esoteric
817 \& $SIG{"PIPE"} = Plumber(); # oops, what did Plumber()
818 \& # return??
819 .Ve
820 .Sp
821 Be sure not to use a bareword as the name of a signal handler,
822 lest you inadvertently call it.
823 .Sp
824 Using a string that doesn\*(Aqt correspond to any existing function or a
825 glob that doesn\*(Aqt contain a code slot is equivalent to \f(CW\*(AqIGNORE\*(Aq\fR,
826 but a warning is emitted when the handler is being called (the warning
827 is not emitted for the internal hooks described below).
828 .Sp
829 If your system has the \f(CWsigaction()\fR function then signal handlers
830 are installed using it. This means you get reliable signal handling.
831 .Sp
832 The default delivery policy of signals changed in Perl v5.8.0 from
833 immediate (also known as "unsafe") to deferred, also known as "safe
834 signals". See perlipc for more information.
835 .Sp
836 Certain internal hooks can be also set using the \f(CW%SIG\fR hash. The
837 routine indicated by \f(CW$SIG{_\|_WARN_\|_}\fR is called when a warning
838 message is about to be printed. The warning message is passed as the
839 first argument. The presence of a \f(CW\*(C`_\|_WARN_\|_\*(C'\fR hook causes the
840 ordinary printing of warnings to \f(CW\*(C`STDERR\*(C'\fR to be suppressed. You can
841 use this to save warnings in a variable, or turn warnings into fatal
842 errors, like this:
843 .Sp
844 .Vb 2
845 \& local $SIG{_\|_WARN_\|_} = sub { die $_[0] };
846 \& eval $proggie;
847 .Ve
848 .Sp
849 As the \f(CW\*(AqIGNORE\*(Aq\fR hook is not supported by \f(CW\*(C`_\|_WARN_\|_\*(C'\fR, its effect is
850 the same as using \f(CW\*(AqDEFAULT\*(Aq\fR. You can disable warnings using the
851 empty subroutine:
852 .Sp
853 .Vb 1
854 \& local $SIG{_\|_WARN_\|_} = sub {};
855 .Ve
856 .Sp
857 The routine indicated by \f(CW$SIG{_\|_DIE_\|_}\fR is called when a fatal
858 exception is about to be thrown. The error message is passed as the
859 first argument. When a \f(CW\*(C`_\|_DIE_\|_\*(C'\fR hook routine returns, the exception
860 processing continues as it would have in the absence of the hook, unless
861 the hook routine itself throws an exception. The \f(CW\*(C`_\|_DIE_\|_\*(C'\fR handler is
862 explicitly disabled during the call, so that you can die from a
863 \&\f(CW\*(C`_\|_DIE_\|_\*(C'\fR handler. Similarly for \f(CW\*(C`_\|_WARN_\|_\*(C'\fR.
864 .Sp
865 The \f(CW$SIG{_\|_DIE_\|_}\fR hook is called even inside an \f(CWeval()\fR. It was
866 never intended to happen this way, but an implementation glitch made
867 this possible. This used to be deprecated, as it allowed strange action
868 at a distance like rewriting a pending exception in \f(CW$@\fR. Plans to
869 rectify this have been scrapped, as users found that rewriting a
870 pending exception is actually a useful feature, and not a bug.
871 .Sp
872 The \f(CW$SIG{_\|_DIE_\|_}\fR hook doesn\*(Aqt support \f(CW\*(AqIGNORE\*(Aq\fR; it has the same
873 effect as \f(CW\*(AqDEFAULT\*(Aq\fR.
874 .Sp
875 \&\f(CW\*(C`_\|_DIE_\|_\*(C'\fR/\f(CW\*(C`_\|_WARN_\|_\*(C'\fR handlers are very special in one respect: they
876 may be called to report (probable) errors found by the parser. In such
877 a case the parser may be in inconsistent state, so any attempt to
878 evaluate Perl code from such a handler will probably result in a
879 segfault. This means that warnings or errors that result from parsing
880 Perl should be used with extreme caution, like this:
881 .Sp
882 .Vb 5
883 \& require Carp if defined $^S;
884 \& Carp::confess("Something wrong") if defined &Carp::confess;
885 \& die "Something wrong, but could not load Carp to give "
886 \& . "backtrace...\en\et"
887 \& . "To see backtrace try starting Perl with \-MCarp switch";
888 .Ve
889 .Sp
890 Here the first line will load \f(CW\*(C`Carp\*(C'\fR \fIunless\fR it is the parser who
891 called the handler. The second line will print backtrace and die if
892 \&\f(CW\*(C`Carp\*(C'\fR was available. The third line will be executed only if \f(CW\*(C`Carp\*(C'\fR was
893 not available.
894 .Sp
895 Having to even think about the \f(CW$^S\fR variable in your exception
896 handlers is simply wrong. \f(CW$SIG{_\|_DIE_\|_}\fR as currently implemented
897 invites grievous and difficult to track down errors. Avoid it
898 and use an \f(CW\*(C`END{}\*(C'\fR or CORE::GLOBAL::die override instead.
899 .Sp
900 See "die" in perlfunc, "warn" in perlfunc, "eval" in perlfunc, and
901 warnings for additional information.
902 .IP %{^HOOK} 8
903 .IX Xref "%{^HOOK}"
904 .IX Item "%{^HOOK}"
905 This hash contains coderefs which are called when various perl keywords
906 which are hard or impossible to wrap are called. The keys of this hash
907 are named after the keyword that is being hooked, followed by two
908 underbars and then a phase term; either "before" or "after".
909 .Sp
910 Perl will throw an error if you attempt to modify a key which is not
911 documented to exist, or if you attempt to store anything other than a
912 code reference or undef in the hash. If you wish to use an object to
913 implement a hook you can use currying to embed the object into an
914 anonymous code reference.
915 .Sp
916 Currently there is only one keyword which can be hooked, \f(CW\*(C`require\*(C'\fR, but
917 it is expected that in future releases there will be additional keywords
918 with hook support.
919 .RS 8
920 .IP require_\|_before 4
921 .IX Item "require__before"
922 The routine indicated by \f(CW\*(C`${^HOOK}{require_\|_before}\*(C'\fR is called by
923 \&\f(CW\*(C`require\*(C'\fR \fBbefore\fR it checks \f(CW%INC\fR, looks up \f(CW@INC\fR, calls INC
924 hooks, or compiles any code. It is called with a single argument, the
925 filename for the item being required (package names are converted to
926 paths). It may alter this filename to change what file is loaded. If
927 the hook dies during execution then it will block the require from executing.
928 .Sp
929 In order to make it easy to perform an action with shared state both
930 before and after the require keyword was executed the \f(CW\*(C`require_\|_before\*(C'\fR
931 hook may return a "post\-action" coderef which will in turn be executed when
932 the \f(CW\*(C`require\*(C'\fR completes. This coderef will be executed regardless as to
933 whether the require completed successfully or threw an exception. It will
934 be called with the filename that was required. You can check \f(CW%INC\fR to
935 determine if the require was successful. Any other return from the
936 \&\f(CW\*(C`require_\|_before\*(C'\fR hook will be silently ignored.
937 .Sp
938 \&\f(CW\*(C`require_\|_before\*(C'\fR hooks are called in FIFO order, and if the hook
939 returns a code reference those code references will be called in FILO
940 order. In other words if A requires B requires C, then
941 \&\f(CW\*(C`require_\|_before\*(C'\fR will be called first for A, then B and then C, and
942 the post\-action code reference will be executed first for C, then B and
943 then finally A.
944 .Sp
945 Well behaved code should ensure that when setting up a
946 \&\f(CW\*(C`require_\|_before\*(C'\fR hook that any prior installed hook will be called,
947 and that their return value, if a code reference, will be called as
948 well. See "require" in perlfunc for an example implementation.
949 .IP require_\|_after 4
950 .IX Item "require__after"
951 The routine indicated by \f(CW\*(C`${^HOOK}{require_\|_after}\*(C'\fR is called by
952 \&\f(CW\*(C`require\*(C'\fR \fBafter\fR the require completes. It is called with a single
953 argument, the filename for the item being required (package names are
954 converted to paths). It is executed when the \f(CW\*(C`require\*(C'\fR completes,
955 either via exception or via completion of the require statement, and you
956 can check \f(CW%INC\fR to determine if the require was successful.
957 .Sp
958 The \f(CW\*(C`require_\|_after\*(C'\fR hook is called for each required file in FILO
959 order. In other words if A requires B requires C, then \f(CW\*(C`require_\|_after\*(C'\fR
960 will be called first for C, then B and then A.
961 .RE
962 .RS 8
963 .RE
964 .ie n .IP $BASETIME 8
965 .el .IP \f(CW$BASETIME\fR 8
966 .IX Item "$BASETIME"
967 .PD 0
968 .IP $^T 8
969 .IX Xref "$^T $BASETIME"
970 .IX Item "$^T"
971 .PD
972 The time at which the program began running, in seconds since the
973 epoch (beginning of 1970). The values returned by the \fB\-M\fR, \fB\-A\fR,
974 and \fB\-C\fR filetests are based on this value.
975 .ie n .IP $PERL_VERSION 8
976 .el .IP \f(CW$PERL_VERSION\fR 8
977 .IX Item "$PERL_VERSION"
978 .PD 0
979 .IP $^V 8
980 .IX Xref "$^V $PERL_VERSION"
981 .IX Item "$^V"
982 .PD
983 The revision, version, and subversion of the Perl interpreter,
984 represented as a version object.
985 .Sp
986 This variable first appeared in perl v5.6.0; earlier versions of perl
987 will see an undefined value. Before perl v5.10.0 \f(CW$^V\fR was represented
988 as a v\-string rather than a version object.
989 .Sp
990 \&\f(CW$^V\fR can be used to determine whether the Perl interpreter executing
991 a script is in the right range of versions. For example:
992 .Sp
993 .Vb 1
994 \& warn "Hashes not randomized!\en" if !$^V or $^V lt v5.8.1
995 .Ve
996 .Sp
997 While version objects overload stringification, to portably convert
998 \&\f(CW$^V\fR into its string representation, use \f(CWsprintf()\fR\*(Aqs \f(CW"%vd"\fR
999 conversion, which works for both v\-strings or version objects:
1000 .Sp
1001 .Vb 1
1002 \& printf "version is v%vd\en", $^V; # Perl\*(Aqs version
1003 .Ve
1004 .Sp
1005 See the documentation of \f(CW\*(C`use VERSION\*(C'\fR and \f(CW\*(C`require VERSION\*(C'\fR
1006 for a convenient way to fail if the running Perl interpreter is too old.
1007 .Sp
1008 See also \f(CW"$]"\fR for a decimal representation of the Perl version.
1009 .Sp
1010 The main advantage of \f(CW$^V\fR over \f(CW$]\fR is that, for Perl v5.10.0 or
1011 later, it overloads operators, allowing easy comparison against other
1012 version representations (e.g. decimal, literal v\-string, "v1.2.3", or
1013 objects). The disadvantage is that prior to v5.10.0, it was only a
1014 literal v\-string, which can\*(Aqt be easily printed or compared, whereas
1015 the behavior of \f(CW$]\fR is unchanged on all versions of Perl.
1016 .Sp
1017 Mnemonic: use ^V for a version object.
1018 .ie n .IP $EXECUTABLE_NAME 8
1019 .el .IP \f(CW$EXECUTABLE_NAME\fR 8
1020 .IX Item "$EXECUTABLE_NAME"
1021 .PD 0
1022 .IP $^X 8
1023 .IX Xref "$^X $EXECUTABLE_NAME"
1024 .IX Item "$^X"
1025 .PD
1026 The name used to execute the current copy of Perl, from C\*(Aqs
1027 \&\f(CW\*(C`argv[0]\*(C'\fR or (where supported) \fI/proc/self/exe\fR.
1028 .Sp
1029 Depending on the host operating system, the value of \f(CW$^X\fR may be
1030 a relative or absolute pathname of the perl program file, or may
1031 be the string used to invoke perl but not the pathname of the
1032 perl program file. Also, most operating systems permit invoking
1033 programs that are not in the PATH environment variable, so there
1034 is no guarantee that the value of \f(CW$^X\fR is in PATH. For VMS, the
1035 value may or may not include a version number.
1036 .Sp
1037 You usually can use the value of \f(CW$^X\fR to re\-invoke an independent
1038 copy of the same perl that is currently running, e.g.,
1039 .Sp
1040 .Vb 1
1041 \& @first_run = \`$^X \-le "print int rand 100 for 1..100"\`;
1042 .Ve
1043 .Sp
1044 But recall that not all operating systems support forking or
1045 capturing of the output of commands, so this complex statement
1046 may not be portable.
1047 .Sp
1048 It is not safe to use the value of \f(CW$^X\fR as a path name of a file,
1049 as some operating systems that have a mandatory suffix on
1050 executable files do not require use of the suffix when invoking
1051 a command. To convert the value of \f(CW$^X\fR to a path name, use the
1052 following statements:
1053 .Sp
1054 .Vb 7
1055 \& # Build up a set of file names (not command names).
1056 \& use Config;
1057 \& my $this_perl = $^X;
1058 \& if ($^O ne \*(AqVMS\*(Aq) {
1059 \& $this_perl .= $Config{_exe}
1060 \& unless $this_perl =~ m/$Config{_exe}$/i;
1061 \& }
1062 .Ve
1063 .Sp
1064 Because many operating systems permit anyone with read access to
1065 the Perl program file to make a copy of it, patch the copy, and
1066 then execute the copy, the security\-conscious Perl programmer
1067 should take care to invoke the installed copy of perl, not the
1068 copy referenced by \f(CW$^X\fR. The following statements accomplish
1069 this goal, and produce a pathname that can be invoked as a
1070 command or referenced as a file.
1071 .Sp
1072 .Vb 6
1073 \& use Config;
1074 \& my $secure_perl_path = $Config{perlpath};
1075 \& if ($^O ne \*(AqVMS\*(Aq) {
1076 \& $secure_perl_path .= $Config{_exe}
1077 \& unless $secure_perl_path =~ m/$Config{_exe}$/i;
1078 \& }
1079 .Ve
1080 .SS "Variables related to regular expressions"
1081 .IX Subsection "Variables related to regular expressions"
1082 Most of the special variables related to regular expressions are side
1083 effects. Perl sets these variables when it has completed a match
1084 successfully, so you should check the match result before using them.
1085 For instance:
1086 .PP
1087 .Vb 3
1088 \& if( /P(A)TT(ER)N/ ) {
1089 \& print "I found $1 and $2\en";
1090 \& }
1091 .Ve
1092 .PP
1093 These variables are read\-only and behave similarly to a dynamically
1094 scoped variable, with only a few exceptions which are explicitly
1095 documented as behaving otherwise. See the following section for more
1096 details.
1097 .PP
1098 \fIScoping Rules of Regex Variables\fR
1099 .IX Xref "Scoping Rules of Regex Variables"
1100 .IX Subsection "Scoping Rules of Regex Variables"
1101 .PP
1102 Regular expression variables allow the programmer to access the state of
1103 the most recent \fIsuccessful\fR regex match in the current dynamic scope.
1104 .PP
1105 The variables themselves are global and unscoped, but the data they
1106 access is scoped similarly to dynamically scoped variables, in that
1107 every successful match behaves as though it localizes a global state
1108 object to the current block or file scope.
1109 (See "Compound Statements" in perlsyn for more details on dynamic
1110 scoping and the \f(CW\*(C`local\*(C'\fR keyword.)
1111 .PP
1112 A \fIsuccessful match\fR includes any successful match performed by the
1113 search and replace operator \f(CW\*(C`s///\*(C'\fR as well as those performed by the
1114 \&\f(CW\*(C`m//\*(C'\fR operator.
1115 .PP
1116 Consider the following code:
1117 .PP
1118 .Vb 7
1119 \& my @state;
1120 \& sub matchit {
1121 \& push @state, $1; # pushes "baz"
1122 \& my $str = shift;
1123 \& $str =~ /(zat)/; # matches "zat"
1124 \& push @state, $1; # pushes "zat"
1125 \& }
1126 \&
1127 \& {
1128 \& $str = "foo bar baz blorp zat";
1129 \& $str =~ /(foo)/; # matches "foo"
1130 \& push @state, $1; # pushes "foo"
1131 \& {
1132 \& $str =~ /(pizza)/; # does NOT match
1133 \& push @state, $1; # pushes "foo"
1134 \& $str =~ /(bar)/; # matches "bar"
1135 \& push @state, $1; # pushes "bar"
1136 \& $str =~ /(baz)/; # matches "baz"
1137 \& matchit($str); # see above
1138 \& push @state, $1; # pushes "baz"
1139 \& }
1140 \& $str =~ s/noodles/rice/; # does NOT match
1141 \& push @state, $1; # pushes "foo"
1142 \& $str =~ s/(blorp)/zwoop/; # matches "blorp"
1143 \& push @state, $1; # pushes "blorp"
1144 \& }
1145 \& # the following prints "foo, foo, bar, baz, zat, baz, foo, blorp"
1146 \& print join ",", @state;
1147 .Ve
1148 .PP
1149 Notice that each successful match in the exact same scope overrides the
1150 match context of the previous successful match, but that unsuccessful
1151 matches do not. Also note that in an inner nested scope the previous
1152 state from an outer dynamic scope persists until it has been overridden
1153 by another successful match, but that when the inner nested scope exits
1154 whatever match context was in effect before the inner successful match
1155 is restored when the scope concludes.
1156 .PP
1157 It is a known issue that \f(CW\*(C`goto LABEL\*(C'\fR may interact poorly with the
1158 dynamically scoped match context. This may not be fixable, and is
1159 considered to be one of many good reasons to avoid \f(CW\*(C`goto LABEL\*(C'\fR.
1160 .PP
1161 \fIPerformance issues\fR
1162 .IX Subsection "Performance issues"
1163 .PP
1164 Traditionally in Perl, any use of any of the three variables \f(CW\*(C`$\`\*(C'\fR, \f(CW$&\fR
1165 or \f(CW\*(C`$\*(Aq\*(C'\fR (or their \f(CW\*(C`use English\*(C'\fR equivalents) anywhere in the code, caused
1166 all subsequent successful pattern matches to make a copy of the matched
1167 string, in case the code might subsequently access one of those variables.
1168 This imposed a considerable performance penalty across the whole program,
1169 so generally the use of these variables has been discouraged.
1170 .PP
1171 In Perl 5.6.0 the \f(CW\*(C`@\-\*(C'\fR and \f(CW\*(C`@+\*(C'\fR dynamic arrays were introduced that
1172 supply the indices of successful matches. So you could for example do
1173 this:
1174 .PP
1175 .Vb 1
1176 \& $str =~ /pattern/;
1177 \&
1178 \& print $\`, $&, $\*(Aq; # bad: performance hit
1179 \&
1180 \& print # good: no performance hit
1181 \& substr($str, 0, $\-[0]),
1182 \& substr($str, $\-[0], $+[0]\-$\-[0]),
1183 \& substr($str, $+[0]);
1184 .Ve
1185 .PP
1186 In Perl 5.10.0 the \f(CW\*(C`/p\*(C'\fR match operator flag and the \f(CW\*(C`${^PREMATCH}\*(C'\fR,
1187 \&\f(CW\*(C`${^MATCH}\*(C'\fR, and \f(CW\*(C`${^POSTMATCH}\*(C'\fR variables were introduced, that allowed
1188 you to suffer the penalties only on patterns marked with \f(CW\*(C`/p\*(C'\fR.
1189 .PP
1190 In Perl 5.18.0 onwards, perl started noting the presence of each of the
1191 three variables separately, and only copied that part of the string
1192 required; so in
1193 .PP
1194 .Vb 1
1195 \& $\`; $&; "abcdefgh" =~ /d/
1196 .Ve
1197 .PP
1198 perl would only copy the "abcd" part of the string. That could make a big
1199 difference in something like
1200 .PP
1201 .Vb 3
1202 \& $str = \*(Aqx\*(Aq x 1_000_000;
1203 \& $&; # whoops
1204 \& $str =~ /x/g # one char copied a million times, not a million chars
1205 .Ve
1206 .PP
1207 In Perl 5.20.0 a new copy\-on\-write system was enabled by default, which
1208 finally fixes most of the performance issues with these three variables, and
1209 makes them safe to use anywhere.
1210 .PP
1211 The \f(CW\*(C`Devel::NYTProf\*(C'\fR and \f(CW\*(C`Devel::FindAmpersand\*(C'\fR modules can help you
1212 find uses of these problematic match variables in your code.
1213 .ie n .IP "$<\fIdigits\fR> ($1, $2, ...)" 8
1214 .el .IP "$<\fIdigits\fR> ($1, \f(CW$2\fR, ...)" 8
1215 .IX Xref "$1 $2 $3 $\\f(ISdigits\\f(IE"
1216 .IX Item "$<digits> ($1, $2, ...)"
1217 Contains the subpattern from the corresponding set of capturing
1218 parentheses from the last successful pattern match in the current
1219 dynamic scope. (See "Scoping Rules of Regex Variables".)
1220 .Sp
1221 Note there is a distinction between a capture buffer which matches
1222 the empty string a capture buffer which is optional. Eg, \f(CW\*(C`(x?)\*(C'\fR and
1223 \&\f(CW\*(C`(x)?\*(C'\fR The latter may be undef, the former not.
1224 .Sp
1225 These variables are read\-only.
1226 .Sp
1227 Mnemonic: like \edigits.
1228 .IP @{^CAPTURE} 8
1229 .IX Xref "@{^CAPTURE} @^CAPTURE"
1230 .IX Item "@{^CAPTURE}"
1231 An array which exposes the contents of the capture buffers, if any, of
1232 the last successful pattern match, not counting patterns matched
1233 in nested blocks that have been exited already.
1234 .Sp
1235 Note that the 0 index of \f(CW\*(C`@{^CAPTURE}\*(C'\fR is equivalent to \f(CW$1\fR, the 1 index
1236 is equivalent to \f(CW$2\fR, etc.
1237 .Sp
1238 .Vb 3
1239 \& if ("foal"=~/(.)(.)(.)(.)/) {
1240 \& print join "\-", @{^CAPTURE};
1241 \& }
1242 .Ve
1243 .Sp
1244 should output "f\-o\-a\-l".
1245 .Sp
1246 See also "$<\fIdigits\fR> ($1, \f(CW$2\fR, ...)", "%{^CAPTURE}" and
1247 "%{^CAPTURE_ALL}".
1248 .Sp
1249 Note that unlike most other regex magic variables there is no single
1250 letter equivalent to \f(CW\*(C`@{^CAPTURE}\*(C'\fR. Also be aware that when
1251 interpolating subscripts of this array you \fBmust\fR use the demarcated
1252 variable form, for instance
1253 .Sp
1254 .Vb 1
1255 \& print "${^CAPTURE[0]}"
1256 .Ve
1257 .Sp
1258 see "Demarcated variable names using braces" in perldata for more
1259 information on this form and its uses.
1260 .Sp
1261 This variable was added in 5.25.7.
1262 .Sp
1263 If you need access to this functionality in older Perls you can use this
1264 function immediately after your regexp.
1265 .Sp
1266 .Vb 2
1267 \& sub get_captures {
1268 \& no strict \*(Aqrefs\*(Aq;
1269 \&
1270 \& my $last_idx = scalar(@\-) \- 1;
1271 \& my @arr = 1 .. $last_idx;
1272 \& my @ret = map { $$_; } @arr;
1273 \&
1274 \& return @ret;
1275 \& }
1276 .Ve
1277 .ie n .IP $MATCH 8
1278 .el .IP \f(CW$MATCH\fR 8
1279 .IX Item "$MATCH"
1280 .PD 0
1281 .IP $& 8
1282 .IX Xref "$& $MATCH"
1283 .PD
1284 The string matched by the last successful pattern match.
1285 (See "Scoping Rules of Regex Variables".)
1286 .Sp
1287 See "Performance issues" above for the serious performance implications
1288 of using this variable (even once) in your code.
1289 .Sp
1290 This variable is read\-only, and its value is dynamically scoped.
1291 .Sp
1292 Mnemonic: like \f(CW\*(C`&\*(C'\fR in some editors.
1293 .IP ${^MATCH} 8
1294 .IX Xref "${^MATCH}"
1295 .IX Item "${^MATCH}"
1296 It is only guaranteed to return a defined value when the pattern was
1297 compiled or executed with the \f(CW\*(C`/p\*(C'\fR modifier.
1298 .Sp
1299 This is similar to \f(CW$&\fR (\f(CW$MATCH\fR) except that to use it you must
1300 use the \f(CW\*(C`/p\*(C'\fR modifier when executing the pattern, and it does not incur
1301 the performance penalty associated with that variable.
1302 .Sp
1303 See "Performance issues" above.
1304 .Sp
1305 This variable was added in Perl v5.10.0.
1306 .Sp
1307 This variable is read\-only, and its value is dynamically scoped.
1308 .ie n .IP $PREMATCH 8
1309 .el .IP \f(CW$PREMATCH\fR 8
1310 .IX Item "$PREMATCH"
1311 .PD 0
1312 .IP $\` 8
1313 .IX Xref "$\\` $PREMATCH"
1314 .PD
1315 The string preceding whatever was matched by the last successful
1316 pattern match. (See "Scoping Rules of Regex Variables").
1317 .Sp
1318 See "Performance issues" above for the serious performance implications
1319 of using this variable (even once) in your code.
1320 .Sp
1321 This variable is read\-only, and its value is dynamically scoped.
1322 .Sp
1323 Mnemonic: \f(CW\*(C`\`\*(C'\fR often precedes a quoted string.
1324 .IP ${^PREMATCH} 8
1325 .IX Xref "${^PREMATCH}"
1326 .IX Item "${^PREMATCH}"
1327 It is only guaranteed to return a defined value when the pattern was
1328 executed with the \f(CW\*(C`/p\*(C'\fR modifier.
1329 .Sp
1330 This is similar to \f(CW\*(C`$\`\*(C'\fR ($PREMATCH) except that to use it you must
1331 use the \f(CW\*(C`/p\*(C'\fR modifier when executing the pattern, and it does not incur
1332 the performance penalty associated with that variable.
1333 .Sp
1334 See "Performance issues" above.
1335 .Sp
1336 This variable was added in Perl v5.10.0.
1337 .Sp
1338 This variable is read\-only, and its value is dynamically scoped.
1339 .ie n .IP $POSTMATCH 8
1340 .el .IP \f(CW$POSTMATCH\fR 8
1341 .IX Item "$POSTMATCH"
1342 .PD 0
1343 .IP $\*(Aq 8
1344 .IX Xref "$\\*(Aq $POSTMATCH @-"
1345 .IX Item "$'"
1346 .PD
1347 The string following whatever was matched by the last successful
1348 pattern match. (See "Scoping Rules of Regex Variables"). Example:
1349 .Sp
1350 .Vb 3
1351 \& local $_ = \*(Aqabcdefghi\*(Aq;
1352 \& /def/;
1353 \& print "$\`:$&:$\*(Aq\en"; # prints abc:def:ghi
1354 .Ve
1355 .Sp
1356 See "Performance issues" above for the serious performance implications
1357 of using this variable (even once) in your code.
1358 .Sp
1359 This variable is read\-only, and its value is dynamically scoped.
1360 .Sp
1361 Mnemonic: \f(CW\*(C`\*(Aq\*(C'\fR often follows a quoted string.
1362 .IP ${^POSTMATCH} 8
1363 .IX Xref "${^POSTMATCH}"
1364 .IX Item "${^POSTMATCH}"
1365 It is only guaranteed to return a defined value when the pattern was
1366 compiled or executed with the \f(CW\*(C`/p\*(C'\fR modifier.
1367 .Sp
1368 This is similar to \f(CW\*(C`$\*(Aq\*(C'\fR (\f(CW$POSTMATCH\fR) except that to use it you must
1369 use the \f(CW\*(C`/p\*(C'\fR modifier when executing the pattern, and it does not incur
1370 the performance penalty associated with that variable.
1371 .Sp
1372 See "Performance issues" above.
1373 .Sp
1374 This variable was added in Perl v5.10.0.
1375 .Sp
1376 This variable is read\-only, and its value is dynamically scoped.
1377 .ie n .IP $LAST_PAREN_MATCH 8
1378 .el .IP \f(CW$LAST_PAREN_MATCH\fR 8
1379 .IX Item "$LAST_PAREN_MATCH"
1380 .PD 0
1381 .IP $+ 8
1382 .IX Xref "$+ $LAST_PAREN_MATCH"
1383 .PD
1384 The text matched by the highest used capture group of the last
1385 successful search pattern. (See "Scoping Rules of Regex Variables").
1386 It is logically equivalent to the highest
1387 numbered capture variable (\f(CW$1\fR, \f(CW$2\fR, ...) which has a defined value.
1388 .Sp
1389 This is useful if you don\*(Aqt know which one of a set of alternative patterns
1390 matched. For example:
1391 .Sp
1392 .Vb 1
1393 \& /Version: (.*)|Revision: (.*)/ && ($rev = $+);
1394 .Ve
1395 .Sp
1396 This variable is read\-only, and its value is dynamically scoped.
1397 .Sp
1398 Mnemonic: be positive and forward looking.
1399 .ie n .IP $LAST_SUBMATCH_RESULT 8
1400 .el .IP \f(CW$LAST_SUBMATCH_RESULT\fR 8
1401 .IX Item "$LAST_SUBMATCH_RESULT"
1402 .PD 0
1403 .IP $^N 8
1404 .IX Xref "$^N $LAST_SUBMATCH_RESULT"
1405 .IX Item "$^N"
1406 .PD
1407 The text matched by the used group most\-recently closed (i.e. the group
1408 with the rightmost closing parenthesis) of the last successful match.
1409 (See "Scoping Rules of Regex Variables").
1410 .Sp
1411 This is subtly different from \f(CW$+\fR. For example in
1412 .Sp
1413 .Vb 1
1414 \& "ab" =~ /^((.)(.))$/
1415 .Ve
1416 .Sp
1417 we have
1418 .Sp
1419 .Vb 3
1420 \& $1,$^N have the value "ab"
1421 \& $2 has the value "a"
1422 \& $3,$+ have the value "b"
1423 .Ve
1424 .Sp
1425 This is primarily used inside \f(CW\*(C`(?{...})\*(C'\fR blocks for examining text
1426 recently matched. For example, to effectively capture text to a variable
1427 (in addition to \f(CW$1\fR, \f(CW$2\fR, etc.), replace \f(CW\*(C`(...)\*(C'\fR with
1428 .Sp
1429 .Vb 1
1430 \& (?:(...)(?{ $var = $^N }))
1431 .Ve
1432 .Sp
1433 By setting and then using \f(CW$var\fR in this way relieves you from having to
1434 worry about exactly which numbered set of parentheses they are.
1435 .Sp
1436 This variable is read\-only, and its value is dynamically scoped.
1437 .Sp
1438 This variable was added in Perl v5.8.0.
1439 .Sp
1440 Mnemonic: the (possibly) Nested parenthesis that most recently closed.
1441 .ie n .IP @LAST_MATCH_END 8
1442 .el .IP \f(CW@LAST_MATCH_END\fR 8
1443 .IX Item "@LAST_MATCH_END"
1444 .PD 0
1445 .IP @+ 8
1446 .IX Xref "@+ @LAST_MATCH_END"
1447 .PD
1448 This array holds the offsets of the ends of the last successful
1449 match and any matching capture buffers that the pattern contains.
1450 (See "Scoping Rules of Regex Variables")
1451 .Sp
1452 The number of elements it contains will be one more than the number
1453 of capture buffers in the pattern, regardless of which capture buffers
1454 actually matched. You can use this to determine how many capture
1455 buffers there are in the pattern. (As opposed to \f(CW\*(C`@\-\*(C'\fR which may
1456 have fewer elements.)
1457 .Sp
1458 \&\f(CW$+[0]\fR is the offset into the string of the end of the entire match.
1459 This is the same value as what the \f(CW\*(C`pos\*(C'\fR function returns when called
1460 on the variable that was matched against. The \fIn\fRth element of this
1461 array holds the offset of the \fIn\fRth submatch, so \f(CW$+[1]\fR is the offset
1462 past where \f(CW$1\fR ends, \f(CW$+[2]\fR the offset past where \f(CW$2\fR ends, and so
1463 on. You can use \f(CW$#+\fR to determine how many subgroups were in the last
1464 successful match. See the examples given for the \f(CW\*(C`@\-\*(C'\fR variable.
1465 .Sp
1466 This variable is read\-only, and its value is dynamically scoped.
1467 .Sp
1468 This variable was added in Perl v5.6.0.
1469 .IP %{^CAPTURE} 8
1470 .IX Item "%{^CAPTURE}"
1471 .PD 0
1472 .ie n .IP %LAST_PAREN_MATCH 8
1473 .el .IP \f(CW%LAST_PAREN_MATCH\fR 8
1474 .IX Item "%LAST_PAREN_MATCH"
1475 .IP %+ 8
1476 .IX Xref "%+ %LAST_PAREN_MATCH %{^CAPTURE}"
1477 .PD
1478 Similar to \f(CW\*(C`@+\*(C'\fR, the \f(CW\*(C`%+\*(C'\fR hash allows access to the named capture
1479 buffers, should they exist, in the last successful match in the
1480 currently active dynamic scope. (See "Scoping Rules of Regex Variables").
1481 .Sp
1482 For example, \f(CW$+{foo}\fR is equivalent to \f(CW$1\fR after the following match:
1483 .Sp
1484 .Vb 1
1485 \& \*(Aqfoo\*(Aq =~ /(?<foo>foo)/;
1486 .Ve
1487 .Sp
1488 The keys of the \f(CW\*(C`%+\*(C'\fR hash list only the names of buffers that have
1489 captured (and that are thus associated to defined values).
1490 .Sp
1491 If multiple distinct capture groups have the same name, then
1492 \&\f(CW$+{NAME}\fR will refer to the leftmost defined group in the match.
1493 .Sp
1494 The underlying behaviour of \f(CW\*(C`%+\*(C'\fR is provided by the
1495 Tie::Hash::NamedCapture module.
1496 .Sp
1497 \&\fBNote:\fR \f(CW\*(C`%\-\*(C'\fR and \f(CW\*(C`%+\*(C'\fR are tied views into a common internal hash
1498 associated with the last successful regular expression. Therefore mixing
1499 iterative access to them via \f(CW\*(C`each\*(C'\fR may have unpredictable results.
1500 Likewise, if the last successful match changes, then the results may be
1501 surprising.
1502 .Sp
1503 This variable was added in Perl v5.10.0. The \f(CW\*(C`%{^CAPTURE}\*(C'\fR alias was
1504 added in 5.25.7.
1505 .Sp
1506 This variable is read\-only, and its value is dynamically scoped.
1507 .ie n .IP @LAST_MATCH_START 8
1508 .el .IP \f(CW@LAST_MATCH_START\fR 8
1509 .IX Item "@LAST_MATCH_START"
1510 .PD 0
1511 .IP @\- 8
1512 .IX Xref "@- @LAST_MATCH_START"
1513 .PD
1514 This array holds the offsets of the beginnings of the last successful
1515 match and any capture buffers it contains.
1516 (See "Scoping Rules of Regex Variables").
1517 .Sp
1518 The number of elements it contains will be one more than the number of
1519 the highest capture buffers (also called a subgroup) that actually
1520 matched something. (As opposed to \f(CW\*(C`@+\*(C'\fR which may have more elements.)
1521 .Sp
1522 \&\f(CW\*(C`$\-[0]\*(C'\fR is the offset of the start of the last successful match.
1523 \&\f(CW\*(C`$\-[\fR\f(CIn\fR\f(CW]\*(C'\fR is the offset of the start of the substring matched by
1524 \&\fIn\fR\-th subpattern, or undef if the subpattern did not match.
1525 .Sp
1526 Thus, after a match against \f(CW$_\fR, \f(CW$&\fR coincides with
1527 \&\f(CW\*(C`substr $_, $\-[0], $+[0] \- $\-[0]\*(C'\fR. Similarly, \f(CW\*(C`$\fR\f(CIn\fR\f(CW\*(C'\fR coincides
1528 with \f(CW\*(C`substr $_, $\-[n], $+[n] \- $\-[n]\*(C'\fR if \f(CW\*(C`$\-[n]\*(C'\fR is defined, and
1529 \&\f(CW$+\fR coincides with \f(CW\*(C`substr $_, $\-[$#\-], $+[$#\-] \- $\-[$#\-]\*(C'\fR.
1530 One can use \f(CW\*(C`$#\-\*(C'\fR to find the last matched subgroup in the last
1531 successful match. Contrast with \f(CW$#+\fR, the number of subgroups
1532 in the regular expression.
1533 .Sp
1534 \&\f(CW\*(C`$\-[0]\*(C'\fR is the offset into the string of the beginning of the
1535 entire match. The \fIn\fRth element of this array holds the offset
1536 of the \fIn\fRth submatch, so \f(CW\*(C`$\-[1]\*(C'\fR is the offset where \f(CW$1\fR
1537 begins, \f(CW\*(C`$\-[2]\*(C'\fR the offset where \f(CW$2\fR begins, and so on.
1538 .Sp
1539 After a match against some variable \f(CW$var\fR:
1540 .RS 8
1541 .ie n .IP """$\`"" is the same as ""substr($var, 0, $\-[0])""" 5
1542 .el .IP "\f(CW$\`\fR is the same as \f(CWsubstr($var, 0, $\-[0])\fR" 5
1543 .IX Item "$` is the same as substr($var, 0, $-[0])"
1544 .PD 0
1545 .ie n .IP "$& is the same as ""substr($var, $\-[0], $+[0] \- $\-[0])""" 5
1546 .el .IP "\f(CW$&\fR is the same as \f(CWsubstr($var, $\-[0], $+[0] \- $\-[0])\fR" 5
1547 .IX Item "$& is the same as substr($var, $-[0], $+[0] - $-[0])"
1548 .ie n .IP """$\*(Aq"" is the same as ""substr($var, $+[0])""" 5
1549 .el .IP "\f(CW$\*(Aq\fR is the same as \f(CWsubstr($var, $+[0])\fR" 5
1550 .IX Item "$' is the same as substr($var, $+[0])"
1551 .ie n .IP "$1 is the same as ""substr($var, $\-[1], $+[1] \- $\-[1])""" 5
1552 .el .IP "\f(CW$1\fR is the same as \f(CWsubstr($var, $\-[1], $+[1] \- $\-[1])\fR" 5
1553 .IX Item "$1 is the same as substr($var, $-[1], $+[1] - $-[1])"
1554 .ie n .IP "$2 is the same as ""substr($var, $\-[2], $+[2] \- $\-[2])""" 5
1555 .el .IP "\f(CW$2\fR is the same as \f(CWsubstr($var, $\-[2], $+[2] \- $\-[2])\fR" 5
1556 .IX Item "$2 is the same as substr($var, $-[2], $+[2] - $-[2])"
1557 .ie n .IP "$3 is the same as ""substr($var, $\-[3], $+[3] \- $\-[3])""" 5
1558 .el .IP "\f(CW$3\fR is the same as \f(CWsubstr($var, $\-[3], $+[3] \- $\-[3])\fR" 5
1559 .IX Item "$3 is the same as substr($var, $-[3], $+[3] - $-[3])"
1560 .PD
1561 .RE
1562 .RS 8
1563 .Sp
1564 This variable is read\-only, and its value is dynamically scoped.
1565 .Sp
1566 This variable was added in Perl v5.6.0.
1567 .RE
1568 .IP %{^CAPTURE_ALL} 8
1569 .IX Xref "%{^CAPTURE_ALL}"
1570 .IX Item "%{^CAPTURE_ALL}"
1571 .PD 0
1572 .IP %\- 8
1573 .IX Xref "%-"
1574 .PD
1575 Similar to \f(CW\*(C`%+\*(C'\fR, this variable allows access to the named capture
1576 groups in the last successful match in the currently active dynamic
1577 scope. (See "Scoping Rules of Regex Variables"). To each capture group
1578 name found in the regular expression, it associates a reference to an
1579 array containing the list of values captured by all buffers with that
1580 name (should there be several of them), in the order where they appear.
1581 .Sp
1582 Here\*(Aqs an example:
1583 .Sp
1584 .Vb 12
1585 \& if (\*(Aq1234\*(Aq =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) {
1586 \& foreach my $bufname (sort keys %\-) {
1587 \& my $ary = $\-{$bufname};
1588 \& foreach my $idx (0..$#$ary) {
1589 \& print "\e$\-{$bufname}[$idx] : ",
1590 \& (defined($ary\->[$idx])
1591 \& ? "\*(Aq$ary\->[$idx]\*(Aq"
1592 \& : "undef"),
1593 \& "\en";
1594 \& }
1595 \& }
1596 \& }
1597 .Ve
1598 .Sp
1599 would print out:
1600 .Sp
1601 .Vb 4
1602 \& $\-{A}[0] : \*(Aq1\*(Aq
1603 \& $\-{A}[1] : \*(Aq3\*(Aq
1604 \& $\-{B}[0] : \*(Aq2\*(Aq
1605 \& $\-{B}[1] : \*(Aq4\*(Aq
1606 .Ve
1607 .Sp
1608 The keys of the \f(CW\*(C`%\-\*(C'\fR hash correspond to all buffer names found in
1609 the regular expression.
1610 .Sp
1611 The behaviour of \f(CW\*(C`%\-\*(C'\fR is implemented via the
1612 Tie::Hash::NamedCapture module.
1613 .Sp
1614 \&\fBNote:\fR \f(CW\*(C`%\-\*(C'\fR and \f(CW\*(C`%+\*(C'\fR are tied views into a common internal hash
1615 associated with the last successful regular expression. Therefore mixing
1616 iterative access to them via \f(CW\*(C`each\*(C'\fR may have unpredictable results.
1617 Likewise, if the last successful match changes, then the results may be
1618 surprising. See "Scoping Rules of Regex Variables".
1619 .Sp
1620 This variable was added in Perl v5.10.0. The \f(CW\*(C`%{^CAPTURE_ALL}\*(C'\fR alias was
1621 added in 5.25.7.
1622 .Sp
1623 This variable is read\-only, and its value is dynamically scoped.
1624 .IP ${^LAST_SUCCESSFUL_PATTERN} 8
1625 .IX Item "${^LAST_SUCCESSFUL_PATTERN}"
1626 The last successful pattern that matched in the current scope. The empty
1627 pattern defaults to matching to this. For instance:
1628 .Sp
1629 .Vb 3
1630 \& if (m/foo/ || m/bar/) {
1631 \& s//BLAH/;
1632 \& }
1633 .Ve
1634 .Sp
1635 and
1636 .Sp
1637 .Vb 3
1638 \& if (m/foo/ || m/bar/) {
1639 \& s/${^LAST_SUCCESSFUL_PATTERN}/BLAH/;
1640 \& }
1641 .Ve
1642 .Sp
1643 are equivalent.
1644 .Sp
1645 You can use this to debug which pattern matched last, or to match with it again.
1646 .Sp
1647 Added in Perl 5.37.10.
1648 .ie n .IP $LAST_REGEXP_CODE_RESULT 8
1649 .el .IP \f(CW$LAST_REGEXP_CODE_RESULT\fR 8
1650 .IX Item "$LAST_REGEXP_CODE_RESULT"
1651 .PD 0
1652 .IP $^R 8
1653 .IX Xref "$^R $LAST_REGEXP_CODE_RESULT"
1654 .IX Item "$^R"
1655 .PD
1656 The result of evaluation of the last successful \f(CW\*(C`(?{ code })\*(C'\fR
1657 regular expression assertion (see perlre).
1658 .Sp
1659 This variable may be written to, and its value is scoped normally,
1660 unlike most other regex variables.
1661 .Sp
1662 This variable was added in Perl 5.005.
1663 .IP ${^RE_COMPILE_RECURSION_LIMIT} 8
1664 .IX Xref "${^RE_COMPILE_RECURSION_LIMIT}"
1665 .IX Item "${^RE_COMPILE_RECURSION_LIMIT}"
1666 The current value giving the maximum number of open but unclosed
1667 parenthetical groups there may be at any point during a regular
1668 expression compilation. The default is currently 1000 nested groups.
1669 You may adjust it depending on your needs and the amount of memory
1670 available.
1671 .Sp
1672 This variable was added in Perl v5.30.0.
1673 .IP ${^RE_DEBUG_FLAGS} 8
1674 .IX Xref "${^RE_DEBUG_FLAGS}"
1675 .IX Item "${^RE_DEBUG_FLAGS}"
1676 The current value of the regex debugging flags. Set to 0 for no debug output
1677 even when the \f(CW\*(C`re \*(Aqdebug\*(Aq\*(C'\fR module is loaded. See re for details.
1678 .Sp
1679 This variable was added in Perl v5.10.0.
1680 .IP ${^RE_TRIE_MAXBUF} 8
1681 .IX Xref "${^RE_TRIE_MAXBUF}"
1682 .IX Item "${^RE_TRIE_MAXBUF}"
1683 Controls how certain regex optimisations are applied and how much memory they
1684 utilize. This value by default is 65536 which corresponds to a 512kB
1685 temporary cache. Set this to a higher value to trade
1686 memory for speed when matching large alternations. Set
1687 it to a lower value if you want the optimisations to
1688 be as conservative of memory as possible but still occur, and set it to a
1689 negative value to prevent the optimisation and conserve the most memory.
1690 Under normal situations this variable should be of no interest to you.
1691 .Sp
1692 This variable was added in Perl v5.10.0.
1693 .SS "Variables related to filehandles"
1694 .IX Subsection "Variables related to filehandles"
1695 Variables that depend on the currently selected filehandle may be set
1696 by calling an appropriate object method on the \f(CW\*(C`IO::Handle\*(C'\fR object,
1697 although this is slightly less efficient than using the regular built\-in
1698 variables. (Summary lines below for this contain the word HANDLE.)
1699 .PP
1700 In Perl versions before v5.14.0, you had to say
1701 .PP
1702 .Vb 1
1703 \& use IO::Handle;
1704 .Ve
1705 .PP
1706 before using
1707 .PP
1708 .Vb 1
1709 \& HANDLE\->method(EXPR)
1710 .Ve
1711 .PP
1712 Since Perl v5.14.0, you can use all filehandles as objects without manually
1713 loading any modules first.
1714 .PP
1715 Each method returns the old value of the \f(CW\*(C`IO::Handle\*(C'\fR attribute. The
1716 methods each take an optional EXPR, which, if supplied, specifies the
1717 new value for the \f(CW\*(C`IO::Handle\*(C'\fR attribute in question. If not
1718 supplied, most methods do nothing to the current value\-\-except for
1719 \&\f(CWautoflush()\fR, which will assume a 1 for you, just to be different.
1720 .PP
1721 A few of these variables are considered "read\-only". This means that
1722 if you try to assign to this variable, either directly or indirectly
1723 through a reference, you\*(Aqll raise a run\-time exception.
1724 .PP
1725 You should be very careful when modifying the default values of most
1726 special variables described in this document. In most cases you want
1727 to localize these variables before changing them, since if you don\*(Aqt,
1728 the change may affect other modules which rely on the default values
1729 of the special variables that you have changed. This is one of the
1730 correct ways to read the whole file at once:
1731 .PP
1732 .Vb 4
1733 \& open my $fh, "<", "foo" or die $!;
1734 \& local $/; # enable localized slurp mode
1735 \& my $content = <$fh>;
1736 \& close $fh;
1737 .Ve
1738 .PP
1739 But the following code is quite bad:
1740 .PP
1741 .Vb 4
1742 \& open my $fh, "<", "foo" or die $!;
1743 \& undef $/; # enable slurp mode
1744 \& my $content = <$fh>;
1745 \& close $fh;
1746 .Ve
1747 .PP
1748 since some other module may want to read data from some file in the
1749 default "line mode", so if the code we have just presented has been
1750 executed, the global value of \f(CW$/\fR is now changed for any other code
1751 running inside the same Perl interpreter.
1752 .PP
1753 Usually when a variable is localized, you want to make sure that this
1754 change affects the shortest scope possible. So unless you are already
1755 inside some short \f(CW\*(C`{}\*(C'\fR block, you should create one yourself. For
1756 example:
1757 .PP
1758 .Vb 7
1759 \& my $content = \*(Aq\*(Aq;
1760 \& open my $fh, "<", "foo" or die $!;
1761 \& {
1762 \& local $/;
1763 \& $content = <$fh>;
1764 \& }
1765 \& close $fh;
1766 .Ve
1767 .PP
1768 Here is an example of how your own code can go broken:
1769 .PP
1770 .Vb 5
1771 \& for ( 1..3 ){
1772 \& $\e = "\er\en";
1773 \& nasty_break();
1774 \& print "$_";
1775 \& }
1776 \&
1777 \& sub nasty_break {
1778 \& $\e = "\ef";
1779 \& # do something with $_
1780 \& }
1781 .Ve
1782 .PP
1783 You probably expect this code to print the equivalent of
1784 .PP
1785 .Vb 1
1786 \& "1\er\en2\er\en3\er\en"
1787 .Ve
1788 .PP
1789 but instead you get:
1790 .PP
1791 .Vb 1
1792 \& "1\ef2\ef3\ef"
1793 .Ve
1794 .PP
1795 Why? Because \f(CWnasty_break()\fR modifies \f(CW\*(C`$\e\*(C'\fR without localizing it
1796 first. The value you set in \f(CWnasty_break()\fR is still there when you
1797 return. The fix is to add \f(CWlocal()\fR so the value doesn\*(Aqt leak out of
1798 \&\f(CWnasty_break()\fR:
1799 .PP
1800 .Vb 1
1801 \& local $\e = "\ef";
1802 .Ve
1803 .PP
1804 It\*(Aqs easy to notice the problem in such a short example, but in more
1805 complicated code you are looking for trouble if you don\*(Aqt localize
1806 changes to the special variables.
1807 .ie n .IP $ARGV 8
1808 .el .IP \f(CW$ARGV\fR 8
1809 .IX Xref "$ARGV"
1810 .IX Item "$ARGV"
1811 Contains the name of the current file when reading from \f(CW\*(C`<>\*(C'\fR.
1812 .ie n .IP @ARGV 8
1813 .el .IP \f(CW@ARGV\fR 8
1814 .IX Xref "@ARGV"
1815 .IX Item "@ARGV"
1816 The array \f(CW@ARGV\fR contains the command\-line arguments intended for
1817 the script. \f(CW$#ARGV\fR is generally the number of arguments minus
1818 one, because \f(CW$ARGV[0]\fR is the first argument, \fInot\fR the program\*(Aqs
1819 command name itself. See "$0" for the command name.
1820 .IP ARGV 8
1821 .IX Xref "ARGV"
1822 .IX Item "ARGV"
1823 The special filehandle that iterates over command\-line filenames in
1824 \&\f(CW@ARGV\fR. Usually written as the null filehandle in the diamond operator
1825 \&\f(CW\*(C`<>\*(C'\fR. Note that currently \f(CW\*(C`ARGV\*(C'\fR only has its magical effect
1826 within the \f(CW\*(C`<>\*(C'\fR operator; elsewhere it is just a plain filehandle
1827 corresponding to the last file opened by \f(CW\*(C`<>\*(C'\fR. In particular,
1828 passing \f(CW\*(C`\e*ARGV\*(C'\fR as a parameter to a function that expects a filehandle
1829 may not cause your function to automatically read the contents of all the
1830 files in \f(CW@ARGV\fR.
1831 .IP ARGVOUT 8
1832 .IX Xref "ARGVOUT"
1833 .IX Item "ARGVOUT"
1834 The special filehandle that points to the currently open output file
1835 when doing edit\-in\-place processing with \fB\-i\fR. Useful when you have
1836 to do a lot of inserting and don\*(Aqt want to keep modifying \f(CW$_\fR. See
1837 perlrun for the \fB\-i\fR switch.
1838 .IP "IO::Handle\->output_field_separator( EXPR )" 8
1839 .IX Item "IO::Handle->output_field_separator( EXPR )"
1840 .PD 0
1841 .ie n .IP $OUTPUT_FIELD_SEPARATOR 8
1842 .el .IP \f(CW$OUTPUT_FIELD_SEPARATOR\fR 8
1843 .IX Item "$OUTPUT_FIELD_SEPARATOR"
1844 .ie n .IP $OFS 8
1845 .el .IP \f(CW$OFS\fR 8
1846 .IX Item "$OFS"
1847 .IP $, 8
1848 .IX Xref "$, $OFS $OUTPUT_FIELD_SEPARATOR"
1849 .PD
1850 The output field separator for the print operator. If defined, this
1851 value is printed between each of print\*(Aqs arguments. Default is \f(CW\*(C`undef\*(C'\fR.
1852 .Sp
1853 You cannot call \f(CWoutput_field_separator()\fR on a handle, only as a
1854 static method. See IO::Handle.
1855 .Sp
1856 Mnemonic: what is printed when there is a "," in your print statement.
1857 .IP "HANDLE\->input_line_number( EXPR )" 8
1858 .IX Item "HANDLE->input_line_number( EXPR )"
1859 .PD 0
1860 .ie n .IP $INPUT_LINE_NUMBER 8
1861 .el .IP \f(CW$INPUT_LINE_NUMBER\fR 8
1862 .IX Item "$INPUT_LINE_NUMBER"
1863 .ie n .IP $NR 8
1864 .el .IP \f(CW$NR\fR 8
1865 .IX Item "$NR"
1866 .IP $. 8
1867 .IX Xref "$. $NR $INPUT_LINE_NUMBER line number"
1868 .PD
1869 Current line number for the last filehandle accessed.
1870 .Sp
1871 Each filehandle in Perl counts the number of lines that have been read
1872 from it. (Depending on the value of \f(CW$/\fR, Perl\*(Aqs idea of what
1873 constitutes a line may not match yours.) When a line is read from a
1874 filehandle (via \f(CWreadline()\fR or \f(CW\*(C`<>\*(C'\fR), or when \f(CWtell()\fR or
1875 \&\f(CWseek()\fR is called on it, \f(CW$.\fR becomes an alias to the line counter
1876 for that filehandle.
1877 .Sp
1878 You can adjust the counter by assigning to \f(CW$.\fR, but this will not
1879 actually move the seek pointer. \fILocalizing \fR\f(CI$.\fR\fI will not localize
1880 the filehandle\*(Aqs line count\fR. Instead, it will localize perl\*(Aqs notion
1881 of which filehandle \f(CW$.\fR is currently aliased to.
1882 .Sp
1883 \&\f(CW$.\fR is reset when the filehandle is closed, but \fBnot\fR when an open
1884 filehandle is reopened without an intervening \f(CWclose()\fR. For more
1885 details, see "I/O Operators" in perlop. Because \f(CW\*(C`<>\*(C'\fR never does
1886 an explicit close, line numbers increase across \f(CW\*(C`ARGV\*(C'\fR files (but see
1887 examples in "eof" in perlfunc).
1888 .Sp
1889 You can also use \f(CW\*(C`HANDLE\->input_line_number(EXPR)\*(C'\fR to access the
1890 line counter for a given filehandle without having to worry about
1891 which handle you last accessed.
1892 .Sp
1893 Mnemonic: many programs use "." to mean the current line number.
1894 .IP "IO::Handle\->input_record_separator( EXPR )" 8
1895 .IX Item "IO::Handle->input_record_separator( EXPR )"
1896 .PD 0
1897 .ie n .IP $INPUT_RECORD_SEPARATOR 8
1898 .el .IP \f(CW$INPUT_RECORD_SEPARATOR\fR 8
1899 .IX Item "$INPUT_RECORD_SEPARATOR"
1900 .ie n .IP $RS 8
1901 .el .IP \f(CW$RS\fR 8
1902 .IX Item "$RS"
1903 .IP $/ 8
1904 .IX Xref "$ $RS $INPUT_RECORD_SEPARATOR"
1905 .PD
1906 The input record separator, newline by default. This influences Perl\*(Aqs
1907 idea of what a "line" is. Works like \fBawk\fR\*(Aqs RS variable, including
1908 treating empty lines as a terminator if set to the null string (an
1909 empty line cannot contain any spaces or tabs). You may set it to a
1910 multi\-character string to match a multi\-character terminator, or to
1911 \&\f(CW\*(C`undef\*(C'\fR to read through the end of file. Setting it to \f(CW"\en\en"\fR
1912 means something slightly different than setting to \f(CW""\fR, if the file
1913 contains consecutive empty lines. Setting to \f(CW""\fR will treat two or
1914 more consecutive empty lines as a single empty line. Setting to
1915 \&\f(CW"\en\en"\fR will blindly assume that the next input character belongs to
1916 the next paragraph, even if it\*(Aqs a newline.
1917 .Sp
1918 .Vb 3
1919 \& local $/; # enable "slurp" mode
1920 \& local $_ = <FH>; # whole file now here
1921 \& s/\en[ \et]+/ /g;
1922 .Ve
1923 .Sp
1924 Remember: the value of \f(CW$/\fR is a string, not a regex. \fBawk\fR has to
1925 be better for something. :\-)
1926 .Sp
1927 Setting \f(CW$/\fR to an empty string \-\- the so\-called \fIparagraph mode\fR \-\- merits
1928 special attention. When \f(CW$/\fR is set to \f(CW""\fR and the entire file is read in
1929 with that setting, any sequence of one or more consecutive newlines at the
1930 beginning of the file is discarded. With the exception of the final record in
1931 the file, each sequence of characters ending in two or more newlines is
1932 treated as one record and is read in to end in exactly two newlines. If the
1933 last record in the file ends in zero or one consecutive newlines, that record
1934 is read in with that number of newlines. If the last record ends in two or
1935 more consecutive newlines, it is read in with two newlines like all preceding
1936 records.
1937 .Sp
1938 Suppose we wrote the following string to a file:
1939 .Sp
1940 .Vb 4
1941 \& my $string = "\en\en\en";
1942 \& $string .= "alpha beta\engamma delta\en\en\en";
1943 \& $string .= "epsilon zeta eta\en\en";
1944 \& $string .= "theta\en";
1945 \&
1946 \& my $file = \*(Aqsimple_file.txt\*(Aq;
1947 \& open my $OUT, \*(Aq>\*(Aq, $file or die;
1948 \& print $OUT $string;
1949 \& close $OUT or die;
1950 .Ve
1951 .Sp
1952 Now we read that file in paragraph mode:
1953 .Sp
1954 .Vb 4
1955 \& local $/ = ""; # paragraph mode
1956 \& open my $IN, \*(Aq<\*(Aq, $file or die;
1957 \& my @records = <$IN>;
1958 \& close $IN or die;
1959 .Ve
1960 .Sp
1961 \&\f(CW@records\fR will consist of these 3 strings:
1962 .Sp
1963 .Vb 5
1964 \& (
1965 \& "alpha beta\engamma delta\en\en",
1966 \& "epsilon zeta eta\en\en",
1967 \& "theta\en",
1968 \& )
1969 .Ve
1970 .Sp
1971 Setting \f(CW$/\fR to a reference to an integer, scalar containing an
1972 integer, or scalar that\*(Aqs convertible to an integer will attempt to
1973 read records instead of lines, with the maximum record size being the
1974 referenced integer number of characters. So this:
1975 .Sp
1976 .Vb 3
1977 \& local $/ = \e32768; # or \e"32768", or \e$var_containing_32768
1978 \& open my $fh, "<", $myfile or die $!;
1979 \& local $_ = <$fh>;
1980 .Ve
1981 .Sp
1982 will read a record of no more than 32768 characters from \f(CW$fh\fR. If you\*(Aqre
1983 not reading from a record\-oriented file (or your OS doesn\*(Aqt have
1984 record\-oriented files), then you\*(Aqll likely get a full chunk of data
1985 with every read. If a record is larger than the record size you\*(Aqve
1986 set, you\*(Aqll get the record back in pieces. Trying to set the record
1987 size to zero or less is deprecated and will cause $/ to have the value
1988 of "undef", which will cause reading in the (rest of the) whole file.
1989 .Sp
1990 As of 5.19.9 setting \f(CW$/\fR to any other form of reference will throw a
1991 fatal exception. This is in preparation for supporting new ways to set
1992 \&\f(CW$/\fR in the future.
1993 .Sp
1994 On VMS only, record reads bypass PerlIO layers and any associated
1995 buffering, so you must not mix record and non\-record reads on the
1996 same filehandle. Record mode mixes with line mode only when the
1997 same buffering layer is in use for both modes.
1998 .Sp
1999 You cannot call \f(CWinput_record_separator()\fR on a handle, only as a
2000 static method. See IO::Handle.
2001 .Sp
2002 See also "Newlines" in perlport. Also see "$.".
2003 .Sp
2004 Mnemonic: / delimits line boundaries when quoting poetry.
2005 .IP "IO::Handle\->output_record_separator( EXPR )" 8
2006 .IX Item "IO::Handle->output_record_separator( EXPR )"
2007 .PD 0
2008 .ie n .IP $OUTPUT_RECORD_SEPARATOR 8
2009 .el .IP \f(CW$OUTPUT_RECORD_SEPARATOR\fR 8
2010 .IX Item "$OUTPUT_RECORD_SEPARATOR"
2011 .ie n .IP $ORS 8
2012 .el .IP \f(CW$ORS\fR 8
2013 .IX Item "$ORS"
2014 .IP $\e 8
2015 .IX Xref "$\\ $ORS $OUTPUT_RECORD_SEPARATOR"
2016 .IX Item "$"
2017 .PD
2018 The output record separator for the print operator. If defined, this
2019 value is printed after the last of print\*(Aqs arguments. Default is \f(CW\*(C`undef\*(C'\fR.
2020 .Sp
2021 You cannot call \f(CWoutput_record_separator()\fR on a handle, only as a
2022 static method. See IO::Handle.
2023 .Sp
2024 Mnemonic: you set \f(CW\*(C`$\e\*(C'\fR instead of adding "\en" at the end of the print.
2025 Also, it\*(Aqs just like \f(CW$/\fR, but it\*(Aqs what you get "back" from Perl.
2026 .IP "HANDLE\->autoflush( EXPR )" 8
2027 .IX Item "HANDLE->autoflush( EXPR )"
2028 .PD 0
2029 .ie n .IP $OUTPUT_AUTOFLUSH 8
2030 .el .IP \f(CW$OUTPUT_AUTOFLUSH\fR 8
2031 .IX Item "$OUTPUT_AUTOFLUSH"
2032 .IP $| 8
2033 .IX Xref "$| autoflush flush $OUTPUT_AUTOFLUSH"
2034 .PD
2035 If set to nonzero, forces a flush right away and after every write or
2036 print on the currently selected output channel. Default is 0
2037 (regardless of whether the channel is really buffered by the system or
2038 not; \f(CW$|\fR tells you only whether you\*(Aqve asked Perl explicitly to
2039 flush after each write). STDOUT will typically be line buffered if
2040 output is to the terminal and block buffered otherwise. Setting this
2041 variable is useful primarily when you are outputting to a pipe or
2042 socket, such as when you are running a Perl program under \fBrsh\fR and
2043 want to see the output as it\*(Aqs happening. This has no effect on input
2044 buffering. See "getc" in perlfunc for that. See "select" in perlfunc on
2045 how to select the output channel. See also IO::Handle.
2046 .Sp
2047 Mnemonic: when you want your pipes to be piping hot.
2048 .IP ${^LAST_FH} 8
2049 .IX Xref "${^LAST_FH}"
2050 .IX Item "${^LAST_FH}"
2051 This read\-only variable contains a reference to the last\-read filehandle.
2052 This is set by \f(CW\*(C`<HANDLE>\*(C'\fR, \f(CW\*(C`readline\*(C'\fR, \f(CW\*(C`tell\*(C'\fR, \f(CW\*(C`eof\*(C'\fR and \f(CW\*(C`seek\*(C'\fR.
2053 This is the same handle that \f(CW$.\fR and \f(CW\*(C`tell\*(C'\fR and \f(CW\*(C`eof\*(C'\fR without arguments
2054 use. It is also the handle used when Perl appends ", <STDIN> line 1" to
2055 an error or warning message.
2056 .Sp
2057 This variable was added in Perl v5.18.0.
2058 .PP
2059 \fIVariables related to formats\fR
2060 .IX Subsection "Variables related to formats"
2061 .PP
2062 The special variables for formats are a subset of those for
2063 filehandles. See perlform for more information about Perl\*(Aqs
2064 formats.
2065 .ie n .IP $ACCUMULATOR 8
2066 .el .IP \f(CW$ACCUMULATOR\fR 8
2067 .IX Item "$ACCUMULATOR"
2068 .PD 0
2069 .IP $^A 8
2070 .IX Xref "$^A $ACCUMULATOR"
2071 .IX Item "$^A"
2072 .PD
2073 The current value of the \f(CWwrite()\fR accumulator for \f(CWformat()\fR lines.
2074 A format contains \f(CWformline()\fR calls that put their result into
2075 \&\f(CW$^A\fR. After calling its format, \f(CWwrite()\fR prints out the contents
2076 of \f(CW$^A\fR and empties. So you never really see the contents of \f(CW$^A\fR
2077 unless you call \f(CWformline()\fR yourself and then look at it. See
2078 perlform and "formline PICTURE,LIST" in perlfunc.
2079 .IP IO::Handle\->format_formfeed(EXPR) 8
2080 .IX Item "IO::Handle->format_formfeed(EXPR)"
2081 .PD 0
2082 .ie n .IP $FORMAT_FORMFEED 8
2083 .el .IP \f(CW$FORMAT_FORMFEED\fR 8
2084 .IX Item "$FORMAT_FORMFEED"
2085 .IP $^L 8
2086 .IX Xref "$^L $FORMAT_FORMFEED"
2087 .IX Item "$^L"
2088 .PD
2089 What formats output as a form feed. The default is \f(CW\*(C`\ef\*(C'\fR.
2090 .Sp
2091 You cannot call \f(CWformat_formfeed()\fR on a handle, only as a static
2092 method. See IO::Handle.
2093 .IP HANDLE\->format_page_number(EXPR) 8
2094 .IX Item "HANDLE->format_page_number(EXPR)"
2095 .PD 0
2096 .ie n .IP $FORMAT_PAGE_NUMBER 8
2097 .el .IP \f(CW$FORMAT_PAGE_NUMBER\fR 8
2098 .IX Item "$FORMAT_PAGE_NUMBER"
2099 .IP $% 8
2100 .IX Xref "$% $FORMAT_PAGE_NUMBER"
2101 .PD
2102 The current page number of the currently selected output channel.
2103 .Sp
2104 Mnemonic: \f(CW\*(C`%\*(C'\fR is page number in \fBnroff\fR.
2105 .IP HANDLE\->format_lines_left(EXPR) 8
2106 .IX Item "HANDLE->format_lines_left(EXPR)"
2107 .PD 0
2108 .ie n .IP $FORMAT_LINES_LEFT 8
2109 .el .IP \f(CW$FORMAT_LINES_LEFT\fR 8
2110 .IX Item "$FORMAT_LINES_LEFT"
2111 .IP $\- 8
2112 .IX Xref "$- $FORMAT_LINES_LEFT"
2113 .PD
2114 The number of lines left on the page of the currently selected output
2115 channel.
2116 .Sp
2117 Mnemonic: lines_on_page \- lines_printed.
2118 .IP "IO::Handle\->format_line_break_characters EXPR" 8
2119 .IX Item "IO::Handle->format_line_break_characters EXPR"
2120 .PD 0
2121 .ie n .IP $FORMAT_LINE_BREAK_CHARACTERS 8
2122 .el .IP \f(CW$FORMAT_LINE_BREAK_CHARACTERS\fR 8
2123 .IX Item "$FORMAT_LINE_BREAK_CHARACTERS"
2124 .ie n .IP $: 8
2125 .el .IP \f(CW$:\fR 8
2126 .IX Xref "$: FORMAT_LINE_BREAK_CHARACTERS"
2127 .IX Item "$:"
2128 .PD
2129 The current set of characters after which a string may be broken to
2130 fill continuation fields (starting with \f(CW\*(C`^\*(C'\fR) in a format. The default is
2131 "\ \en\-", to break on a space, newline, or a hyphen.
2132 .Sp
2133 You cannot call \f(CWformat_line_break_characters()\fR on a handle, only as
2134 a static method. See IO::Handle.
2135 .Sp
2136 Mnemonic: a "colon" in poetry is a part of a line.
2137 .IP HANDLE\->format_lines_per_page(EXPR) 8
2138 .IX Item "HANDLE->format_lines_per_page(EXPR)"
2139 .PD 0
2140 .ie n .IP $FORMAT_LINES_PER_PAGE 8
2141 .el .IP \f(CW$FORMAT_LINES_PER_PAGE\fR 8
2142 .IX Item "$FORMAT_LINES_PER_PAGE"
2143 .IP $= 8
2144 .IX Xref "$= $FORMAT_LINES_PER_PAGE"
2145 .PD
2146 The current page length (printable lines) of the currently selected
2147 output channel. The default is 60.
2148 .Sp
2149 Mnemonic: = has horizontal lines.
2150 .IP HANDLE\->format_top_name(EXPR) 8
2151 .IX Item "HANDLE->format_top_name(EXPR)"
2152 .PD 0
2153 .ie n .IP $FORMAT_TOP_NAME 8
2154 .el .IP \f(CW$FORMAT_TOP_NAME\fR 8
2155 .IX Item "$FORMAT_TOP_NAME"
2156 .IP $^ 8
2157 .IX Xref "$^ $FORMAT_TOP_NAME"
2158 .PD
2159 The name of the current top\-of\-page format for the currently selected
2160 output channel. The default is the name of the filehandle with \f(CW\*(C`_TOP\*(C'\fR
2161 appended. For example, the default format top name for the \f(CW\*(C`STDOUT\*(C'\fR
2162 filehandle is \f(CW\*(C`STDOUT_TOP\*(C'\fR.
2163 .Sp
2164 Mnemonic: points to top of page.
2165 .IP HANDLE\->format_name(EXPR) 8
2166 .IX Item "HANDLE->format_name(EXPR)"
2167 .PD 0
2168 .ie n .IP $FORMAT_NAME 8
2169 .el .IP \f(CW$FORMAT_NAME\fR 8
2170 .IX Item "$FORMAT_NAME"
2171 .IP $~ 8
2172 .IX Xref "$~ $FORMAT_NAME"
2173 .PD
2174 The name of the current report format for the currently selected
2175 output channel. The default format name is the same as the filehandle
2176 name. For example, the default format name for the \f(CW\*(C`STDOUT\*(C'\fR
2177 filehandle is just \f(CW\*(C`STDOUT\*(C'\fR.
2178 .Sp
2179 Mnemonic: brother to \f(CW$^\fR.
2180 .SS "Error Variables"
2181 .IX Xref "error exception"
2182 .IX Subsection "Error Variables"
2183 The variables \f(CW$@\fR, \f(CW$!\fR, \f(CW$^E\fR, and \f(CW$?\fR contain information
2184 about different types of error conditions that may appear during
2185 execution of a Perl program. The variables are shown ordered by
2186 the "distance" between the subsystem which reported the error and
2187 the Perl process. They correspond to errors detected by the Perl
2188 interpreter, C library, operating system, or an external program,
2189 respectively.
2190 .PP
2191 To illustrate the differences between these variables, consider the
2192 following Perl expression, which uses a single\-quoted string. After
2193 execution of this statement, perl may have set all four special error
2194 variables:
2195 .PP
2196 .Vb 5
2197 \& eval q{
2198 \& open my $pipe, "/cdrom/install |" or die $!;
2199 \& my @res = <$pipe>;
2200 \& close $pipe or die "bad pipe: $?, $!";
2201 \& };
2202 .Ve
2203 .PP
2204 When perl executes the \f(CWeval()\fR expression, it translates the
2205 \&\f(CWopen()\fR, \f(CW\*(C`<PIPE>\*(C'\fR, and \f(CW\*(C`close\*(C'\fR calls in the C run\-time library
2206 and thence to the operating system kernel. perl sets \f(CW$!\fR to
2207 the C library\*(Aqs \f(CW\*(C`errno\*(C'\fR if one of these calls fails.
2208 .PP
2209 \&\f(CW$@\fR is set if the string to be \f(CW\*(C`eval\*(C'\fR\-ed did not compile (this may
2210 happen if \f(CW\*(C`open\*(C'\fR or \f(CW\*(C`close\*(C'\fR were imported with bad prototypes), or
2211 if Perl code executed during evaluation \f(CWdie()\fRd. In these cases the
2212 value of \f(CW$@\fR is the compile error, or the argument to \f(CW\*(C`die\*(C'\fR (which
2213 will interpolate \f(CW$!\fR and \f(CW$?\fR). (See also Fatal, though.)
2214 .PP
2215 Under a few operating systems, \f(CW$^E\fR may contain a more verbose error
2216 indicator, such as in this case, "CDROM tray not closed." Systems that
2217 do not support extended error messages leave \f(CW$^E\fR the same as \f(CW$!\fR.
2218 .PP
2219 Finally, \f(CW$?\fR may be set to a non\-0 value if the external program
2220 \&\fI/cdrom/install\fR fails. The upper eight bits reflect specific error
2221 conditions encountered by the program (the program\*(Aqs \f(CWexit()\fR value).
2222 The lower eight bits reflect mode of failure, like signal death and
2223 core dump information. See \fBwait\fR\|(2) for details. In contrast to
2224 \&\f(CW$!\fR and \f(CW$^E\fR, which are set only if an error condition is detected,
2225 the variable \f(CW$?\fR is set on each \f(CW\*(C`wait\*(C'\fR or pipe \f(CW\*(C`close\*(C'\fR,
2226 overwriting the old value. This is more like \f(CW$@\fR, which on every
2227 \&\f(CWeval()\fR is always set on failure and cleared on success.
2228 .PP
2229 For more details, see the individual descriptions at \f(CW$@\fR, \f(CW$!\fR,
2230 \&\f(CW$^E\fR, and \f(CW$?\fR.
2231 .IP ${^CHILD_ERROR_NATIVE} 8
2232 .IX Xref "$^CHILD_ERROR_NATIVE"
2233 .IX Item "${^CHILD_ERROR_NATIVE}"
2234 The native status returned by the last pipe close, backtick (\f(CW\`\`\fR)
2235 command, successful call to \f(CWwait()\fR or \f(CWwaitpid()\fR, or from the
2236 \&\f(CWsystem()\fR operator. On POSIX\-like systems this value can be decoded
2237 with the WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, and
2238 WSTOPSIG functions provided by the POSIX module.
2239 .Sp
2240 Under VMS this reflects the actual VMS exit status; i.e. it is the
2241 same as \f(CW$?\fR when the pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR is in effect.
2242 .Sp
2243 This variable was added in Perl v5.10.0.
2244 .ie n .IP $EXTENDED_OS_ERROR 8
2245 .el .IP \f(CW$EXTENDED_OS_ERROR\fR 8
2246 .IX Item "$EXTENDED_OS_ERROR"
2247 .PD 0
2248 .IP $^E 8
2249 .IX Xref "$^E $EXTENDED_OS_ERROR"
2250 .IX Item "$^E"
2251 .PD
2252 Error information specific to the current operating system. At the
2253 moment, this differs from \f(CW"$!"\fR under only VMS, OS/2, and Win32 (and
2254 for MacPerl). On all other platforms, \f(CW$^E\fR is always just the same
2255 as \f(CW$!\fR.
2256 .Sp
2257 Under VMS, \f(CW$^E\fR provides the VMS status value from the last system
2258 error. This is more specific information about the last system error
2259 than that provided by \f(CW$!\fR. This is particularly important when \f(CW$!\fR
2260 is set to \fBEVMSERR\fR.
2261 .Sp
2262 Under OS/2, \f(CW$^E\fR is set to the error code of the last call to OS/2
2263 API either via CRT, or directly from perl.
2264 .Sp
2265 Under Win32, \f(CW$^E\fR always returns the last error information reported
2266 by the Win32 call \f(CWGetLastError()\fR which describes the last error
2267 from within the Win32 API. Most Win32\-specific code will report errors
2268 via \f(CW$^E\fR. ANSI C and Unix\-like calls set \f(CW\*(C`errno\*(C'\fR and so most
2269 portable Perl code will report errors via \f(CW$!\fR.
2270 .Sp
2271 Caveats mentioned in the description of \f(CW"$!"\fR generally apply to
2272 \&\f(CW$^E\fR, also.
2273 .Sp
2274 This variable was added in Perl 5.003.
2275 .Sp
2276 Mnemonic: Extra error explanation.
2277 .ie n .IP $EXCEPTIONS_BEING_CAUGHT 8
2278 .el .IP \f(CW$EXCEPTIONS_BEING_CAUGHT\fR 8
2279 .IX Item "$EXCEPTIONS_BEING_CAUGHT"
2280 .PD 0
2281 .IP $^S 8
2282 .IX Xref "$^S $EXCEPTIONS_BEING_CAUGHT"
2283 .IX Item "$^S"
2284 .PD
2285 Current state of the interpreter.
2286 .Sp
2287 .Vb 5
2288 \& $^S State
2289 \& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
2290 \& undef Parsing module, eval, or main program
2291 \& true (1) Executing an eval or try block
2292 \& false (0) Otherwise
2293 .Ve
2294 .Sp
2295 The first state may happen in \f(CW$SIG{_\|_DIE_\|_}\fR and \f(CW$SIG{_\|_WARN_\|_}\fR
2296 handlers.
2297 .Sp
2298 The English name \f(CW$EXCEPTIONS_BEING_CAUGHT\fR is slightly misleading, because
2299 the \f(CW\*(C`undef\*(C'\fR value does not indicate whether exceptions are being caught,
2300 since compilation of the main program does not catch exceptions.
2301 .Sp
2302 This variable was added in Perl 5.004.
2303 .ie n .IP $WARNING 8
2304 .el .IP \f(CW$WARNING\fR 8
2305 .IX Item "$WARNING"
2306 .PD 0
2307 .IP $^W 8
2308 .IX Xref "$^W $WARNING"
2309 .IX Item "$^W"
2310 .PD
2311 The current value of the warning switch, initially true if \fB\-w\fR was
2312 used, false otherwise, but directly modifiable.
2313 .Sp
2314 See also warnings.
2315 .Sp
2316 Mnemonic: related to the \fB\-w\fR switch.
2317 .IP ${^WARNING_BITS} 8
2318 .IX Xref "${^WARNING_BITS}"
2319 .IX Item "${^WARNING_BITS}"
2320 The current set of warning checks enabled by the \f(CW\*(C`use warnings\*(C'\fR pragma.
2321 It has the same scoping as the \f(CW$^H\fR and \f(CW\*(C`%^H\*(C'\fR variables. The exact
2322 values are considered internal to the warnings pragma and may change
2323 between versions of Perl.
2324 .Sp
2325 Each time a statement completes being compiled, the current value of
2326 \&\f(CW\*(C`${^WARNING_BITS}\*(C'\fR is stored with that statement, and can later be
2327 retrieved via \f(CW\*(C`(caller($level))[9]\*(C'\fR.
2328 .Sp
2329 This variable was added in Perl v5.6.0.
2330 .ie n .IP $OS_ERROR 8
2331 .el .IP \f(CW$OS_ERROR\fR 8
2332 .IX Item "$OS_ERROR"
2333 .PD 0
2334 .ie n .IP $ERRNO 8
2335 .el .IP \f(CW$ERRNO\fR 8
2336 .IX Item "$ERRNO"
2337 .IP $! 8
2338 .IX Xref "$! $ERRNO $OS_ERROR"
2339 .PD
2340 When referenced, \f(CW$!\fR retrieves the current value
2341 of the C \f(CW\*(C`errno\*(C'\fR integer variable.
2342 If \f(CW$!\fR is assigned a numerical value, that value is stored in \f(CW\*(C`errno\*(C'\fR.
2343 When referenced as a string, \f(CW$!\fR yields the system error string
2344 corresponding to \f(CW\*(C`errno\*(C'\fR.
2345 .Sp
2346 Many system or library calls set \f(CW\*(C`errno\*(C'\fR if they fail,
2347 to indicate the cause of failure. They usually do \fBnot\fR
2348 set \f(CW\*(C`errno\*(C'\fR to zero if they succeed and may set \f(CW\*(C`errno\*(C'\fR to a
2349 non\-zero value on success. This means \f(CW\*(C`errno\*(C'\fR, hence \f(CW$!\fR, is
2350 meaningful only \fIimmediately\fR after a \fBfailure\fR:
2351 .Sp
2352 .Vb 11
2353 \& if (open my $fh, "<", $filename) {
2354 \& # Here $! is meaningless.
2355 \& ...
2356 \& }
2357 \& else {
2358 \& # ONLY here is $! meaningful.
2359 \& ...
2360 \& # Already here $! might be meaningless.
2361 \& }
2362 \& # Since here we might have either success or failure,
2363 \& # $! is meaningless.
2364 .Ve
2365 .Sp
2366 Here, \fImeaningless\fR means that \f(CW$!\fR may be unrelated to the outcome
2367 of the \f(CWopen()\fR operator. Assignment to \f(CW$!\fR is similarly ephemeral.
2368 It can be used immediately before invoking the \f(CWdie()\fR operator,
2369 to set the exit value, or to inspect the system error string
2370 corresponding to error \fIn\fR, or to restore \f(CW$!\fR to a meaningful state.
2371 .Sp
2372 Perl itself may set \f(CW\*(C`errno\*(C'\fR to a non\-zero on failure even if no
2373 system call is performed.
2374 .Sp
2375 Mnemonic: What just went bang?
2376 .ie n .IP %OS_ERROR 8
2377 .el .IP \f(CW%OS_ERROR\fR 8
2378 .IX Item "%OS_ERROR"
2379 .PD 0
2380 .ie n .IP %ERRNO 8
2381 .el .IP \f(CW%ERRNO\fR 8
2382 .IX Item "%ERRNO"
2383 .IP %! 8
2384 .IX Xref "%! %OS_ERROR %ERRNO"
2385 .PD
2386 Each element of \f(CW\*(C`%!\*(C'\fR has a true value only if \f(CW$!\fR is set to that
2387 value. For example, \f(CW$!{ENOENT}\fR is true if and only if the current
2388 value of \f(CW$!\fR is \f(CW\*(C`ENOENT\*(C'\fR; that is, if the most recent error was "No
2389 such file or directory" (or its moral equivalent: not all operating
2390 systems give that exact error, and certainly not all languages). The
2391 specific true value is not guaranteed, but in the past has generally
2392 been the numeric value of \f(CW$!\fR. To check if a particular key is
2393 meaningful on your system, use \f(CW\*(C`exists $!{the_key}\*(C'\fR; for a list of legal
2394 keys, use \f(CW\*(C`keys %!\*(C'\fR. See Errno for more information, and also see
2395 "$!".
2396 .Sp
2397 This variable was added in Perl 5.005.
2398 .ie n .IP $CHILD_ERROR 8
2399 .el .IP \f(CW$CHILD_ERROR\fR 8
2400 .IX Item "$CHILD_ERROR"
2401 .PD 0
2402 .IP $? 8
2403 .IX Xref "$? $CHILD_ERROR"
2404 .PD
2405 The status returned by the last pipe close, backtick (\f(CW\`\`\fR) command,
2406 successful call to \f(CWwait()\fR or \f(CWwaitpid()\fR, or from the \f(CWsystem()\fR
2407 operator. This is just the 16\-bit status word returned by the
2408 traditional Unix \f(CWwait()\fR system call (or else is made up to look
2409 like it). Thus, the exit value of the subprocess is really (\f(CW$? >>
2410 8\fR), and \f(CW\*(C`$? & 127\*(C'\fR gives which signal, if any, the process died
2411 from, and \f(CW\*(C`$? & 128\*(C'\fR reports whether there was a core dump.
2412 .Sp
2413 Additionally, if the \f(CW\*(C`h_errno\*(C'\fR variable is supported in C, its value
2414 is returned via \f(CW$?\fR if any \f(CW\*(C`gethost*()\*(C'\fR function fails.
2415 .Sp
2416 If you have installed a signal handler for \f(CW\*(C`SIGCHLD\*(C'\fR, the
2417 value of \f(CW$?\fR will usually be wrong outside that handler.
2418 .Sp
2419 Inside an \f(CW\*(C`END\*(C'\fR subroutine \f(CW$?\fR contains the value that is going to be
2420 given to \f(CWexit()\fR. You can modify \f(CW$?\fR in an \f(CW\*(C`END\*(C'\fR subroutine to
2421 change the exit status of your program. For example:
2422 .Sp
2423 .Vb 3
2424 \& END {
2425 \& $? = 1 if $? == 255; # die would make it 255
2426 \& }
2427 .Ve
2428 .Sp
2429 Under VMS, the pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR makes \f(CW$?\fR reflect the
2430 actual VMS exit status, instead of the default emulation of POSIX
2431 status; see "$?" in perlvms for details.
2432 .Sp
2433 Mnemonic: similar to \fBsh\fR and \fBksh\fR.
2434 .ie n .IP $EVAL_ERROR 8
2435 .el .IP \f(CW$EVAL_ERROR\fR 8
2436 .IX Item "$EVAL_ERROR"
2437 .PD 0
2438 .IP $@ 8
2439 .IX Xref "$@ $EVAL_ERROR"
2440 .PD
2441 The Perl error from the last \f(CW\*(C`eval\*(C'\fR operator, i.e. the last exception that
2442 was caught. For \f(CW\*(C`eval BLOCK\*(C'\fR, this is either a runtime error message or the
2443 string or reference \f(CW\*(C`die\*(C'\fR was called with. The \f(CW\*(C`eval STRING\*(C'\fR form also
2444 catches syntax errors and other compile time exceptions.
2445 .Sp
2446 If no error occurs, \f(CW\*(C`eval\*(C'\fR sets \f(CW$@\fR to the empty string.
2447 .Sp
2448 Warning messages are not collected in this variable. You can, however,
2449 set up a routine to process warnings by setting \f(CW$SIG{_\|_WARN_\|_}\fR as
2450 described in "%SIG".
2451 .Sp
2452 Mnemonic: Where was the error "at"?
2453 .SS "Variables related to the interpreter state"
2454 .IX Subsection "Variables related to the interpreter state"
2455 These variables provide information about the current interpreter state.
2456 .ie n .IP $COMPILING 8
2457 .el .IP \f(CW$COMPILING\fR 8
2458 .IX Item "$COMPILING"
2459 .PD 0
2460 .IP $^C 8
2461 .IX Xref "$^C $COMPILING"
2462 .IX Item "$^C"
2463 .PD
2464 The current value of the flag associated with the \fB\-c\fR switch.
2465 Mainly of use with \fB\-MO=...\fR to allow code to alter its behavior
2466 when being compiled, such as for example to \f(CW\*(C`AUTOLOAD\*(C'\fR at compile
2467 time rather than normal, deferred loading. Setting
2468 \&\f(CW\*(C`$^C = 1\*(C'\fR is similar to calling \f(CW\*(C`B::minus_c\*(C'\fR.
2469 .Sp
2470 This variable was added in Perl v5.6.0.
2471 .ie n .IP $DEBUGGING 8
2472 .el .IP \f(CW$DEBUGGING\fR 8
2473 .IX Item "$DEBUGGING"
2474 .PD 0
2475 .IP $^D 8
2476 .IX Xref "$^D $DEBUGGING"
2477 .IX Item "$^D"
2478 .PD
2479 The current value of the debugging flags. May be read or set. Like its
2480 command\-line equivalent, you can use numeric
2481 or symbolic values, e.g. \f(CW\*(C`$^D = 10\*(C'\fR or \f(CW\*(C`$^D = "st"\*(C'\fR. See
2482 "\fB\-D\fR\fInumber\fR" in perlrun. The contents of this variable also affects the
2483 debugger operation. See "Debugger Internals" in perldebguts.
2484 .Sp
2485 Mnemonic: value of \fB\-D\fR switch.
2486 .IP ${^GLOBAL_PHASE} 8
2487 .IX Xref "${^GLOBAL_PHASE}"
2488 .IX Item "${^GLOBAL_PHASE}"
2489 The current phase of the perl interpreter.
2490 .Sp
2491 Possible values are:
2492 .RS 8
2493 .IP CONSTRUCT 8
2494 .IX Item "CONSTRUCT"
2495 The \f(CW\*(C`PerlInterpreter*\*(C'\fR is being constructed via \f(CW\*(C`perl_construct\*(C'\fR. This
2496 value is mostly there for completeness and for use via the
2497 underlying C variable \f(CW\*(C`PL_phase\*(C'\fR. It\*(Aqs not really possible for Perl
2498 code to be executed unless construction of the interpreter is
2499 finished.
2500 .IP START 8
2501 .IX Item "START"
2502 This is the global compile\-time. That includes, basically, every
2503 \&\f(CW\*(C`BEGIN\*(C'\fR block executed directly or indirectly from during the
2504 compile\-time of the top\-level program.
2505 .Sp
2506 This phase is not called "BEGIN" to avoid confusion with
2507 \&\f(CW\*(C`BEGIN\*(C'\fR\-blocks, as those are executed during compile\-time of any
2508 compilation unit, not just the top\-level program. A new, localised
2509 compile\-time entered at run\-time, for example by constructs as
2510 \&\f(CW\*(C`eval "use SomeModule"\*(C'\fR are not global interpreter phases, and
2511 therefore aren\*(Aqt reflected by \f(CW\*(C`${^GLOBAL_PHASE}\*(C'\fR.
2512 .IP CHECK 8
2513 .IX Item "CHECK"
2514 Execution of any \f(CW\*(C`CHECK\*(C'\fR blocks.
2515 .IP INIT 8
2516 .IX Item "INIT"
2517 Similar to "CHECK", but for \f(CW\*(C`INIT\*(C'\fR\-blocks, not \f(CW\*(C`CHECK\*(C'\fR blocks.
2518 .IP RUN 8
2519 .IX Item "RUN"
2520 The main run\-time, i.e. the execution of \f(CW\*(C`PL_main_root\*(C'\fR.
2521 .IP END 8
2522 .IX Item "END"
2523 Execution of any \f(CW\*(C`END\*(C'\fR blocks.
2524 .IP DESTRUCT 8
2525 .IX Item "DESTRUCT"
2526 Global destruction.
2527 .RE
2528 .RS 8
2529 .Sp
2530 Also note that there\*(Aqs no value for UNITCHECK\-blocks. That\*(Aqs because
2531 those are run for each compilation unit individually, and therefore is
2532 not a global interpreter phase.
2533 .Sp
2534 Not every program has to go through each of the possible phases, but
2535 transition from one phase to another can only happen in the order
2536 described in the above list.
2537 .Sp
2538 An example of all of the phases Perl code can see:
2539 .Sp
2540 .Vb 1
2541 \& BEGIN { print "compile\-time: ${^GLOBAL_PHASE}\en" }
2542 \&
2543 \& INIT { print "init\-time: ${^GLOBAL_PHASE}\en" }
2544 \&
2545 \& CHECK { print "check\-time: ${^GLOBAL_PHASE}\en" }
2546 \&
2547 \& {
2548 \& package Print::Phase;
2549 \&
2550 \& sub new {
2551 \& my ($class, $time) = @_;
2552 \& return bless \e$time, $class;
2553 \& }
2554 \&
2555 \& sub DESTROY {
2556 \& my $self = shift;
2557 \& print "$$self: ${^GLOBAL_PHASE}\en";
2558 \& }
2559 \& }
2560 \&
2561 \& print "run\-time: ${^GLOBAL_PHASE}\en";
2562 \&
2563 \& my $runtime = Print::Phase\->new(
2564 \& "lexical variables are garbage collected before END"
2565 \& );
2566 \&
2567 \& END { print "end\-time: ${^GLOBAL_PHASE}\en" }
2568 \&
2569 \& our $destruct = Print::Phase\->new(
2570 \& "package variables are garbage collected after END"
2571 \& );
2572 .Ve
2573 .Sp
2574 This will print out
2575 .Sp
2576 .Vb 7
2577 \& compile\-time: START
2578 \& check\-time: CHECK
2579 \& init\-time: INIT
2580 \& run\-time: RUN
2581 \& lexical variables are garbage collected before END: RUN
2582 \& end\-time: END
2583 \& package variables are garbage collected after END: DESTRUCT
2584 .Ve
2585 .Sp
2586 This variable was added in Perl 5.14.0.
2587 .RE
2588 .IP $^H 8
2589 .IX Xref "$^H"
2590 .IX Item "$^H"
2591 WARNING: This variable is strictly for
2592 internal use only. Its availability,
2593 behavior, and contents are subject to change without notice.
2594 .Sp
2595 This variable contains compile\-time hints for the Perl interpreter. At the
2596 end of compilation of a BLOCK the value of this variable is restored to the
2597 value when the interpreter started to compile the BLOCK.
2598 .Sp
2599 Each time a statement completes being compiled, the current value of
2600 \&\f(CW$^H\fR is stored with that statement, and can later be retrieved via
2601 \&\f(CW\*(C`(caller($level))[8]\*(C'\fR. See "caller EXPR" in perlfunc.
2602 .Sp
2603 When perl begins to parse any block construct that provides a lexical scope
2604 (e.g., eval body, required file, subroutine body, loop body, or conditional
2605 block), the existing value of \f(CW$^H\fR is saved, but its value is left unchanged.
2606 When the compilation of the block is completed, it regains the saved value.
2607 Between the points where its value is saved and restored, code that
2608 executes within BEGIN blocks is free to change the value of \f(CW$^H\fR.
2609 .Sp
2610 This behavior provides the semantic of lexical scoping, and is used in,
2611 for instance, the \f(CW\*(C`use strict\*(C'\fR pragma.
2612 .Sp
2613 The contents should be an integer; different bits of it are used for
2614 different pragmatic flags. Here\*(Aqs an example:
2615 .Sp
2616 .Vb 1
2617 \& sub add_100 { $^H |= 0x100 }
2618 \&
2619 \& sub foo {
2620 \& BEGIN { add_100() }
2621 \& bar\->baz($boon);
2622 \& }
2623 .Ve
2624 .Sp
2625 Consider what happens during execution of the BEGIN block. At this point
2626 the BEGIN block has already been compiled, but the body of \f(CWfoo()\fR is still
2627 being compiled. The new value of \f(CW$^H\fR
2628 will therefore be visible only while
2629 the body of \f(CWfoo()\fR is being compiled.
2630 .Sp
2631 Substitution of \f(CW\*(C`BEGIN { add_100() }\*(C'\fR block with:
2632 .Sp
2633 .Vb 1
2634 \& BEGIN { require strict; strict\->import(\*(Aqvars\*(Aq) }
2635 .Ve
2636 .Sp
2637 demonstrates how \f(CW\*(C`use strict \*(Aqvars\*(Aq\*(C'\fR is implemented. Here\*(Aqs a conditional
2638 version of the same lexical pragma:
2639 .Sp
2640 .Vb 3
2641 \& BEGIN {
2642 \& require strict; strict\->import(\*(Aqvars\*(Aq) if $condition
2643 \& }
2644 .Ve
2645 .Sp
2646 This variable was added in Perl 5.003.
2647 .IP %^H 8
2648 .IX Xref "%^H"
2649 .IX Item "%^H"
2650 The \f(CW\*(C`%^H\*(C'\fR hash provides the same scoping semantics as \f(CW$^H\fR. This
2651 makes it useful for implementing lexically scoped pragmas. See perlpragma.
2652 All the entries are stringified when accessed at runtime, so only simple values
2653 can be accommodated. This means no references to objects, for example.
2654 .Sp
2655 Each time a statement completes being compiled, the current value of
2656 \&\f(CW\*(C`%^H\*(C'\fR is stored with that statement, and can later be retrieved via
2657 \&\f(CW\*(C`(caller($level))[10]\*(C'\fR. See "caller EXPR" in perlfunc.
2658 .Sp
2659 When putting items into \f(CW\*(C`%^H\*(C'\fR, in order to avoid conflicting with other
2660 users of the hash there is a convention regarding which keys to use.
2661 A module should use only keys that begin with the module\*(Aqs name (the
2662 name of its main package) and a "/" character. For example, a module
2663 \&\f(CW\*(C`Foo::Bar\*(C'\fR should use keys such as \f(CW\*(C`Foo::Bar/baz\*(C'\fR.
2664 .Sp
2665 This variable was added in Perl v5.6.0.
2666 .IP ${^OPEN} 8
2667 .IX Xref "${^OPEN}"
2668 .IX Item "${^OPEN}"
2669 An internal variable used by PerlIO. A string in two parts, separated
2670 by a \f(CW\*(C`\e0\*(C'\fR byte, the first part describes the input layers, the second
2671 part describes the output layers.
2672 .Sp
2673 This is the mechanism that applies the lexical effects of the open
2674 pragma, and the main program scope effects of the \f(CW\*(C`io\*(C'\fR or \f(CW\*(C`D\*(C'\fR options
2675 for the \-C command\-line switch and
2676 PERL_UNICODE environment variable.
2677 .Sp
2678 The functions \f(CWaccept()\fR, \f(CWopen()\fR, \f(CWpipe()\fR, \f(CWreadpipe()\fR (as well
2679 as the related \f(CW\*(C`qx\*(C'\fR and \f(CW\`STRING\`\fR operators), \f(CWsocket()\fR,
2680 \&\f(CWsocketpair()\fR, and \f(CWsysopen()\fR are affected by the lexical value of
2681 this variable. The implicit "ARGV" handle opened by \f(CWreadline()\fR (or
2682 the related \f(CW\*(C`<>\*(C'\fR (diamond) and \f(CW\*(C`<<>>\*(C'\fR (double diamond)
2683 operators) on passed filenames is
2684 also affected (but not if it opens \f(CW\*(C`STDIN\*(C'\fR). If this variable is not
2685 set, these functions will set the default layers as described in
2686 "Defaults and how to override them" in PerlIO.
2687 .Sp
2688 \&\f(CWopen()\fR ignores this variable (and the default layers) when called with
2689 3 arguments and explicit layers are specified. Indirect calls to these
2690 functions via modules like IO::Handle are not affected as they occur
2691 in a different lexical scope. Directory handles such as opened by
2692 \&\f(CWopendir()\fR are not currently affected.
2693 .Sp
2694 This variable was added in Perl v5.8.0.
2695 .ie n .IP $PERLDB 8
2696 .el .IP \f(CW$PERLDB\fR 8
2697 .IX Item "$PERLDB"
2698 .PD 0
2699 .IP $^P 8
2700 .IX Xref "$^P $PERLDB"
2701 .IX Item "$^P"
2702 .PD
2703 The internal variable for debugging support. The meanings of the
2704 various bits are subject to change, but currently indicate:
2705 .RS 8
2706 .IP 0x01 6
2707 .IX Item "0x01"
2708 Debug subroutine enter/exit.
2709 .IP 0x02 6
2710 .IX Item "0x02"
2711 Line\-by\-line debugging. Causes \f(CWDB::DB()\fR subroutine to be called for
2712 each statement executed. Also causes saving source code lines (like
2713 0x400).
2714 .IP 0x04 6
2715 .IX Item "0x04"
2716 Switch off optimizations.
2717 .IP 0x08 6
2718 .IX Item "0x08"
2719 Preserve more data for future interactive inspections.
2720 .IP 0x10 6
2721 .IX Item "0x10"
2722 Keep info about source lines on which a subroutine is defined.
2723 .IP 0x20 6
2724 .IX Item "0x20"
2725 Start with single\-step on.
2726 .IP 0x40 6
2727 .IX Item "0x40"
2728 Use subroutine address instead of name when reporting.
2729 .IP 0x80 6
2730 .IX Item "0x80"
2731 Report \f(CW\*(C`goto &subroutine\*(C'\fR as well.
2732 .IP 0x100 6
2733 .IX Item "0x100"
2734 Provide informative "file" names for evals based on the place they were compiled.
2735 .IP 0x200 6
2736 .IX Item "0x200"
2737 Provide informative names to anonymous subroutines based on the place they
2738 were compiled.
2739 .IP 0x400 6
2740 .IX Item "0x400"
2741 Save source code lines into \f(CW\*(C`@{"_<$filename"}\*(C'\fR.
2742 .IP 0x800 6
2743 .IX Item "0x800"
2744 When saving source, include evals that generate no subroutines.
2745 .IP 0x1000 6
2746 .IX Item "0x1000"
2747 When saving source, include source that did not compile.
2748 .RE
2749 .RS 8
2750 .Sp
2751 Some bits may be relevant at compile\-time only, some at
2752 run\-time only. This is a new mechanism and the details may change.
2753 See also perldebguts.
2754 .RE
2755 .IP ${^TAINT} 8
2756 .IX Xref "${^TAINT}"
2757 .IX Item "${^TAINT}"
2758 Reflects if taint mode is on or off. 1 for on (the program was run with
2759 \&\fB\-T\fR), 0 for off, \-1 when only taint warnings are enabled (i.e. with
2760 \&\fB\-t\fR or \fB\-TU\fR).
2761 .Sp
2762 Note: if your perl was built without taint support (see perlsec),
2763 then \f(CW\*(C`${^TAINT}\*(C'\fR will always be 0, even if the program was run with \fB\-T\fR).
2764 .Sp
2765 This variable is read\-only.
2766 .Sp
2767 This variable was added in Perl v5.8.0.
2768 .IP ${^SAFE_LOCALES} 8
2769 .IX Xref "${^SAFE_LOCALES}"
2770 .IX Item "${^SAFE_LOCALES}"
2771 Reflects if safe locale operations are available to this perl (when the
2772 value is 1) or not (the value is 0). This variable is always 1 if the
2773 perl has been compiled without threads. It is also 1 if this perl is
2774 using thread\-safe locale operations. Note that an individual thread may
2775 choose to use the global locale (generally unsafe) by calling
2776 "switch_to_global_locale" in perlapi. This variable currently is still
2777 set to 1 in such threads.
2778 .Sp
2779 This variable is read\-only.
2780 .Sp
2781 This variable was added in Perl v5.28.0.
2782 .IP ${^UNICODE} 8
2783 .IX Xref "${^UNICODE}"
2784 .IX Item "${^UNICODE}"
2785 Reflects certain Unicode settings of Perl. See
2786 perlrun documentation for the \f(CW\*(C`\-C\*(C'\fR
2787 switch for more information about the possible values.
2788 .Sp
2789 This variable is set during Perl startup and is thereafter read\-only.
2790 .Sp
2791 This variable was added in Perl v5.8.2.
2792 .IP ${^UTF8CACHE} 8
2793 .IX Xref "${^UTF8CACHE}"
2794 .IX Item "${^UTF8CACHE}"
2795 This variable controls the state of the internal UTF\-8 offset caching code.
2796 1 for on (the default), 0 for off, \-1 to debug the caching code by checking
2797 all its results against linear scans, and panicking on any discrepancy.
2798 .Sp
2799 This variable was added in Perl v5.8.9. It is subject to change or
2800 removal without notice, but is currently used to avoid recalculating the
2801 boundaries of multi\-byte UTF\-8\-encoded characters.
2802 .IP ${^UTF8LOCALE} 8
2803 .IX Xref "${^UTF8LOCALE}"
2804 .IX Item "${^UTF8LOCALE}"
2805 This variable indicates whether a UTF\-8 locale was detected by perl at
2806 startup. This information is used by perl when it\*(Aqs in
2807 adjust\-utf8ness\-to\-locale mode (as when run with the \f(CW\*(C`\-CL\*(C'\fR command\-line
2808 switch); see perlrun for more info on
2809 this.
2810 .Sp
2811 This variable was added in Perl v5.8.8.
2812 .SS "Deprecated and removed variables"
2813 .IX Subsection "Deprecated and removed variables"
2814 Deprecating a variable announces the intent of the perl maintainers to
2815 eventually remove the variable from the language. It may still be
2816 available despite its status. Using a deprecated variable triggers
2817 a warning.
2818 .PP
2819 Once a variable is removed, its use triggers an error telling you
2820 the variable is unsupported.
2821 .PP
2822 See perldiag for details about error messages.
2823 .IP $# 8
2824 .IX Xref "$#"
2825 \&\f(CW$#\fR was a variable that could be used to format printed numbers.
2826 After a deprecation cycle, its magic was removed in Perl v5.10.0 and
2827 using it now triggers a compilation error: \f(CW\*(C`$# is no longer supported\*(C'\fR.
2828 .Sp
2829 This is not the sigil you use in front of an array name to get the
2830 last index, like \f(CW$#array\fR. That\*(Aqs still how you get the last index
2831 of an array in Perl. (See "Arrays" in perlintro.)
2832 The two have nothing to do with each other.
2833 .Sp
2834 Deprecated in Perl 5.
2835 .Sp
2836 Removed in Perl v5.10.0.
2837 .IP $* 8
2838 .IX Xref "$*"
2839 \&\f(CW$*\fR was a variable that you could use to enable multiline matching.
2840 After a deprecation cycle, its magic was removed in Perl v5.10.0.
2841 Using it now triggers a compilation error: \f(CW\*(C`$* is no longer supported\*(C'\fR.
2842 You should use the \f(CW\*(C`/s\*(C'\fR and \f(CW\*(C`/m\*(C'\fR regexp modifiers instead.
2843 .Sp
2844 Deprecated in Perl 5.
2845 .Sp
2846 Removed in Perl v5.10.0.
2847 .IP $[ 8
2848 .IX Xref "$["
2849 This variable stores the index of the first element in an array, and
2850 of the first character in a substring. The default is 0, but you could
2851 theoretically set it to 1 to make Perl behave more like \fBawk\fR (or Fortran)
2852 when subscripting and when evaluating the \fBindex()\fR and \fBsubstr()\fR functions.
2853 .Sp
2854 As of release 5 of Perl, assignment to \f(CW$[\fR is treated as a compiler
2855 directive, and cannot influence the behavior of any other file.
2856 (That\*(Aqs why you can only assign compile\-time constants to it.)
2857 Its use is highly discouraged.
2858 .Sp
2859 Prior to Perl v5.10.0, assignment to \f(CW$[\fR could be seen from outer lexical
2860 scopes in the same file, unlike other compile\-time directives (such as
2861 strict). Using \fBlocal()\fR on it would bind its value strictly to a lexical
2862 block. Now it is always lexically scoped.
2863 .Sp
2864 As of Perl v5.16.0, it is implemented by the arybase module.
2865 .Sp
2866 As of Perl v5.30.0, or under \f(CW\*(C`use v5.16\*(C'\fR, or \f(CW\*(C`no feature "array_base"\*(C'\fR,
2867 \&\f(CW$[\fR no longer has any effect, and always contains 0.
2868 Assigning 0 to it is permitted, but any other value will produce an error.
2869 .Sp
2870 Mnemonic: [ begins subscripts.
2871 .Sp
2872 Deprecated in Perl v5.12.0.
2873 .IP ${^ENCODING} 8
2874 .IX Xref "${^ENCODING}"
2875 .IX Item "${^ENCODING}"
2876 This variable is no longer supported.
2877 .Sp
2878 It used to hold the \fIobject reference\fR to the \f(CW\*(C`Encode\*(C'\fR object that was
2879 used to convert the source code to Unicode.
2880 .Sp
2881 Its purpose was to allow your non\-ASCII Perl
2882 scripts not to have to be written in UTF\-8; this was
2883 useful before editors that worked on UTF\-8 encoded text were common, but
2884 that was long ago. It caused problems, such as affecting the operation
2885 of other modules that weren\*(Aqt expecting it, causing general mayhem.
2886 .Sp
2887 If you need something like this functionality, it is recommended that use
2888 you a simple source filter, such as Filter::Encoding.
2889 .Sp
2890 If you are coming here because code of yours is being adversely affected
2891 by someone\*(Aqs use of this variable, you can usually work around it by
2892 doing this:
2893 .Sp
2894 .Vb 1
2895 \& local ${^ENCODING};
2896 .Ve
2897 .Sp
2898 near the beginning of the functions that are getting broken. This
2899 undefines the variable during the scope of execution of the including
2900 function.
2901 .Sp
2902 This variable was added in Perl 5.8.2 and removed in 5.26.0.
2903 Setting it to anything other than \f(CW\*(C`undef\*(C'\fR was made fatal in Perl 5.28.0.
2904 .IP ${^WIN32_SLOPPY_STAT} 8
2905 .IX Xref "${^WIN32_SLOPPY_STAT} sitecustomize sitecustomize.pl"
2906 .IX Item "${^WIN32_SLOPPY_STAT}"
2907 This variable no longer has any function.
2908 .Sp
2909 This variable was added in Perl v5.10.0 and removed in Perl v5.34.0.