Special Variables

The following names have special meaning to Perl. Most of the punctuational names have reasonable mnemonics, or analogs in one of the shells. Nevertheless, if you wish to use the long variable names, just say:

use English;

at the top of your program. This will alias all the short names to the long names in the current package. Some of them even have medium names, generally borrowed from awk(1).

A few of these variables are considered read-only. This means that if you try to assign to this variable, either directly, or indirectly through a reference, you'll raise a run-time exception.

Regular Expression Special Variables

There are several variables that are associated with regular expressions and pattern matching. Except for $* they are always local to the current block, so you never need to mention them in a local. (And $* is deprecated, so you never need to mention it at all.)

Per-Filehandle Special Variables

These variables never need to be mentioned in a local because they always refer to some value pertaining to the currently selected output filehandle - each filehandle keeps its own set of values. When you select another filehandle, the old filehandle keeps whatever values it had in effect, and the variables now reflect the values of the new filehandle.

To go a step further and avoid select entirely, these variables that depend on the currently selected filehandle may instead be set by calling an object method on the FileHandle object. (Summary lines below for this contain the word HANDLE.) First you must say:

use FileHandle;

after which you may use either:

method HANDLE EXPR

or:

HANDLE->method(EXPR)

Each of the methods returns the old value of the FileHandle attribute. The methods each take an optional EXPR, which if supplied specifies the new value for the FileHandle attribute in question. If not supplied, most of the methods do nothing to the current value, except for autoflush, which will assume a for you, just to be different.

Global Special Variables

There are quite a few variables that are global in the fullest sense - they mean the same thing in every package. If you want a private copy of one of these, you must localize it in the current block.

Global Special Arrays

The following arrays and hashes are global. Just like the special global scalar variables, they refer to package main no matter when they are referenced. The following two statements are exactly the same:

print "@INC\n";
print "@main::INC\n";

Global Special Filehandles

The following filehandles (except for DATA) always refer to main::FILEHANDLE.