This document summarizes Perl's predefined variables, including:
- $_ is the default input space and pattern-searching space
- $MATCH contains the string matched by the last successful pattern match
- @LAST_MATCH_START and @LAST_MATCH_END hold the offsets of the starts and ends of the last successful submatches
- $INPUT_RECORD_SEPARATOR and $OUTPUT_RECORD_SEPARATOR control input and output record separation for operators like print
- $, $", and $; control field, array, and subscript separators for operators like print
This document summarizes Perl's predefined variables, including:
- $_ is the default input space and pattern-searching space
- $MATCH contains the string matched by the last successful pattern match
- @LAST_MATCH_START and @LAST_MATCH_END hold the offsets of the starts and ends of the last successful submatches
- $INPUT_RECORD_SEPARATOR and $OUTPUT_RECORD_SEPARATOR control input and output record separation for operators like print
- $, $", and $; control field, array, and subscript separators for operators like print
This document summarizes Perl's predefined variables, including:
- $_ is the default input space and pattern-searching space
- $MATCH contains the string matched by the last successful pattern match
- @LAST_MATCH_START and @LAST_MATCH_END hold the offsets of the starts and ends of the last successful submatches
- $INPUT_RECORD_SEPARATOR and $OUTPUT_RECORD_SEPARATOR control input and output record separation for operators like print
- $, $", and $; control field, array, and subscript separators for operators like print
This document summarizes Perl's predefined variables, including:
- $_ is the default input space and pattern-searching space
- $MATCH contains the string matched by the last successful pattern match
- @LAST_MATCH_START and @LAST_MATCH_END hold the offsets of the starts and ends of the last successful submatches
- $INPUT_RECORD_SEPARATOR and $OUTPUT_RECORD_SEPARATOR control input and output record separation for operators like print
- $, $", and $; control field, array, and subscript separators for operators like print
machine that supports membership in multiple The first number is the one returned $REAL_GROUP_ID groups simultaneously, gives a space separated list by getgid(), and the subsequent ones $GID by getgroups(), one of which may be of groups you are in. (Mnemonic: parentheses are $( used to group things. The real gid is the group you the same as the first number. left, if you're running setgid.) The effective gid of this process. If you are on a machine that supports membership in multiple $EFFECTIVE_GROUP_ID groups simultaneously, gives a space separated list $EGID $) = "5 5" of groups you are in. (Mnemonic: parentheses are $) used to group things. The effective gid is the group that's right for you, if you're running setgid.) $PROGRAM_NAME Contains the name of the program being executed. $0 (Mnemonic: same as sh and ksh.) The index of the first element in an array, and of $[ the first character in a substring. Default is 0. (Mnemonic: [ begins subscripts.) The version + patchlevel / 1000 of the Perl $] interpreter. (Mnemonic: Is this version of perl in the right bracket?) $COMPILING The current value of the flag associated with the -c $^C switch. $DEBUGGING The current value of the debugging flags. $^D (Mnemonic: value of -D switch.) $SYSTEM_FD_MAX The maximum system file descriptor, ordinarily 2. $^F WARNING: This variable is strictly for This variable contains compile-time hints for the internal use only. Its availability, $^H behavior, and contents are subject to Perl interpreter. change without notice. WARNING: This variable is strictly for The %^H hash provides the same scoping internal use only. Its availability, %^H semantic as $^H. This makes it useful for behavior, and contents are subject to implementation of lexically scoped pragmas. change without notice. The current value of the inplace-edit extension. $INPLACE_EDIT Use undef to disable inplace editing. (Mnemonic: $^I value of -i switch.) By default, running out of memory is an # allocate a 64K buffer for use in untrappable, fatal error. However, if suitably built, # an emergency if Perl was compiled $^M # with -DPERL_EMERGENCY_SBRK Perl can use the contents of $^M as an emergency memory pool after die()ing. $^M = 'a' x (1 << 16); The name of the operating system under which $OSNAME this copy of Perl was built, as determined during $^O the configuration process. An internal variable used by PerlIO. A string in ${^OPEN} two parts, separated by a \0 byte, 1st part describes input layers, 2nd part descrabe output layers. $PERLDB The internal variable for debugging support. $^P $LAST_REGEXP_CODE The result of evaluation of the last successful (? _RESULT { code }) regular expression assertion (see perlre). $^R May be written to. $^S State $EXCEPTIONS_BEING --------- ------------------- _CAUGHT Current state of the interpreter. undef Parsing module/eval $^S true (1) Executing an eval false (0) Otherwise The time at which the program began running, in $BASETIME seconds since the epoch (beginning of 1970). The $^T values returned by the -M, -A, and -C filetests are based on this value. Reflects if taint mode is on or off. 1 for on (the ${^TAINT} program was run with -T), 0 for off, -1 when only taint warnings are enabled (i.e. with -t or -TU). ${^UNICODE} Reflects certain Unicode settings of Perl. This variable indicates whether an UTF-8 locale ${^UTF8LOCALE} was detected by perl at startup. The revision, version, and subversion of the Perl $PERL_VERSION interpreter, represented as a string composed of $^V characters with those ordinals. The current value of the warning switch, initially $WARNING true if -w was used, false otherwise, but directly $^W modifiable. (Mnemonic: related to the -w switch.) The current set of warning checks enabled by the ${^WARNING_BITS} use warnings pragma. The name used to execute the current copy of Perl, $EXECUTABLE_NAME from C's argv[0] or (where supported) $^X /proc/self/exe. The special filehandle that iterates over command- ARGV line filenames in @ARGV. Usually written as the null filehandle in the angle operator <> Contains the name of the current file when reading $ARGV from <>. The array @ARGV contains the command-line arguments intended for the script. $#ARGV is @ARGV generally the number of arguments minus one, because $ARGV[0] is the first argument, not the program's command name itself. The special filehandle that points to the currently open output file when doing edit-in-place ARGVOUT processing with -i. Useful when you have to do a lot of inserting and don't want to keep modifying $_. The array @F contains the fields of each line read @F in when autosplit mode is turned on. See perlrun for the -a switch. The array @INC contains the list of places that the do EXPR , require, or use constructs look for their @INC library files. It initially consists of the arguments to any -I command-line switches, followed by the default Perl library. Within a subroutine the array @_ contains the @_ parameters passed to that subroutine. The hash %INC contains entries for each %INC filename included via the do, require, or use operators. The hash %ENV contains your current %ENV environment. Setting a value in ENV changes the $ENV{expr} environment for any child processes you subsequently fork() off. sub handler { # 1st argument is signal name my($sig) = @_; print "Caught a SIG$sig\n"; close(LOG); exit(0); %SIG The hash %SIG contains signal handlers for } $SIG{expr} signals. $SIG{'INT'} = \&handler; $SIG{'QUIT'} = \&handler; # restore default action $SIG{'INT'} = 'DEFAULT'; # ignore SIGQUIT $SIG{'QUIT'} = 'IGNORE';