The alternative names for special variables are provided by the standard module English.
The following variables are global and should be localized in subroutines:
$_
Alternative: $ARG.
The default argument for many functions and operations.
$.
Alternatives: $INPUT_LINE_NUMBER, $NR.
The current input line number of the last filehandle that was read. Reset only when the filehandle is closed explicitly.
$/
Alternatives: $INPUT_RECORD_SEPARATOR, $RS.
The string that separates input records. Default value is a newline.
$,
Alternatives: $OUTPUT_FIELD_SEPARATOR, $OFS.
The output field separator for the print functions. Default value is an empty string.
$"
Alternative: $LIST_SEPARATOR.
The separator that joins elements of arrays interpolated in strings. Default value is a single space.
$
Alternatives: $OUTPUT_RECORD_SEPARATOR, $ORS.
The output record separator for the print functions. Default value is an empty string.
$?
Alternative: $CHILD_ERROR.
The status returned by the last ` . . . `
command, pipe close, wait, waitpid, or system function.
$]
The Perl version number, e.g., 5.006.
See also $^V
in page 72.
$[
The index of the first element in an array or list, and of the first character in a substring. Default is zero. Deprecated. Do not use.
$;
Alternatives: $SUBSCRIPT_SEPARATOR, $SUBSEP.
The subscript separator for multidimensional hash emulation. Default is " 34".
$!
Alternatives: $OS_ERROR, $ERRNO.
If used in numeric context, yields the current value of errno.
Otherwise, yields the corresponding error string.
$@
Alternative: $EVAL_ERROR.
The Perl error message from the last eval or do expr command.
$:
Alternative: $FORMAT_LINE_BREAK_CHARACTERS.
The set of characters after which a string may be broken to fill continuation fields (starting with ^
) in a format.
$0
Alternative: $PROGRAM_NAME.
The name of the file containing the Perl script being executed. May be assigned to.
$$
Alternatives: $PROCESS_ID, $PID.
The process ID of the Perl interpreter running this script. Altered (in the child process) by fork.
$<
Alternatives: $REAL_USER_ID, $UID.
The real user ID of this process.
$>
Alternatives: $EFFECTIVE_USER_ID, $EUID.
The effective user ID of this process.
$(
Alternatives: $REAL_GROUP_ID, $GID.
The real group ID of this process.
$)
Alternatives: $EFFECTIVE_GROUP_ID, $EGID.
The effective group ID, or a space-separated list of group IDs, of this process.
$^A
Alternative: $ACCUMULATOR.
The accumulator for formline and write operations.
$^{CHILD_ERROR_NATIVE}
As $?
, but returns the native status instead.
$^C
Alternative: $COMPILING.
True if Perl is run in compile-only mode (command-line option -c
).
$^D
Alternative: $DEBUGGING.
The debug flags as passed to Perl using command-line option -D.
$^E
Alternative: $EXTENDED_OS_ERROR.
Operating-system dependent error information.
$^F
Alternative: $SYSTEM_FD_MAX.
The highest system file descriptor, ordinarily 2.
$^H
The current state of syntax checks.
$^I
Alternative: $INPLACE_EDIT.
In-place edit extension as specified using command-line option -i.
$^L
Alternative: $FORMAT_FORMFEED.
Formfeed character used in formats.
$^M
Emergency memory pool.
$^O
Alternative: $OSNAME.
Operating system name.
$^P
Alternative: $PERLDB.
Internal debugging flag.
$^{RE_DEBUG_FLAGS}
Flags for debugging.
$^{RE_TRIE_MAXBUF}
For trie optimisation of literal string alternations.
$^S
Alternative: $EXCEPTIONS_BEING_CAUGHT.
Current state of the Perl interpreter.
$^T
Alternative: $BASETIME.
The time (as delivered by time) when the program started. This value is used by the file test operators -M
, -A
, and -C
.
$^{TAINT}
The current state of taint mode.
$^V
Alternative: $PERL_VERSION.
The Perl version as a version object. Use %vd
format to print it.
$^W
Alternative: $WARNING.
The value of the -w
option as passed to Perl.
$^{WIN32_SLOPPY_STAT}
Controls sloppy stat on Windows.
$^X
Alternative: $EXECUTABLE_NAME.
The name by which Perl was invoked.
$AUTOLOAD
The name of the undefined subroutine that was called.
$REGERROR
On a match failure, to the name of the failing backtrack control or the last (*MARK:
name)
pattern.
$REGMARK
On a successful match, this contains the name of the last (*MARK:
name)
pattern.
The following variables are context dependent and need not be localized:
$%
Alternative: $FORMAT_PAGE_NUMBER.
The current page number of the currently selected output handle.
$=
Alternative: $FORMAT_LINES_PER_PAGE.
The page length of the current output handle. Default is 60 lines.
$-
Alternative: $FORMAT_LINES_LEFT.
The number of lines remaining on the page.
$~
Alternative: $FORMAT_NAME.
The name of the current report format.
$^
Alternative: $FORMAT_TOP_NAME.
The name of the current top-of-page format.
$|
Alternative: $OUTPUT_AUTOFLUSH.
If set to nonzero, forces a flush after every write or print on the currently selected output handle. Default is zero.
$ARGV
The name of the current file when reading from < >
.
The following variables are always local to the current block:
$&
Alternative: $MATCH.
The string matched by the last successful match.
$`
Alternative: $PREMATCH.
The string preceding what was matched by the last successful match.
$'
The string following what was matched by the last successful match.
$+
Alternative: $LAST_PAREN_MATCH.
The last bracket matched by the last search pattern.
$1
. . . $9
. . .Contain the subpatterns from the corresponding sets of parentheses in the last pattern successfully matched. $10
and up are only available if the match contained that many subpatterns.
$^N
Alternative: $LAST_SUBMATCH_RESULT.
The text matched by the most recently closed group.
$^R
Alternative: $LAST_REGEXP_CODE_RESULT.
Result of last (?{
code })
.