1PERLVAR(1)             Perl Programmers Reference Guide             PERLVAR(1)
2
3
4

NAME

6       perlvar - Perl predefined variables
7

DESCRIPTION

9       Predefined Names
10
11       The following names have special meaning to Perl.  Most punctuation
12       names have reasonable mnemonics, or analogs in the shells.  Neverthe‐
13       less, if you wish to use long variable names, you need only say
14
15           use English;
16
17       at the top of your program. This aliases all the short names to the
18       long names in the current package. Some even have medium names, gener‐
19       ally borrowed from awk. In general, it's best to use the
20
21           use English '-no_match_vars';
22
23       invocation if you don't need $PREMATCH, $MATCH, or $POSTMATCH, as it
24       avoids a certain performance hit with the use of regular expressions.
25       See English.
26
27       Variables that depend on the currently selected filehandle may be set
28       by calling an appropriate object method on the IO::Handle object,
29       although this is less efficient than using the regular built-in vari‐
30       ables. (Summary lines below for this contain the word HANDLE.) First
31       you must say
32
33           use IO::Handle;
34
35       after which you may use either
36
37           method HANDLE EXPR
38
39       or more safely,
40
41           HANDLE->method(EXPR)
42
43       Each method returns the old value of the IO::Handle attribute.  The
44       methods each take an optional EXPR, which, if supplied, specifies the
45       new value for the IO::Handle attribute in question.  If not supplied,
46       most methods do nothing to the current value--except for autoflush(),
47       which will assume a 1 for you, just to be different.
48
49       Because loading in the IO::Handle class is an expensive operation, you
50       should learn how to use the regular built-in variables.
51
52       A few of these variables are considered "read-only".  This means that
53       if you try to assign to this variable, either directly or indirectly
54       through a reference, you'll raise a run-time exception.
55
56       You should be very careful when modifying the default values of most
57       special variables described in this document. In most cases you want to
58       localize these variables before changing them, since if you don't, the
59       change may affect other modules which rely on the default values of the
60       special variables that you have changed. This is one of the correct
61       ways to read the whole file at once:
62
63           open my $fh, "foo" or die $!;
64           local $/; # enable localized slurp mode
65           my $content = <$fh>;
66           close $fh;
67
68       But the following code is quite bad:
69
70           open my $fh, "foo" or die $!;
71           undef $/; # enable slurp mode
72           my $content = <$fh>;
73           close $fh;
74
75       since some other module, may want to read data from some file in the
76       default "line mode", so if the code we have just presented has been
77       executed, the global value of $/ is now changed for any other code run‐
78       ning inside the same Perl interpreter.
79
80       Usually when a variable is localized you want to make sure that this
81       change affects the shortest scope possible. So unless you are already
82       inside some short "{}" block, you should create one yourself. For exam‐
83       ple:
84
85           my $content = '';
86           open my $fh, "foo" or die $!;
87           {
88               local $/;
89               $content = <$fh>;
90           }
91           close $fh;
92
93       Here is an example of how your own code can go broken:
94
95           for (1..5){
96               nasty_break();
97               print "$_ ";
98           }
99           sub nasty_break {
100               $_ = 5;
101               # do something with $_
102           }
103
104       You probably expect this code to print:
105
106           1 2 3 4 5
107
108       but instead you get:
109
110           5 5 5 5 5
111
112       Why? Because nasty_break() modifies $_ without localizing it first. The
113       fix is to add local():
114
115               local $_ = 5;
116
117       It's easy to notice the problem in such a short example, but in more
118       complicated code you are looking for trouble if you don't localize
119       changes to the special variables.
120
121       The following list is ordered by scalar variables first, then the
122       arrays, then the hashes.
123
124       $ARG
125       $_      The default input and pattern-searching space.  The following
126               pairs are equivalent:
127
128                   while (<>) {...}    # equivalent only in while!
129                   while (defined($_ = <>)) {...}
130
131                   /^Subject:/
132                   $_ =~ /^Subject:/
133
134                   tr/a-z/A-Z/
135                   $_ =~ tr/a-z/A-Z/
136
137                   chomp
138                   chomp($_)
139
140               Here are the places where Perl will assume $_ even if you don't
141               use it:
142
143               *  Various unary functions, including functions like ord() and
144                  int(), as well as the all file tests ("-f", "-d") except for
145                  "-t", which defaults to STDIN.
146
147               *  Various list functions like print() and unlink().
148
149               *  The pattern matching operations "m//", "s///", and "tr///"
150                  when used without an "=~" operator.
151
152               *  The default iterator variable in a "foreach" loop if no
153                  other variable is supplied.
154
155               *  The implicit iterator variable in the grep() and map() func‐
156                  tions.
157
158               *  The default place to put an input record when a "<FH>" oper‐
159                  ation's result is tested by itself as the sole criterion of
160                  a "while" test.  Outside a "while" test, this will not hap‐
161                  pen.
162
163               (Mnemonic: underline is understood in certain operations.)
164
165       $a
166       $b      Special package variables when using sort(), see "sort" in
167               perlfunc.  Because of this specialness $a and $b don't need to
168               be declared (using use vars, or our()) even when using the
169               "strict 'vars'" pragma.  Don't lexicalize them with "my $a" or
170               "my $b" if you want to be able to use them in the sort() com‐
171               parison block or function.
172
173       $<digits>
174               Contains the subpattern from the corresponding set of capturing
175               parentheses from the last pattern match, not counting patterns
176               matched in nested blocks that have been exited already.
177               (Mnemonic: like \digits.)  These variables are all read-only
178               and dynamically scoped to the current BLOCK.
179
180       $MATCH
181       $&      The string matched by the last successful pattern match (not
182               counting any matches hidden within a BLOCK or eval() enclosed
183               by the current BLOCK).  (Mnemonic: like & in some editors.)
184               This variable is read-only and dynamically scoped to the cur‐
185               rent BLOCK.
186
187               The use of this variable anywhere in a program imposes a con‐
188               siderable performance penalty on all regular expression
189               matches.  See "BUGS".
190
191       $PREMATCH
192       $`      The string preceding whatever was matched by the last success‐
193               ful pattern match (not counting any matches hidden within a
194               BLOCK or eval enclosed by the current BLOCK).  (Mnemonic: "`"
195               often precedes a quoted string.)  This variable is read-only.
196
197               The use of this variable anywhere in a program imposes a con‐
198               siderable performance penalty on all regular expression
199               matches.  See "BUGS".
200
201       $POSTMATCH
202       $'      The string following whatever was matched by the last success‐
203               ful pattern match (not counting any matches hidden within a
204               BLOCK or eval() enclosed by the current BLOCK).  (Mnemonic: "'"
205               often follows a quoted string.)  Example:
206
207                   local $_ = 'abcdefghi';
208                   /def/;
209                   print "$`:$&:$'\n";         # prints abc:def:ghi
210
211               This variable is read-only and dynamically scoped to the cur‐
212               rent BLOCK.
213
214               The use of this variable anywhere in a program imposes a con‐
215               siderable performance penalty on all regular expression
216               matches.  See "BUGS".
217
218       $LAST_PAREN_MATCH
219       $+      The text matched by the last bracket of the last successful
220               search pattern.  This is useful if you don't know which one of
221               a set of alternative patterns matched. For example:
222
223                   /Version: (.*)⎪Revision: (.*)/ && ($rev = $+);
224
225               (Mnemonic: be positive and forward looking.)  This variable is
226               read-only and dynamically scoped to the current BLOCK.
227
228       $^N     The text matched by the used group most-recently closed (i.e.
229               the group with the rightmost closing parenthesis) of the last
230               successful search pattern.  (Mnemonic: the (possibly) Nested
231               parenthesis that most recently closed.)
232
233               This is primarily used inside "(?{...})" blocks for examining
234               text recently matched. For example, to effectively capture text
235               to a variable (in addition to $1, $2, etc.), replace "(...)"
236               with
237
238                    (?:(...)(?{ $var = $^N }))
239
240               By setting and then using $var in this way relieves you from
241               having to worry about exactly which numbered set of parentheses
242               they are.
243
244               This variable is dynamically scoped to the current BLOCK.
245
246       @LAST_MATCH_END
247       @+      This array holds the offsets of the ends of the last successful
248               submatches in the currently active dynamic scope.  $+[0] is the
249               offset into the string of the end of the entire match.  This is
250               the same value as what the "pos" function returns when called
251               on the variable that was matched against.  The nth element of
252               this array holds the offset of the nth submatch, so $+[1] is
253               the offset past where $1 ends, $+[2] the offset past where $2
254               ends, and so on.  You can use $#+ to determine how many sub‐
255               groups were in the last successful match.  See the examples
256               given for the "@-" variable.
257
258       $*      Set to a non-zero integer value to do multi-line matching
259               within a string, 0 (or undefined) to tell Perl that it can
260               assume that strings contain a single line, for the purpose of
261               optimizing pattern matches.  Pattern matches on strings con‐
262               taining multiple newlines can produce confusing results when $*
263               is 0 or undefined. Default is undefined.  (Mnemonic: * matches
264               multiple things.) This variable influences the interpretation
265               of only "^" and "$". A literal newline can be searched for even
266               when "$* == 0".
267
268               Use of $* is deprecated in modern Perl, supplanted by the "/s"
269               and "/m" modifiers on pattern matching.
270
271               Assigning a non-numerical value to $* triggers a warning (and
272               makes $* act if "$* == 0"), while assigning a numerical value
273               to $* makes that an implicit "int" is applied on the value.
274
275       HANDLE->input_line_number(EXPR)
276       $INPUT_LINE_NUMBER
277       $NR
278       $.      Current line number for the last filehandle accessed.
279
280               Each filehandle in Perl counts the number of lines that have
281               been read from it.  (Depending on the value of $/, Perl's idea
282               of what constitutes a line may not match yours.)  When a line
283               is read from a filehandle (via readline() or "<>"), or when
284               tell() or seek() is called on it, $. becomes an alias to the
285               line counter for that filehandle.
286
287               You can adjust the counter by assigning to $., but this will
288               not actually move the seek pointer.  Localizing $. will not
289               localize the filehandle's line count.  Instead, it will local‐
290               ize perl's notion of which filehandle $. is currently aliased
291               to.
292
293               $. is reset when the filehandle is closed, but not when an open
294               filehandle is reopened without an intervening close().  For
295               more details, see "I/O Operators" in perlop.  Because "<>"
296               never does an explicit close, line numbers increase across ARGV
297               files (but see examples in "eof" in perlfunc).
298
299               You can also use "HANDLE->input_line_number(EXPR)" to access
300               the line counter for a given filehandle without having to worry
301               about which handle you last accessed.
302
303               (Mnemonic: many programs use "." to mean the current line num‐
304               ber.)
305
306       IO::Handle->input_record_separator(EXPR)
307       $INPUT_RECORD_SEPARATOR
308       $RS
309       $/      The input record separator, newline by default.  This influ‐
310               ences Perl's idea of what a "line" is.  Works like awk's RS
311               variable, including treating empty lines as a terminator if set
312               to the null string.  (An empty line cannot contain any spaces
313               or tabs.)  You may set it to a multi-character string to match
314               a multi-character terminator, or to "undef" to read through the
315               end of file.  Setting it to "\n\n" means something slightly
316               different than setting to "", if the file contains consecutive
317               empty lines.  Setting to "" will treat two or more consecutive
318               empty lines as a single empty line.  Setting to "\n\n" will
319               blindly assume that the next input character belongs to the
320               next paragraph, even if it's a newline.  (Mnemonic: / delimits
321               line boundaries when quoting poetry.)
322
323                   local $/;           # enable "slurp" mode
324                   local $_ = <FH>;    # whole file now here
325                   s/\n[ \t]+/ /g;
326
327               Remember: the value of $/ is a string, not a regex.  awk has to
328               be better for something. :-)
329
330               Setting $/ to a reference to an integer, scalar containing an
331               integer, or scalar that's convertible to an integer will
332               attempt to read records instead of lines, with the maximum
333               record size being the referenced integer.  So this:
334
335                   local $/ = \32768; # or \"32768", or \$var_containing_32768
336                   open my $fh, $myfile or die $!;
337                   local $_ = <$fh>;
338
339               will read a record of no more than 32768 bytes from FILE.  If
340               you're not reading from a record-oriented file (or your OS
341               doesn't have record-oriented files), then you'll likely get a
342               full chunk of data with every read.  If a record is larger than
343               the record size you've set, you'll get the record back in
344               pieces.
345
346               On VMS, record reads are done with the equivalent of "sysread",
347               so it's best not to mix record and non-record reads on the same
348               file.  (This is unlikely to be a problem, because any file
349               you'd want to read in record mode is probably unusable in line
350               mode.)  Non-VMS systems do normal I/O, so it's safe to mix
351               record and non-record reads of a file.
352
353               See also "Newlines" in perlport.  Also see $..
354
355       HANDLE->autoflush(EXPR)
356       $OUTPUT_AUTOFLUSH
357       $⎪      If set to nonzero, forces a flush right away and after every
358               write or print on the currently selected output channel.
359               Default is 0 (regardless of whether the channel is really
360               buffered by the system or not; $⎪ tells you only whether you've
361               asked Perl explicitly to flush after each write).  STDOUT will
362               typically be line buffered if output is to the terminal and
363               block buffered otherwise.  Setting this variable is useful pri‐
364               marily when you are outputting to a pipe or socket, such as
365               when you are running a Perl program under rsh and want to see
366               the output as it's happening.  This has no effect on input
367               buffering.  See "getc" in perlfunc for that.  (Mnemonic: when
368               you want your pipes to be piping hot.)
369
370       IO::Handle->output_field_separator EXPR
371       $OUTPUT_FIELD_SEPARATOR
372       $OFS
373       $,      The output field separator for the print operator.  If defined,
374               this value is printed between each of print's arguments.
375               Default is "undef".  (Mnemonic: what is printed when there is a
376               "," in your print statement.)
377
378       IO::Handle->output_record_separator EXPR
379       $OUTPUT_RECORD_SEPARATOR
380       $ORS
381       $\      The output record separator for the print operator.  If
382               defined, this value is printed after the last of print's argu‐
383               ments.  Default is "undef".  (Mnemonic: you set "$\" instead of
384               adding "\n" at the end of the print.  Also, it's just like $/,
385               but it's what you get "back" from Perl.)
386
387       $LIST_SEPARATOR
388       $"      This is like $, except that it applies to array and slice val‐
389               ues interpolated into a double-quoted string (or similar inter‐
390               preted string).  Default is a space.  (Mnemonic: obvious, I
391               think.)
392
393       $SUBSCRIPT_SEPARATOR
394       $SUBSEP
395       $;      The subscript separator for multidimensional array emulation.
396               If you refer to a hash element as
397
398                   $foo{$a,$b,$c}
399
400               it really means
401
402                   $foo{join($;, $a, $b, $c)}
403
404               But don't put
405
406                   @foo{$a,$b,$c}      # a slice--note the @
407
408               which means
409
410                   ($foo{$a},$foo{$b},$foo{$c})
411
412               Default is "\034", the same as SUBSEP in awk.  If your keys
413               contain binary data there might not be any safe value for $;.
414               (Mnemonic: comma (the syntactic subscript separator) is a
415               semi-semicolon.  Yeah, I know, it's pretty lame, but $, is
416               already taken for something more important.)
417
418               Consider using "real" multidimensional arrays as described in
419               perllol.
420
421       $#      The output format for printed numbers.  This variable is a
422               half-hearted attempt to emulate awk's OFMT variable.  There are
423               times, however, when awk and Perl have differing notions of
424               what counts as numeric.  The initial value is "%.ng", where n
425               is the value of the macro DBL_DIG from your system's float.h.
426               This is different from awk's default OFMT setting of "%.6g", so
427               you need to set $# explicitly to get awk's value.  (Mnemonic: #
428               is the number sign.)
429
430               Use of $# is deprecated.
431
432       HANDLE->format_page_number(EXPR)
433       $FORMAT_PAGE_NUMBER
434       $%      The current page number of the currently selected output chan‐
435               nel.  Used with formats.  (Mnemonic: % is page number in
436               nroff.)
437
438       HANDLE->format_lines_per_page(EXPR)
439       $FORMAT_LINES_PER_PAGE
440       $=      The current page length (printable lines) of the currently
441               selected output channel.  Default is 60.  Used with formats.
442               (Mnemonic: = has horizontal lines.)
443
444       HANDLE->format_lines_left(EXPR)
445       $FORMAT_LINES_LEFT
446       $-      The number of lines left on the page of the currently selected
447               output channel.  Used with formats.  (Mnemonic: lines_on_page -
448               lines_printed.)
449
450       @LAST_MATCH_START
451       @-      $-[0] is the offset of the start of the last successful match.
452               "$-["n"]" is the offset of the start of the substring matched
453               by n-th subpattern, or undef if the subpattern did not match.
454
455               Thus after a match against $_, $& coincides with "substr $_,
456               $-[0], $+[0] - $-[0]".  Similarly, $n coincides with "substr
457               $_, $-[n], $+[n] - $-[n]" if "$-[n]" is defined, and $+ coin‐
458               cides with "substr $_, $-[$#-], $+[$#-] - $-[$#-]".  One can
459               use "$#-" to find the last matched subgroup in the last suc‐
460               cessful match.  Contrast with $#+, the number of subgroups in
461               the regular expression.  Compare with "@+".
462
463               This array holds the offsets of the beginnings of the last suc‐
464               cessful submatches in the currently active dynamic scope.
465               "$-[0]" is the offset into the string of the beginning of the
466               entire match.  The nth element of this array holds the offset
467               of the nth submatch, so "$-[1]" is the offset where $1 begins,
468               "$-[2]" the offset where $2 begins, and so on.
469
470               After a match against some variable $var:
471
472               $` is the same as "substr($var, 0, $-[0])"
473               $& is the same as "substr($var, $-[0], $+[0] - $-[0])"
474               $' is the same as "substr($var, $+[0])"
475               $1 is the same as "substr($var, $-[1], $+[1] - $-[1])"
476               $2 is the same as "substr($var, $-[2], $+[2] - $-[2])"
477               $3 is the same as "substr($var, $-[3], $+[3] - $-[3])"
478       HANDLE->format_name(EXPR)
479       $FORMAT_NAME
480       $~      The name of the current report format for the currently
481               selected output channel.  Default is the name of the filehan‐
482               dle.  (Mnemonic: brother to $^.)
483
484       HANDLE->format_top_name(EXPR)
485       $FORMAT_TOP_NAME
486       $^      The name of the current top-of-page format for the currently
487               selected output channel.  Default is the name of the filehandle
488               with _TOP appended.  (Mnemonic: points to top of page.)
489
490       IO::Handle->format_line_break_characters EXPR
491       $FORMAT_LINE_BREAK_CHARACTERS
492       $:      The current set of characters after which a string may be bro‐
493               ken to fill continuation fields (starting with ^) in a format.
494               Default is " \n-", to break on whitespace or hyphens.
495               (Mnemonic: a "colon" in poetry is a part of a line.)
496
497       IO::Handle->format_formfeed EXPR
498       $FORMAT_FORMFEED
499       $^L     What formats output as a form feed.  Default is \f.
500
501       $ACCUMULATOR
502       $^A     The current value of the write() accumulator for format()
503               lines.  A format contains formline() calls that put their
504               result into $^A.  After calling its format, write() prints out
505               the contents of $^A and empties.  So you never really see the
506               contents of $^A unless you call formline() yourself and then
507               look at it.  See perlform and "formline()" in perlfunc.
508
509       $CHILD_ERROR
510       $?      The status returned by the last pipe close, backtick (``) com‐
511               mand, successful call to wait() or waitpid(), or from the sys‐
512               tem() operator.  This is just the 16-bit status word returned
513               by the wait() system call (or else is made up to look like it).
514               Thus, the exit value of the subprocess is really ("$? >> 8"),
515               and "$? & 127" gives which signal, if any, the process died
516               from, and "$? & 128" reports whether there was a core dump.
517               (Mnemonic: similar to sh and ksh.)
518
519               Additionally, if the "h_errno" variable is supported in C, its
520               value is returned via $? if any "gethost*()" function fails.
521
522               If you have installed a signal handler for "SIGCHLD", the value
523               of $? will usually be wrong outside that handler.
524
525               Inside an "END" subroutine $? contains the value that is going
526               to be given to "exit()".  You can modify $? in an "END" subrou‐
527               tine to change the exit status of your program.  For example:
528
529                   END {
530                       $? = 1 if $? == 255;  # die would make it 255
531                   }
532
533               Under VMS, the pragma "use vmsish 'status'" makes $? reflect
534               the actual VMS exit status, instead of the default emulation of
535               POSIX status; see "$?" in perlvms for details.
536
537               Also see "Error Indicators".
538
539       ${^ENCODING}
540               The object reference to the Encode object that is used to con‐
541               vert the source code to Unicode.  Thanks to this variable your
542               perl script does not have to be written in UTF-8.  Default is
543               undef.  The direct manipulation of this variable is highly dis‐
544               couraged.  See encoding for more details.
545
546       $OS_ERROR
547       $ERRNO
548       $!      If used numerically, yields the current value of the C "errno"
549               variable, or in other words, if a system or library call fails,
550               it sets this variable.  This means that the value of $! is
551               meaningful only immediately after a failure:
552
553                   if (open(FH, $filename)) {
554                       # Here $! is meaningless.
555                       ...
556                   } else {
557                       # ONLY here is $! meaningful.
558                       ...
559                       # Already here $! might be meaningless.
560                   }
561                   # Since here we might have either success or failure,
562                   # here $! is meaningless.
563
564               In the above meaningless stands for anything: zero, non-zero,
565               "undef".  A successful system or library call does not set the
566               variable to zero.
567
568               If used as a string, yields the corresponding system error
569               string.  You can assign a number to $! to set errno if, for
570               instance, you want "$!" to return the string for error n, or
571               you want to set the exit value for the die() operator.
572               (Mnemonic: What just went bang?)
573
574               Also see "Error Indicators".
575
576       %!      Each element of "%!" has a true value only if $! is set to that
577               value.  For example, $!{ENOENT} is true if and only if the cur‐
578               rent value of $! is "ENOENT"; that is, if the most recent error
579               was "No such file or directory" (or its moral equivalent: not
580               all operating systems give that exact error, and certainly not
581               all languages).  To check if a particular key is meaningful on
582               your system, use "exists $!{the_key}"; for a list of legal
583               keys, use "keys %!".  See Errno for more information, and also
584               see above for the validity of $!.
585
586       $EXTENDED_OS_ERROR
587       $^E     Error information specific to the current operating system.  At
588               the moment, this differs from $! under only VMS, OS/2, and
589               Win32 (and for MacPerl).  On all other platforms, $^E is always
590               just the same as $!.
591
592               Under VMS, $^E provides the VMS status value from the last sys‐
593               tem error.  This is more specific information about the last
594               system error than that provided by $!.  This is particularly
595               important when $! is set to EVMSERR.
596
597               Under OS/2, $^E is set to the error code of the last call to
598               OS/2 API either via CRT, or directly from perl.
599
600               Under Win32, $^E always returns the last error information
601               reported by the Win32 call "GetLastError()" which describes the
602               last error from within the Win32 API.  Most Win32-specific code
603               will report errors via $^E.  ANSI C and Unix-like calls set
604               "errno" and so most portable Perl code will report errors via
605               $!.
606
607               Caveats mentioned in the description of $! generally apply to
608               $^E, also.  (Mnemonic: Extra error explanation.)
609
610               Also see "Error Indicators".
611
612       $EVAL_ERROR
613       $@      The Perl syntax error message from the last eval() operator.
614               If $@ is the null string, the last eval() parsed and executed
615               correctly (although the operations you invoked may have failed
616               in the normal fashion).  (Mnemonic: Where was the syntax error
617               "at"?)
618
619               Warning messages are not collected in this variable.  You can,
620               however, set up a routine to process warnings by setting
621               $SIG{__WARN__} as described below.
622
623               Also see "Error Indicators".
624
625       $PROCESS_ID
626       $PID
627       $$      The process number of the Perl running this script.  You should
628               consider this variable read-only, although it will be altered
629               across fork() calls.  (Mnemonic: same as shells.)
630
631               Note for Linux users: on Linux, the C functions "getpid()" and
632               "getppid()" return different values from different threads. In
633               order to be portable, this behavior is not reflected by $$,
634               whose value remains consistent across threads. If you want to
635               call the underlying "getpid()", you may use the CPAN module
636               "Linux::Pid".
637
638       $REAL_USER_ID
639       $UID
640       $<      The real uid of this process.  (Mnemonic: it's the uid you came
641               from, if you're running setuid.)  You can change both the real
642               uid and the effective uid at the same time by using
643               POSIX::setuid().  Since changes to $< require a system call,
644               check $! after a change attempt to detect any possible errors.
645
646       $EFFECTIVE_USER_ID
647       $EUID
648       $>      The effective uid of this process.  Example:
649
650                   $< = $>;            # set real to effective uid
651                   ($<,$>) = ($>,$<);  # swap real and effective uid
652
653               You can change both the effective uid and the real uid at the
654               same time by using POSIX::setuid().  Changes to $> require a
655               check to $!  to detect any possible errors after an attempted
656               change.
657
658               (Mnemonic: it's the uid you went to, if you're running setuid.)
659               $< and $> can be swapped only on machines supporting
660               setreuid().
661
662       $REAL_GROUP_ID
663       $GID
664       $(      The real gid of this process.  If you are on a machine that
665               supports membership in multiple groups simultaneously, gives a
666               space separated list of groups you are in.  The first number is
667               the one returned by getgid(), and the subsequent ones by get‐
668               groups(), one of which may be the same as the first number.
669
670               However, a value assigned to $( must be a single number used to
671               set the real gid.  So the value given by $( should not be
672               assigned back to $( without being forced numeric, such as by
673               adding zero.
674
675               You can change both the real gid and the effective gid at the
676               same time by using POSIX::setgid().  Changes to $( require a
677               check to $!  to detect any possible errors after an attempted
678               change.
679
680               (Mnemonic: parentheses are used to group things.  The real gid
681               is the group you left, if you're running setgid.)
682
683       $EFFECTIVE_GROUP_ID
684       $EGID
685       $)      The effective gid of this process.  If you are on a machine
686               that supports membership in multiple groups simultaneously,
687               gives a space separated list of groups you are in.  The first
688               number is the one returned by getegid(), and the subsequent
689               ones by getgroups(), one of which may be the same as the first
690               number.
691
692               Similarly, a value assigned to $) must also be a space-sepa‐
693               rated list of numbers.  The first number sets the effective
694               gid, and the rest (if any) are passed to setgroups().  To get
695               the effect of an empty list for setgroups(), just repeat the
696               new effective gid; that is, to force an effective gid of 5 and
697               an effectively empty setgroups() list, say " $) = "5 5" ".
698
699               You can change both the effective gid and the real gid at the
700               same time by using POSIX::setgid() (use only a single numeric
701               argument).  Changes to $) require a check to $! to detect any
702               possible errors after an attempted change.
703
704               (Mnemonic: parentheses are used to group things.  The effective
705               gid is the group that's right for you, if you're running set‐
706               gid.)
707
708               $<, $>, $( and $) can be set only on machines that support the
709               corresponding set[re][ug]id() routine.  $( and $) can be
710               swapped only on machines supporting setregid().
711
712       $PROGRAM_NAME
713       $0      Contains the name of the program being executed.
714
715               On some (read: not all) operating systems assigning to $0 modi‐
716               fies the argument area that the "ps" program sees.  On some
717               platforms you may have to use special "ps" options or a differ‐
718               ent "ps" to see the changes.  Modifying the $0 is more useful
719               as a way of indicating the current program state than it is for
720               hiding the program you're running.  (Mnemonic: same as sh and
721               ksh.)
722
723               Note that there are platform specific limitations on the maxi‐
724               mum length of $0.  In the most extreme case it may be limited
725               to the space occupied by the original $0.
726
727               In some platforms there may be arbitrary amount of padding, for
728               example space characters, after the modified name as shown by
729               "ps".  In some platforms this padding may extend all the way to
730               the original length of the argument area, no matter what you do
731               (this is the case for example with Linux 2.2).
732
733               Note for BSD users: setting $0 does not completely remove
734               "perl" from the ps(1) output.  For example, setting $0 to "foo‐
735               bar" may result in "perl: foobar (perl)" (whether both the
736               "perl: " prefix and the " (perl)" suffix are shown depends on
737               your exact BSD variant and version).  This is an operating sys‐
738               tem feature, Perl cannot help it.
739
740               In multithreaded scripts Perl coordinates the threads so that
741               any thread may modify its copy of the $0 and the change becomes
742               visible to ps(1) (assuming the operating system plays along).
743               Note that the view of $0 the other threads have will not change
744               since they have their own copies of it.
745
746       $[      The index of the first element in an array, and of the first
747               character in a substring.  Default is 0, but you could theoret‐
748               ically set it to 1 to make Perl behave more like awk (or For‐
749               tran) when subscripting and when evaluating the index() and
750               substr() functions.  (Mnemonic: [ begins subscripts.)
751
752               As of release 5 of Perl, assignment to $[ is treated as a com‐
753               piler directive, and cannot influence the behavior of any other
754               file.  (That's why you can only assign compile-time constants
755               to it.)  Its use is highly discouraged.
756
757               Note that, unlike other compile-time directives (such as
758               strict), assignment to $[ can be seen from outer lexical scopes
759               in the same file.  However, you can use local() on it to
760               strictly bind its value to a lexical block.
761
762       $]      The version + patchlevel / 1000 of the Perl interpreter.  This
763               variable can be used to determine whether the Perl interpreter
764               executing a script is in the right range of versions.
765               (Mnemonic: Is this version of perl in the right bracket?)
766               Example:
767
768                   warn "No checksumming!\n" if $] < 3.019;
769
770               See also the documentation of "use VERSION" and "require VER‐
771               SION" for a convenient way to fail if the running Perl inter‐
772               preter is too old.
773
774               When testing the variable, to steer clear of floating point
775               inaccuracies you might want to prefer the inequality tests "<"
776               and ">" to the tests containing equivalence: "<=", "==", and
777               ">=".
778
779               The floating point representation can sometimes lead to inaccu‐
780               rate numeric comparisons.  See $^V for a more modern represen‐
781               tation of the Perl version that allows accurate string compar‐
782               isons.
783
784       $COMPILING
785       $^C     The current value of the flag associated with the -c switch.
786               Mainly of use with -MO=... to allow code to alter its behavior
787               when being compiled, such as for example to AUTOLOAD at compile
788               time rather than normal, deferred loading.  See perlcc.  Set‐
789               ting "$^C = 1" is similar to calling "B::minus_c".
790
791       $DEBUGGING
792       $^D     The current value of the debugging flags.  (Mnemonic: value of
793               -D switch.) May be read or set. Like its command-line equiva‐
794               lent, you can use numeric or symbolic values, eg "$^D = 10" or
795               "$^D = "st"".
796
797       $SYSTEM_FD_MAX
798       $^F     The maximum system file descriptor, ordinarily 2.  System file
799               descriptors are passed to exec()ed processes, while higher file
800               descriptors are not.  Also, during an open(), system file
801               descriptors are preserved even if the open() fails.  (Ordinary
802               file descriptors are closed before the open() is attempted.)
803               The close-on-exec status of a file descriptor will be decided
804               according to the value of $^F when the corresponding file,
805               pipe, or socket was opened, not the time of the exec().
806
807       $^H     WARNING: This variable is strictly for internal use only.  Its
808               availability, behavior, and contents are subject to change
809               without notice.
810
811               This variable contains compile-time hints for the Perl inter‐
812               preter.  At the end of compilation of a BLOCK the value of this
813               variable is restored to the value when the interpreter started
814               to compile the BLOCK.
815
816               When perl begins to parse any block construct that provides a
817               lexical scope (e.g., eval body, required file, subroutine body,
818               loop body, or conditional block), the existing value of $^H is
819               saved, but its value is left unchanged.  When the compilation
820               of the block is completed, it regains the saved value.  Between
821               the points where its value is saved and restored, code that
822               executes within BEGIN blocks is free to change the value of
823               $^H.
824
825               This behavior provides the semantic of lexical scoping, and is
826               used in, for instance, the "use strict" pragma.
827
828               The contents should be an integer; different bits of it are
829               used for different pragmatic flags.  Here's an example:
830
831                   sub add_100 { $^H ⎪= 0x100 }
832
833                   sub foo {
834                       BEGIN { add_100() }
835                       bar->baz($boon);
836                   }
837
838               Consider what happens during execution of the BEGIN block.  At
839               this point the BEGIN block has already been compiled, but the
840               body of foo() is still being compiled.  The new value of $^H
841               will therefore be visible only while the body of foo() is being
842               compiled.
843
844               Substitution of the above BEGIN block with:
845
846                   BEGIN { require strict; strict->import('vars') }
847
848               demonstrates how "use strict 'vars'" is implemented.  Here's a
849               conditional version of the same lexical pragma:
850
851                   BEGIN { require strict; strict->import('vars') if $condition }
852
853       %^H     WARNING: This variable is strictly for internal use only.  Its
854               availability, behavior, and contents are subject to change
855               without notice.
856
857               The %^H hash provides the same scoping semantic as $^H.  This
858               makes it useful for implementation of lexically scoped pragmas.
859
860       $INPLACE_EDIT
861       $^I     The current value of the inplace-edit extension.  Use "undef"
862               to disable inplace editing.  (Mnemonic: value of -i switch.)
863
864       $^M     By default, running out of memory is an untrappable, fatal
865               error.  However, if suitably built, Perl can use the contents
866               of $^M as an emergency memory pool after die()ing.  Suppose
867               that your Perl were compiled with "-DPERL_EMERGENCY_SBRK" and
868               used Perl's malloc.  Then
869
870                   $^M = 'a' x (1 << 16);
871
872               would allocate a 64K buffer for use in an emergency.  See the
873               INSTALL file in the Perl distribution for information on how to
874               add custom C compilation flags when compiling perl.  To dis‐
875               courage casual use of this advanced feature, there is no Eng‐
876               lish long name for this variable.
877
878       $OSNAME
879       $^O     The name of the operating system under which this copy of Perl
880               was built, as determined during the configuration process.  The
881               value is identical to $Config{'osname'}.  See also Config and
882               the -V command-line switch documented in perlrun.
883
884               In Windows platforms, $^O is not very helpful: since it is
885               always "MSWin32", it doesn't tell the difference between
886               95/98/ME/NT/2000/XP/CE/.NET.  Use Win32::GetOSName() or
887               Win32::GetOSVersion() (see Win32 and perlport) to distinguish
888               between the variants.
889
890       ${^OPEN}
891               An internal variable used by PerlIO.  A string in two parts,
892               separated by a "\0" byte, the first part describes the input
893               layers, the second part describes the output layers.
894
895       $PERLDB
896       $^P     The internal variable for debugging support.  The meanings of
897               the various bits are subject to change, but currently indicate:
898
899               0x01  Debug subroutine enter/exit.
900
901               0x02  Line-by-line debugging.
902
903               0x04  Switch off optimizations.
904
905               0x08  Preserve more data for future interactive inspections.
906
907               0x10  Keep info about source lines on which a subroutine is
908                     defined.
909
910               0x20  Start with single-step on.
911
912               0x40  Use subroutine address instead of name when reporting.
913
914               0x80  Report "goto &subroutine" as well.
915
916               0x100 Provide informative "file" names for evals based on the
917                     place they were compiled.
918
919               0x200 Provide informative names to anonymous subroutines based
920                     on the place they were compiled.
921
922               0x400 Debug assertion subroutines enter/exit.
923
924               Some bits may be relevant at compile-time only, some at run-
925               time only.  This is a new mechanism and the details may change.
926
927       $LAST_REGEXP_CODE_RESULT
928       $^R     The result of evaluation of the last successful "(?{ code })"
929               regular expression assertion (see perlre).  May be written to.
930
931       $EXCEPTIONS_BEING_CAUGHT
932       $^S     Current state of the interpreter.
933
934                   $^S         State
935                   ---------   -------------------
936                   undef       Parsing module/eval
937                   true (1)    Executing an eval
938                   false (0)   Otherwise
939
940               The first state may happen in $SIG{__DIE__} and $SIG{__WARN__}
941               handlers.
942
943       $BASETIME
944       $^T     The time at which the program began running, in seconds since
945               the epoch (beginning of 1970).  The values returned by the -M,
946               -A, and -C filetests are based on this value.
947
948       ${^TAINT}
949               Reflects if taint mode is on or off.  1 for on (the program was
950               run with -T), 0 for off, -1 when only taint warnings are
951               enabled (i.e. with -t or -TU).
952
953       ${^UNICODE}
954               Reflects certain Unicode settings of Perl.  See perlrun docu‐
955               mentation for the "-C" switch for more information about the
956               possible values. This variable is set during Perl startup and
957               is thereafter read-only.
958
959       ${^UTF8LOCALE}
960               This variable indicates whether an UTF-8 locale was detected by
961               perl at startup. This information is used by perl when it's in
962               adjust-utf8ness-to-locale mode (as when run with the "-CL" com‐
963               mand-line switch); see perlrun for more info on this.
964
965       $PERL_VERSION
966       $^V     The revision, version, and subversion of the Perl interpreter,
967               represented as a string composed of characters with those ordi‐
968               nals.  Thus in Perl v5.6.0 it equals "chr(5) . chr(6) . chr(0)"
969               and will return true for "$^V eq v5.6.0".  Note that the char‐
970               acters in this string value can potentially be in Unicode
971               range.
972
973               This can be used to determine whether the Perl interpreter exe‐
974               cuting a script is in the right range of versions.  (Mnemonic:
975               use ^V for Version Control.)  Example:
976
977                   warn "No \"our\" declarations!\n" if $^V and $^V lt v5.6.0;
978
979               To convert $^V into its string representation use sprintf()'s
980               "%vd" conversion:
981
982                   printf "version is v%vd\n", $^V;  # Perl's version
983
984               See the documentation of "use VERSION" and "require VERSION"
985               for a convenient way to fail if the running Perl interpreter is
986               too old.
987
988               See also $] for an older representation of the Perl version.
989
990       $WARNING
991       $^W     The current value of the warning switch, initially true if -w
992               was used, false otherwise, but directly modifiable.  (Mnemonic:
993               related to the -w switch.)  See also warnings.
994
995       ${^WARNING_BITS}
996               The current set of warning checks enabled by the "use warnings"
997               pragma.  See the documentation of "warnings" for more details.
998
999       $EXECUTABLE_NAME
1000       $^X     The name used to execute the current copy of Perl, from C's
1001               "argv[0]" or (where supported) /proc/self/exe.
1002
1003               Depending on the host operating system, the value of $^X may be
1004               a relative or absolute pathname of the perl program file, or
1005               may be the string used to invoke perl but not the pathname of
1006               the perl program file.  Also, most operating systems permit
1007               invoking programs that are not in the PATH environment vari‐
1008               able, so there is no guarantee that the value of $^X is in
1009               PATH.  For VMS, the value may or may not include a version num‐
1010               ber.
1011
1012               You usually can use the value of $^X to re-invoke an indepen‐
1013               dent copy of the same perl that is currently running, e.g.,
1014
1015                 @first_run = `$^X -le "print int rand 100 for 1..100"`;
1016
1017               But recall that not all operating systems support forking or
1018               capturing of the output of commands, so this complex statement
1019               may not be portable.
1020
1021               It is not safe to use the value of $^X as a path name of a
1022               file, as some operating systems that have a mandatory suffix on
1023               executable files do not require use of the suffix when invoking
1024               a command.  To convert the value of $^X to a path name, use the
1025               following statements:
1026
1027                 # Build up a set of file names (not command names).
1028                 use Config;
1029                 $this_perl = $^X;
1030                 if ($^O ne 'VMS')
1031                    {$this_perl .= $Config{_exe}
1032                         unless $this_perl =~ m/$Config{_exe}$/i;}
1033
1034               Because many operating systems permit anyone with read access
1035               to the Perl program file to make a copy of it, patch the copy,
1036               and then execute the copy, the security-conscious Perl program‐
1037               mer should take care to invoke the installed copy of perl, not
1038               the copy referenced by $^X.  The following statements accom‐
1039               plish this goal, and produce a pathname that can be invoked as
1040               a command or referenced as a file.
1041
1042                 use Config;
1043                 $secure_perl_path = $Config{perlpath};
1044                 if ($^O ne 'VMS')
1045                    {$secure_perl_path .= $Config{_exe}
1046                         unless $secure_perl_path =~ m/$Config{_exe}$/i;}
1047
1048       ARGV    The special filehandle that iterates over command-line file‐
1049               names in @ARGV. Usually written as the null filehandle in the
1050               angle operator "<>". Note that currently "ARGV" only has its
1051               magical effect within the "<>" operator; elsewhere it is just a
1052               plain filehandle corresponding to the last file opened by "<>".
1053               In particular, passing "\*ARGV" as a parameter to a function
1054               that expects a filehandle may not cause your function to auto‐
1055               matically read the contents of all the files in @ARGV.
1056
1057       $ARGV   contains the name of the current file when reading from <>.
1058
1059       @ARGV   The array @ARGV contains the command-line arguments intended
1060               for the script.  $#ARGV is generally the number of arguments
1061               minus one, because $ARGV[0] is the first argument, not the pro‐
1062               gram's command name itself.  See $0 for the command name.
1063
1064       ARGVOUT The special filehandle that points to the currently open output
1065               file when doing edit-in-place processing with -i.  Useful when
1066               you have to do a lot of inserting and don't want to keep modi‐
1067               fying $_.  See perlrun for the -i switch.
1068
1069       @F      The array @F contains the fields of each line read in when
1070               autosplit mode is turned on.  See perlrun for the -a switch.
1071               This array is package-specific, and must be declared or given a
1072               full package name if not in package main when running under
1073               "strict 'vars'".
1074
1075       @INC    The array @INC contains the list of places that the "do EXPR",
1076               "require", or "use" constructs look for their library files.
1077               It initially consists of the arguments to any -I command-line
1078               switches, followed by the default Perl library, probably
1079               /usr/local/lib/perl, followed by ".", to represent the current
1080               directory.  ("." will not be appended if taint checks are
1081               enabled, either by "-T" or by "-t".)  If you need to modify
1082               this at runtime, you should use the "use lib" pragma to get the
1083               machine-dependent library properly loaded also:
1084
1085                   use lib '/mypath/libdir/';
1086                   use SomeMod;
1087
1088               You can also insert hooks into the file inclusion system by
1089               putting Perl code directly into @INC.  Those hooks may be sub‐
1090               routine references, array references or blessed objects.  See
1091               "require" in perlfunc for details.
1092
1093       @_      Within a subroutine the array @_ contains the parameters passed
1094               to that subroutine.  See perlsub.
1095
1096       %INC    The hash %INC contains entries for each filename included via
1097               the "do", "require", or "use" operators.  The key is the file‐
1098               name you specified (with module names converted to pathnames),
1099               and the value is the location of the file found.  The "require"
1100               operator uses this hash to determine whether a particular file
1101               has already been included.
1102
1103               If the file was loaded via a hook (e.g. a subroutine reference,
1104               see "require" in perlfunc for a description of these hooks),
1105               this hook is by default inserted into %INC in place of a file‐
1106               name.  Note, however, that the hook may have set the %INC entry
1107               by itself to provide some more specific info.
1108
1109       %ENV
1110       $ENV{expr}
1111               The hash %ENV contains your current environment.  Setting a
1112               value in "ENV" changes the environment for any child processes
1113               you subsequently fork() off.
1114
1115       %SIG
1116       $SIG{expr}
1117               The hash %SIG contains signal handlers for signals.  For exam‐
1118               ple:
1119
1120                   sub handler {       # 1st argument is signal name
1121                       my($sig) = @_;
1122                       print "Caught a SIG$sig--shutting down\n";
1123                       close(LOG);
1124                       exit(0);
1125                   }
1126
1127                   $SIG{'INT'}  = \&handler;
1128                   $SIG{'QUIT'} = \&handler;
1129                   ...
1130                   $SIG{'INT'}  = 'DEFAULT';   # restore default action
1131                   $SIG{'QUIT'} = 'IGNORE';    # ignore SIGQUIT
1132
1133               Using a value of 'IGNORE' usually has the effect of ignoring
1134               the signal, except for the "CHLD" signal.  See perlipc for more
1135               about this special case.
1136
1137               Here are some other examples:
1138
1139                   $SIG{"PIPE"} = "Plumber";   # assumes main::Plumber (not recommended)
1140                   $SIG{"PIPE"} = \&Plumber;   # just fine; assume current Plumber
1141                   $SIG{"PIPE"} = *Plumber;    # somewhat esoteric
1142                   $SIG{"PIPE"} = Plumber();   # oops, what did Plumber() return??
1143
1144               Be sure not to use a bareword as the name of a signal handler,
1145               lest you inadvertently call it.
1146
1147               If your system has the sigaction() function then signal han‐
1148               dlers are installed using it.  This means you get reliable sig‐
1149               nal handling.
1150
1151               The default delivery policy of signals changed in Perl 5.8.0
1152               from immediate (also known as "unsafe") to deferred, also known
1153               as "safe signals".  See perlipc for more information.
1154
1155               Certain internal hooks can be also set using the %SIG hash.
1156               The routine indicated by $SIG{__WARN__} is called when a warn‐
1157               ing message is about to be printed.  The warning message is
1158               passed as the first argument.  The presence of a __WARN__ hook
1159               causes the ordinary printing of warnings to STDERR to be sup‐
1160               pressed.  You can use this to save warnings in a variable, or
1161               turn warnings into fatal errors, like this:
1162
1163                   local $SIG{__WARN__} = sub { die $_[0] };
1164                   eval $proggie;
1165
1166               The routine indicated by $SIG{__DIE__} is called when a fatal
1167               exception is about to be thrown.  The error message is passed
1168               as the first argument.  When a __DIE__ hook routine returns,
1169               the exception processing continues as it would have in the
1170               absence of the hook, unless the hook routine itself exits via a
1171               "goto", a loop exit, or a die().  The "__DIE__" handler is
1172               explicitly disabled during the call, so that you can die from a
1173               "__DIE__" handler.  Similarly for "__WARN__".
1174
1175               Due to an implementation glitch, the $SIG{__DIE__} hook is
1176               called even inside an eval().  Do not use this to rewrite a
1177               pending exception in $@, or as a bizarre substitute for over‐
1178               riding CORE::GLOBAL::die().  This strange action at a distance
1179               may be fixed in a future release so that $SIG{__DIE__} is only
1180               called if your program is about to exit, as was the original
1181               intent.  Any other use is deprecated.
1182
1183               "__DIE__"/"__WARN__" handlers are very special in one respect:
1184               they may be called to report (probable) errors found by the
1185               parser.  In such a case the parser may be in inconsistent
1186               state, so any attempt to evaluate Perl code from such a handler
1187               will probably result in a segfault.  This means that warnings
1188               or errors that result from parsing Perl should be used with
1189               extreme caution, like this:
1190
1191                   require Carp if defined $^S;
1192                   Carp::confess("Something wrong") if defined &Carp::confess;
1193                   die "Something wrong, but could not load Carp to give backtrace...
1194                        To see backtrace try starting Perl with -MCarp switch";
1195
1196               Here the first line will load Carp unless it is the parser who
1197               called the handler.  The second line will print backtrace and
1198               die if Carp was available.  The third line will be executed
1199               only if Carp was not available.
1200
1201               See "die" in perlfunc, "warn" in perlfunc, "eval" in perlfunc,
1202               and warnings for additional information.
1203
1204       Error Indicators
1205
1206       The variables $@, $!, $^E, and $? contain information about different
1207       types of error conditions that may appear during execution of a Perl
1208       program.  The variables are shown ordered by the "distance" between the
1209       subsystem which reported the error and the Perl process.  They corre‐
1210       spond to errors detected by the Perl interpreter, C library, operating
1211       system, or an external program, respectively.
1212
1213       To illustrate the differences between these variables, consider the
1214       following Perl expression, which uses a single-quoted string:
1215
1216           eval q{
1217               open my $pipe, "/cdrom/install ⎪" or die $!;
1218               my @res = <$pipe>;
1219               close $pipe or die "bad pipe: $?, $!";
1220           };
1221
1222       After execution of this statement all 4 variables may have been set.
1223
1224       $@ is set if the string to be "eval"-ed did not compile (this may hap‐
1225       pen if "open" or "close" were imported with bad prototypes), or if Perl
1226       code executed during evaluation die()d .  In these cases the value of
1227       $@ is the compile error, or the argument to "die" (which will interpo‐
1228       late $! and $?).  (See also Fatal, though.)
1229
1230       When the eval() expression above is executed, open(), "<PIPE>", and
1231       "close" are translated to calls in the C run-time library and thence to
1232       the operating system kernel.  $! is set to the C library's "errno" if
1233       one of these calls fails.
1234
1235       Under a few operating systems, $^E may contain a more verbose error
1236       indicator, such as in this case, "CDROM tray not closed."  Systems that
1237       do not support extended error messages leave $^E the same as $!.
1238
1239       Finally, $? may be set to non-0 value if the external program
1240       /cdrom/install fails.  The upper eight bits reflect specific error con‐
1241       ditions encountered by the program (the program's exit() value).   The
1242       lower eight bits reflect mode of failure, like signal death and core
1243       dump information  See wait(2) for details.  In contrast to $! and $^E,
1244       which are set only if error condition is detected, the variable $? is
1245       set on each "wait" or pipe "close", overwriting the old value.  This is
1246       more like $@, which on every eval() is always set on failure and
1247       cleared on success.
1248
1249       For more details, see the individual descriptions at $@, $!, $^E, and
1250       $?.
1251
1252       Technical Note on the Syntax of Variable Names
1253
1254       Variable names in Perl can have several formats.  Usually, they must
1255       begin with a letter or underscore, in which case they can be arbitrar‐
1256       ily long (up to an internal limit of 251 characters) and may contain
1257       letters, digits, underscores, or the special sequence "::" or "'".  In
1258       this case, the part before the last "::" or "'" is taken to be a pack‐
1259       age qualifier; see perlmod.
1260
1261       Perl variable names may also be a sequence of digits or a single punc‐
1262       tuation or control character.  These names are all reserved for special
1263       uses by Perl; for example, the all-digits names are used to hold data
1264       captured by backreferences after a regular expression match.  Perl has
1265       a special syntax for the single-control-character names: It understands
1266       "^X" (caret "X") to mean the control-"X" character.  For example, the
1267       notation $^W (dollar-sign caret "W") is the scalar variable whose name
1268       is the single character control-"W".  This is better than typing a lit‐
1269       eral control-"W" into your program.
1270
1271       Finally, new in Perl 5.6, Perl variable names may be alphanumeric
1272       strings that begin with control characters (or better yet, a caret).
1273       These variables must be written in the form "${^Foo}"; the braces are
1274       not optional.  "${^Foo}" denotes the scalar variable whose name is a
1275       control-"F" followed by two "o"'s.  These variables are reserved for
1276       future special uses by Perl, except for the ones that begin with "^_"
1277       (control-underscore or caret-underscore).  No control-character name
1278       that begins with "^_" will acquire a special meaning in any future ver‐
1279       sion of Perl; such names may therefore be used safely in programs.  $^_
1280       itself, however, is reserved.
1281
1282       Perl identifiers that begin with digits, control characters, or punctu‐
1283       ation characters are exempt from the effects of the "package" declara‐
1284       tion and are always forced to be in package "main"; they are also
1285       exempt from "strict 'vars'" errors.  A few other names are also exempt
1286       in these ways:
1287
1288               ENV             STDIN
1289               INC             STDOUT
1290               ARGV            STDERR
1291               ARGVOUT         _
1292               SIG
1293
1294       In particular, the new special "${^_XYZ}" variables are always taken to
1295       be in package "main", regardless of any "package" declarations
1296       presently in scope.
1297

BUGS

1299       Due to an unfortunate accident of Perl's implementation, "use English"
1300       imposes a considerable performance penalty on all regular expression
1301       matches in a program, regardless of whether they occur in the scope of
1302       "use English".  For that reason, saying "use English" in libraries is
1303       strongly discouraged.  See the Devel::SawAmpersand module documentation
1304       from CPAN ( http://www.cpan.org/modules/by-module/Devel/ ) for more
1305       information.
1306
1307       Having to even think about the $^S variable in your exception handlers
1308       is simply wrong.  $SIG{__DIE__} as currently implemented invites griev‐
1309       ous and difficult to track down errors.  Avoid it and use an "END{}" or
1310       CORE::GLOBAL::die override instead.
1311
1312
1313
1314perl v5.8.8                       2006-01-07                        PERLVAR(1)
Impressum