Full documentation of predefined variables: perlvar
$_ - The default input and pattern-searching space
@_ - Within a subroutine the array @_
contains the parameters passed to that subroutine
$" - When an array or an array slice is interpolated into a double-quoted string or a similar context such as /.../
, its elements are separated by this value
$$ - The process number of the Perl running this script
$0 - Contains the name of the program being executed
$( - The real gid of this process
$) - The effective gid of this process
$< - The real uid of this process
$> - The effective uid of this process
$; - The subscript separator for multidimensional array emulation
$a, $b - Special package variables when using sort()
, see "sort" in perlfunc
%ENV - The hash %ENV
contains your current environment
$] - The revision, version, and subversion of the Perl interpreter, represented as a decimal of the form 5.XXXYYY, where XXX is the version / 1e3 and YYY is the subversion / 1e6
$^F - The maximum system file descriptor, ordinarily 2. System file descriptors are passed to exec()
ed processes, while higher file descriptors are not
@F - The array @F
contains the fields of each line read in when autosplit mode is turned on
@INC - The array @INC
contains the list of places that the do EXPR
, require
, or use
constructs look for their library files
%INC - The hash %INC
contains entries for each filename included via the do
, require
, or use
operators
$INC - As of 5.37.7 when an @INC
hook is executed the index of the @INC
array that holds the hook will be localized into the $INC
variable
$^I - The current value of the inplace-edit extension
@ISA - Each package contains a special array called @ISA
which contains a list of that class's parent classes, if any
$^M - Perl can use the contents of $^M
as an emergency memory pool after die()
ing
${^MAX_NESTED_EVAL_BEGIN_BLOCKS} - This variable determines the maximum number eval EXPR
/BEGIN
or require
/BEGIN
block nesting that is allowed
$^O - The name of the operating system under which this copy of Perl was built, as determined during the configuration process
%SIG - The hash %SIG
contains signal handlers for signals
%{^HOOK} - This hash contains coderefs which are called when various perl keywords which are hard or impossible to wrap are called
$^T - The time at which the program began running, in seconds since the epoch (beginning of 1970)
$^V - The revision, version, and subversion of the Perl interpreter, represented as a version object
$^X - The name used to execute the current copy of Perl, from C's argv[0]
or (where supported) /proc/self/exe
$<digits> ($1, $2, ...) - Contains the subpattern from the corresponding set of capturing parentheses from the last successful pattern match in the current dynamic scope
@{^CAPTURE} - An array which exposes the contents of the capture buffers, if any, of the last successful pattern match, not counting patterns matched in nested blocks that have been exited already
$& - The string matched by the last successful pattern match
${^MATCH} - It is only guaranteed to return a defined value when the pattern was compiled or executed with the /p
modifier
$` - The string preceding whatever was matched by the last successful pattern match
${^PREMATCH} - It is only guaranteed to return a defined value when the pattern was executed with the /p
modifier
$' - The string following whatever was matched by the last successful pattern match
${^POSTMATCH} - It is only guaranteed to return a defined value when the pattern was compiled or executed with the /p
modifier
$+ - The text matched by the highest used capture group of the last successful search pattern
$^N - The text matched by the used group most-recently closed (i.e. the group with the rightmost closing parenthesis) of the last successful match
@+ - This array holds the offsets of the ends of the last successful match and any matching capture buffers that the pattern contains
%+ - Similar to @+
, the %+
hash allows access to the named capture buffers, should they exist, in the last successful match in the currently active dynamic scope
@- - This array holds the offsets of the beginnings of the last successful match and any capture buffers it contains
%- - Similar to %+
, this variable allows access to the named capture groups in the last successful match in the currently active dynamic scope
${^LAST_SUCCESSFUL_PATTERN} - The last successful pattern that matched in the current scope
$^R - The result of evaluation of the last successful (?{ code })
regular expression assertion (see perlre)
${^RE_COMPILE_RECURSION_LIMIT} - The current value giving the maximum number of open but unclosed parenthetical groups there may be at any point during a regular expression compilation
${^RE_DEBUG_FLAGS} - The current value of the regex debugging flags
${^RE_TRIE_MAXBUF} - Controls how certain regex optimisations are applied and how much memory they utilize
$ARGV - Contains the name of the current file when reading from <>
@ARGV - The array @ARGV
contains the command-line arguments intended for the script
ARGV - The special filehandle that iterates over command-line filenames in @ARGV
ARGVOUT - The special filehandle that points to the currently open output file when doing edit-in-place processing with -i
$, - The output field separator for the print operator
$. - Current line number for the last filehandle accessed
$/ - The input record separator, newline by default
$\ - The output record separator for the print operator
$| - If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel
${^LAST_FH} - This read-only variable contains a reference to the last-read filehandle
$^A - The current value of the write()
accumulator for format()
lines
$^L - What formats output as a form feed
$% - The current page number of the currently selected output channel
$- - The number of lines left on the page of 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
$= - The current page length (printable lines) of the currently selected output channel
$^ - The name of the current top-of-page format for the currently selected output channel
$~ - The name of the current report format for the currently selected output channel
${^CHILD_ERROR_NATIVE} - The native status returned by the last pipe close, backtick (``
) command, successful call to wait()
or waitpid()
, or from the system()
operator
$^E - Error information specific to the current operating system
$^S - Current state of the interpreter
$^W - The current value of the warning switch, initially true if -w was used, false otherwise, but directly modifiable
${^WARNING_BITS} - The current set of warning checks enabled by the use warnings
pragma
$! - When referenced, $!
retrieves the current value of the C errno
integer variable
%! - Each element of %!
has a true value only if $!
is set to that value
$? - The status returned by the last pipe close, backtick (``
) command, successful call to wait()
or waitpid()
, or from the system()
operator
$@ - The Perl error from the last eval
operator, i.e. the last exception that was caught
$^C - The current value of the flag associated with the -c switch
$^D - The current value of the debugging flags
${^GLOBAL_PHASE} - The current phase of the perl interpreter
$^H - This variable contains compile-time hints for the Perl interpreter
%^H - The %^H
hash provides the same scoping semantics as $^H
$^P - The internal variable for debugging support
${^TAINT} - Reflects if taint mode is on or off
${^SAFE_LOCALES} - Reflects if safe locale operations are available to this perl (when the value is 1) or not (the value is 0)
${^UNICODE} - Reflects certain Unicode settings of Perl
${^UTF8CACHE} - This variable controls the state of the internal UTF-8 offset caching code
${^UTF8LOCALE} - This variable indicates whether a UTF-8 locale was detected by perl at startup
$# - $#
was a variable that could be used to format printed numbers
$* - $*
was a variable that you could use to enable multiline matching
$[ - This variable stores the index of the first element in an array, and of the first character in a substring
${^ENCODING} - It used to hold the object reference to the Encode
object that was used to convert the source code to Unicode
${^WIN32_SLOPPY_STAT} - This variable no longer has any function