Mega Code Archive

 
Categories / Perl / Language Basics
 

Perl 5 Built-In Variables

Variable    English Name                     Description $_          $ARG                             default input and pattern-searching space $&          $MATCH                           string matched by the last successful pattern match $`          $PREMATCH                        string preceding whatever was matched by the last successful pattern $'          $POSTMATCH                       string following whatever was matched by the last successful pattern $+          $LAST_PAREN_MATCH                last bracket matched by the last search pattern   $*          $MULTILINE_MATCHING              Perl 5 does multi-line matching within a string if it is 1(the default is 0) $.          $INPUT_LINE_NUMBER               current input line number from the last file handle read $/          $INPUT_RECORD_SEPARATOR          The input record separator (newline by default) $|          $OUTPUT_AUTOFLUSH                If it is nonzero, forces a flush after every write or print on the currently selected output device (the default is 0) $,          $OUTPUT_FIELD_SEPARATOR          field separator for the print function $\          $OUTPUT_RECORD_SEPARATOR         record separator for the print function $"          $LIST_SEPARATOR                  list separator for the print function $;          $SUBSCRIPT_SEPARATOR             subscript separator for multidimensional array emulation $#          $OFMT                            format for printed numbers $%          $FORMAT_PAGE_NUMBER              page number for file handle output $=          $FORMAT_LINES_PER_PAGE           page length for file handle output $-          $FORMAT_LINES_LEFT               number of lines left on the page $~          $FORMAT_NAME                     current format $^          $FORMAT_TOP_NAME                 current top-of-page format $:          $FORMAT_LINE_BREAK_CHARACTERS    characters after which a string may be separated to fill continuation fields  $^L         $FORMAT_FORMFEED                 The value a format will output for each form feed $^A         $ACCUMULATOR                     write() accumulator for format() lines $?          $CHILD_ERROR                     status returned by the last pipe close, backtick (``) command, or system() operator $!          $ERRNO                           current numeric or string value of error number $^E         $EXTENDED_OS_ERROR               Error information specific to the current operating system $@          $EVAL_ERROR                      Perl syntax error message from the last eval() command $$          $PROCESS_ID                      process number of the Perl running this script $<          $REAL_USER_ID                    uid of this process $>          $EFFECTIVE_USER_ID               effective uid of this process $(          $REAL_GROUP_ID                   real gid of this process $)          $EFFECTIVE_GROUP_ID              effective gid of this process $0          $PROGRAM_NAME                    name of the file used to invoke the executing program $[                                           index of the first element in an array and of the first character in a substring $]          $PERL_VERSION                    version and patch level of the Perl interpreter $^D         $DEBUGGING                       value of the debugging flags $^F         $SYSTEM_FD_MAX                   maximum system file descriptor $^H                                          set of syntax checks enabled by use strict and other pragmas $^I         $INPLACE_EDIT                    value of the in-place edit extension $^M                                          An emergency pool of allocated memory, used after an out-of-memory condition for printing error messages $^O         $OSNAME                          name of the operating system under which this copy of Perl was built, as determined during the configuration process $^P         $PERLDB                          internal variable for debugging support $^R                                          The result of evaluation of the last successful regular expression $^S                                          state of the interpreter $^T         $BASETIME                        The time at which the script began running, in seconds since the epoch $^W         $WARNING                         The current value of the warning switch, either true or false $^X         $EXECUTABLE_NAME                 Perl binary $ARGV                                        current file when reading from <> @ARGV                                        An array that contains the command-line arguments @INC                                         An array that contains the list of places to look for Perl scripts to be evaluated by the do EXPR, require, or use constructs (initially consists of the arguments to any -I command-line switches, followed by the default Perl library, followed by ``.'', which represents the current directory) @_                                           Within a subroutine, an array that contains the parameters passed to that subroutine %INC                                         A hash that contains entries for each filename that has been included via do or require (the key is the filename you specified, and the value is the location of the file actually found) %ENV                                         A hash that contains your current environment (setting a value in %ENV changes the environment for child processes) %SIG                                         A hash used to set signal handlers for various signals