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 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 "\034".

$!

Alternatives: $OS_ERROR, $ERRNO.

If used in numeric context, yields the current value of errno. Otherwise, yields the corresponding ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.