Full documentation of predefined variables: perlvar
$_ - The default input and pattern-searching space
$<digits> - Contains the subpattern from the corresponding set of parentheses in the last pattern matched, not counting patterns matched in nested blocks that have been exited already
$& - The string matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval() enclosed by the current BLOCK)
$` - The string preceding whatever was matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval enclosed by the current BLOCK)
$' - The string following whatever was matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval() enclosed by the current BLOCK)
$+ - The last bracket matched by the last search pattern
$* - Set to 1 to do multi-line matching within a string, 0 to tell Perl that it can assume that strings contain a single line, for the purpose of optimizing pattern matches
$. - The current input line number for the last file handle from which you read (or performed a seek
or tell
on)
$/ - The input record separator, newline by default
$| - If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel
$, - The output field separator for the print operator
$\ - The output record separator for the print operator
$" - This is like "$,
" except that it applies to array values interpolated into a double-quoted string (or similar interpreted string)
$; - The subscript separator for multidimensional array emulation
$# - The output format for printed numbers
$% - The current page number of the currently selected output channel
$= - The current page length (printable lines) of the currently selected output channel
$- - The number of lines left on the page of the currently selected output channel
$~ - The name of the current report format for the currently selected output channel
$^ - The name of the current top-of-page format for the currently selected output channel
$: - The current set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format
$^L - What formats output to perform a form feed
$^A - The current value of the write() accumulator for format() lines
$? - The status returned by the last pipe close, backtick (``
) command, or system() operator
$! - If used in a numeric context, yields the current value of errno, with all the usual caveats
$^E - Error information specific to the current operating system
$@ - The Perl syntax error message from the last eval() command
$$ - The process number of the Perl running this script
$< - The real uid of this process
$> - The effective uid of this process
$( - The real gid of this process
$) - The effective gid of this process
$0 - Contains the name of the file containing the Perl script being executed
$[ - The index of the first element in an array, and of the first character in a substring
$] - The version + patchlevel / 1000 of the Perl interpreter
$^C - The current value of the flag associated with the -c switch
$^D - The current value of the debugging flags
$^F - The maximum system file descriptor, ordinarily 2. System file descriptors are passed to exec()ed processes, while higher file descriptors are not
$^H - The current set of syntax checks enabled by use strict
and other block scoped compiler hints
$^I - The current value of the inplace-edit extension
$^M - Perl may use the contents of $^M
as an emergency pool after die()ing with this message
$^O - The name of the operating system under which this copy of Perl was built, as determined during the configuration process
$^P - The internal variable for debugging support
$^R - The result of evaluation of the last successful "(?{ code })
" in perlre regular expression assertion
$^S - Current state of the interpreter
$^T - The time at which the script began running, in seconds since the epoch (beginning of 1970)
$^W - The current value of the warning switch, either TRUE or FALSE
$^X - The name that the Perl binary itself was executed as, from C's argv[0]
$ARGV - contains the name of the current file when reading from <>
@ARGV - The array @ARGV contains the command line arguments intended for the script
@INC - The array @INC contains the list of places to look for Perl scripts to be evaluated by the do EXPR
, require
, or use
constructs
@_ - Within a subroutine the array @_ contains the parameters passed to that subroutine
%INC - The hash %INC contains entries for each filename that has been included via do
or require
$ENV{expr} - The hash %ENV contains your current environment
$SIG{expr} - The hash %SIG is used to set signal handlers for various signals