Perl Special Vars Quick Reference

Document Sample
Perl Special Vars Quick Reference Powered By Docstoc
					                                                                         ID's and Process Information
Perl Special Vars Quick                                           $$            Process ID
                                                                  $<
Reference
                                                                                Real user id of process.
                                                                  $>            Effective user id of process.
                                                                  $(            Real group id of process.
$_          The default or implicit variable.
                                                                  $)            Effective group id of process.
@_          Subroutine parameters.
                                                                  $0            Program name.
$a
            sort comparison routine variables.                    $^O           Operating System name.
$b

             Regular Expressions                                                      Perl Status Info
$<digit> Regexp parenthetical capture holders.                $]                Version and patch number of perl interpreter.
$&       Last successful match (degrades performance).        $^C               Current value of flag associated with -c switch.
         Prematch for last successful match string (degrades $^D                Current value of debugging flags
$`
         performance).                                        $^F               Maximum file descriptor.
         Postmatch for last successful match string (degrades $^I               Value of the -i (inplace edit) switch.
$'
         performance).                                        $^M               Emergency Memory pool.
$+       Last paren match.                                    $^P               Internal variable for debugging support.
$^N      Last closed paren match.                             $^R               Last regexp (?{code}) result.
@+       Offsets of ends of successful submatches in scope. $^S                 Exceptions being caught. (eval)
@-       Offsets of starts of successful submatches in scope. $^T               Base time of program start.
         Boolean for multi-line matching. Deprecated. Use /s $^V                Perl version.
$*
         and /m.
                                                              $^W               Status of -w switch
$^R      Last regexp (?{code}) result.
                                                              $^X               Perl executable name.
              IO and Separators
                                                                                Command Line Args
            Current line number (or record number) of most
$.                                                                              Filehandle iterates over files from command line
            recent filehandle.                                    ARGV
                                                                                (see also <>).
$/          Input record separator.
                                                                  $ARGV         Name of current file when reading <>
$|          Output autoflush. 1=autoflush, 0=default
                                                                  @ARGV         List of command line args.
$,          Output field separator (lists)
                                                                  ARGVOUT       Output filehandle for -i switch
$\          Output record separator.
$"          Output list separator. (interpolated lists)                               Miscellaneous
            Subscript separator. (Use a real multidimensional     @F            Autosplit (-a mode) recipient.
$;
            array instead.)                                       @INC          List of library paths.
                        Formats                                   %INC
                                                                                Keys are filenames, values are paths to modules
                                                                                included via use, require, or do.
$#          Output format for printed numbers (deprecated).
                                                                  %ENV          Hash containing current environment variables
$%          Page number for currently selected output channel.
                                                                  %SIG          Signal handlers.
$=          Current page length.
                                                                  $[            Array and substr first element (Deprecated!).
$-          Number of lines left on page.
$~          Format name.
$^          Name of top-of-page format.                           See perlvar for detailed descriptions of each of these (and a few
$:          Format line break characters                          more) special variables.
$^L         Form feed (default "\f").                             When modifiying special variables, it is often a good practice to
$^A         Format Accumulator                                    localize the effects of the change. ie,

                Status Reporting
            Child error. Status code of most recent system call           my @array = ( 1, 2, 3, 4, 5 );
$?                                                                        print "@array\n";
            or pipe.
                                                                          {
$!          Operating System Error. (What just went 'bang'?)                  local $" = "\t";
%!          Error number hash                                                 print "@array\n";
            Extended Operating System Error (Extra error                  }
$^E                                                                       print "@array\n";
            explanation).
$@          Eval error.