●
5.18.1
Latest
5.40.0
5.38.2
5.38.1
5.38.0
5.36.3
5.36.2
5.36.1
5.36.0
5.34.3
5.34.2
5.34.1
5.34.0
5.32.1
5.32.0
5.30.3
5.30.2
5.30.1
5.30.0
5.28.3
5.28.2
5.28.1
5.28.0
5.26.3
5.26.2
5.26.1
5.26.0
5.24.4
5.24.3
5.24.2
5.24.1
5.24.0
5.22.4
5.22.3
5.22.2
5.22.1
5.22.0
5.20.3
5.20.2
5.20.1
5.20.0
5.18.4
5.18.3
5.18.2
5.18.1
5.18.0
5.16.3
5.16.2
5.16.1
5.16.0
5.14.4
5.14.3
5.14.2
5.14.1
5.14.0
5.12.5
5.12.4
5.12.3
5.12.2
5.12.1
5.12.0
5.10.1
5.10.0
5.8.9
5.8.8
5.8.7
5.8.6
5.8.5
5.8.4
5.8.3
5.8.2
5.8.1
5.8.0
5.6.2
5.6.1
5.6.0
5.005_04
5.005_03
5.005_02
5.005_01
5.005
●
Dev
blead
5.41.2
5.41.1
5.40.0-RC2
5.40.0-RC1
5.39.10
5.39.9
5.39.8
5.39.6
5.39.5
5.39.4
5.39.3
5.39.2
5.39.1
5.37.11
5.37.10
5.37.9
5.37.8
5.37.7
5.37.6
5.37.5
5.37.4
5.37.3
5.37.2
5.37.1
5.37.0
●
Documentation
Perl
Intro
Tutorials
FAQs
Reference
Operators
Functions
Variables
Modules
Utilities
Community
History
variables
(source,
CPAN)
You are viewing the version of this documentation from Perl 5.18.1.
View the latest version
●
General Variables
●
Variables related to regular expressions
●
Variables related to filehandles
●
Variables related to formats
●
Error Variables
●
Variables related to the interpreter state
●
Deprecated and removed variables
Full documentation of predefined variables: perlvar
#General Variables
$_ - 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
$^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
$^I - The current value of the inplace-edit extension
$^M - Perl can use the contents of $^M
as an emergency memory pool after die()
ing
$^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
$^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
${^WIN32_SLOPPY_STAT} - If this variable is set to a true value, then stat()
on Windows will not try to open the file
$^X - The name used to execute the current copy of Perl, from C'sargv[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, 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)
${^MATCH} - This is similar to $&
($MATCH
) except that it does not incur the performance penalty associated with that variable, and 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, not counting any matches hidden within a BLOCK or eval
enclosed by the current BLOCK
${^PREMATCH} - This is similar to $`
($PREMATCH) except that it does not incur the performance penalty associated with that variable, and is only guaranteed to return a defined value when the pattern was compiled or executed with the /p
modifier
$' - 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)
${^POSTMATCH} - This is similar to $'
($POSTMATCH
) except that it does not incur the performance penalty associated with that variable, and is only guaranteed to return a defined value when the pattern was compiled or executed with the /p
modifier
$+ - The text matched by the last bracket 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 search pattern
@+ - This array holds the offsets of the ends of the last successful submatches in the currently active dynamic scope
%+ - 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
@- - $-[0]
is the offset of the start of the last successful match
%- - Similar to %+
, this variable allows access to the named capture groups in the last successful match in the currently active dynamic scope
$^R - The result of evaluation of the last successful (?{ code
})
regular expression assertion (see perlre)
${^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
#Error Variables
${^CHILD_ERROR_NATIVE} - The native status returned by the last pipe close, backtick (``
) command, successful call to wait()
orwaitpid()
, 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 wa
it()
orwaitpid()
, or from the sys
tem()
operator
$@ - The Perl syntax error message from the last eval()
operator
$^C - The current value of the flag associated with the -c switch
$^D - The current value of the debugging flags
${^ENCODING} - The object reference to the Encode
object that is used to convert the source code to Unicode
${^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 semantic as $^H
${^OPEN} - An internal variable used by PerlIO
$^P - The internal variable for debugging support
${^TAINT} - Reflects if taint mode is on or off
${^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
#Deprecated and removed variables
$# - $#
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
$] - The version + patchlevel / 1000 of the Perl interpreter
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via the GitHub issue trackeroremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the Perl issue tracker, the mailing list, or IRC to report any issues with the contents or format of the documentation.