Global Special Variable Types in Perl
There are various global special variables in Perl. We have listed them in different blocks based on their usage and nature −
Global Array Special Variables
@ARGV |
The array containing the command-line arguments intended for the script. |
@INC |
The array containing the list of places to look for Perl scripts to be evaluated by the do, require, or use constructs. |
@F |
The array into which the input lines are split when the -a command-line switch is given. |
Global Hash Special Variables
%INC |
The hash containing entries for the filename of each file that has been included via do or require. |
%ENV |
The hash containing your current environment. |
%SIG |
The hash used to set signal handlers for various signals. |
Global Special Filehandles
ARGV |
The special filehandle that iterates over command line filenames in @ARGV. Usually written as the null filehandle in <>. |
STDERR |
The special filehandle for standard error in any package. |
STDIN |
The special filehandle for standard input in any package. |
STDOUT |
The special filehandle for standard output in any package. |
DATA |
The special filehandle that refers to anything following the __END__ token in the file containing the script. Or, the special filehandle for anything following the __DATA__ token in a required file, as long as you're reading data in the same package __DATA__ was found in. |
_ (underscore) |
The special filehandle used to cache the information from the last stat, lstat, or file test operator. |
Global Special Constants
__END__ |
Indicates the logical end of your program. Any following text is ignored, but may be read via the DATA filehandle. |
__FILE__ |
Represents the filename at the point in your program where it's used. Not interpolated into strings. |
__LINE__ |
Represents the current line number. Not interpolated into strings. |
__PACKAGE__ |
Represents the current package name at compile time, or undefined if there is no current package. Not interpolated into strings. |
Kickstart Your Career
Get certified by completing the course
Get Started