Chapter 36. Special Variables

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 input, output, and pattern-searching space.

$.

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.

$#

The output format for printed numbers. Deprecated. Use printf instead.

$*

Set to 1 to do multiline matching within strings. Deprecated; see the m and s modifiers.

$?

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.

$[

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 ...

Get Perl Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.