Perl stuff.
See also: PerlErrorCodes
A URL with lots of useful perl stuff:
Notes on special variables in perl:
Information from System Files
- passwd
- Returns ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell).
- endpwent Ends lookup processing.
- getpwent Gets next user information.
- getpwnam NAME Gets information by name.
- getpwuid UID Gets information by user ID.
- setpwent Resets lookup processing.
- group
- Returns ($name, $passwd, $gid, $members).
- endgrent Ends lookup processing.
- getgrgid GID Gets information by group ID.
- getgrnam NAME Gets information by name.
- getgrent Gets next information.
- setgrent Resets lookup processing.
- hosts
- Returns ($name, $aliases, $addrtype, $length, @addrs).
- endhostent Ends lookup processing.
- gethostbyaddr ADDR, ADDRTYPE Gets information by IP address.
- gethostbyname NAME Gets information by hostname.
- gethostent Gets next host information.
- sethostent STAYOPEN Resets lookup processing.
- networks
- Returns ($name, $aliases, $addrtype, $net).
- endnetent Ends lookup processing.
- getnetbyaddr ADDR, TYPE Gets information by address and type.
- getnetbyname NAME Gets information by network name.
- getnetent Gets next network information.
- setnetent STAYOPEN Resets lookup processing.
- services
- Returns ($name, $aliases, $port, $proto).
- endservent Ends lookup processing.
- getservbyname NAME, PROTO Gets information by service name.
- getservbyport PORT, PROTO Gets information by service port.
- getservent Gets next service information.
- setservent STAYOPEN Resets lookup processing.
- protocols
- Returns ($name, $aliases, $proto).
- endprotoent Ends lookup processing.
- getprotobyname NAME Gets information by protocol name.
- getprotobynumber NUMBER Gets information by protocol number.
- getprotoent Gets next protocol information.
- setprotoent STAYOPEN Resets lookup processing.
- Back to Contents or Index
Special Variables
- The following variables are global and should be localized in subroutines:
- $_ The default input and pattern-searching space.
- $. The current input line number of the last filehandle that was read.
- $/ The input record separator, newline by default. May be multicharacter.
- $, The output field separator for the print operator.
- $" The separator that joins elements of arrays interpolated in strings.
- $\ The output record separator for the print operator.
- $# The output format for printed numbers. Deprecated.
- $* Set to 1 to do multiline matching within strings. Deprecated, see the m and s modifiers in section Search and Replace Functions.
$? The status returned by the last ... command, pipe close or system operator.
- $] The perl version number, e.g., 5.001.
- $[ The index of the first element in an array, and of the first character in a substring. Default is 0. Deprecated.
- $; The subscript separator for multidimensional array emulation. Default is "\034".
- $! If used in a numeric context, yields the current value of errno. If used in a string context, yields the corresponding error string.
- $@ The Perl error message from the last eval or do EXPR command.
- $: The set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format.
- $0 The name of the file containing the Perl script being executed. May be assigned to.
- $$ The process ID of the currently executing Perl program. Altered (in the child process) by fork.
$< The real user ID of this process.
$> The effective user ID of this process.
- $( The real group ID of this process.
- $) The effective group ID of this process.
- $^A The accumulator for formline and write operations.
- $^D The debug flags as passed to perl using -D.
- $^F The highest system file descriptor, ordinarily 2.
- $^I In-place edit extension as passed to Perl using -i.
- $^L Formfeed character used in formats.
- $^P Internal debugging flag.
- $^T The time (as delivered by time) when the program started. This value is used by the file test operators -M, -A and -C.
- $^W The value of the -w option as passed to Perl.
- $^X The name by which the currently executing program was invoked.
The following variables are context dependent and need not be localized:
- $% The current page number of the currently selected output channel.
- $= The page length of the current output channel. Default is 60 lines.
- $- The number of lines remaining on the page.
- $~ The name of the current report format.
- $^ The name of the current top-of-page format.
- $| If set to nonzero, forces a flush after every write or print on the currently selected output channel. Default is 0.
$ARGV The name of the current file when reading from <>.
The following variables are always local to the current block:
$& The string matched by the last successful pattern match.
- $` The string preceding what was matched by the last successful match.
- $' The string following what was matched by the last successful match.
- $+ The last bracket matched by the last search pattern.
- $1...$9... Contain the subpatterns from the corresponding sets of parentheses in the last pattern successfully matched. $10... and up are only available if the match contained that many subpatterns.
Special Arrays
- @ARGV Contains the command-line arguments for the script (not including the command name).
- @EXPORT Names the methods a package exports by default.
- @EXPORT_OK Names the methods a package can export upon explicit request.
- @INC Contains the list of places to look for Perl scripts to be evaluated by the do FILENAME and require commands.
- @ISA List of base classes of a package.
- @_ Parameter array for subroutines. Also used by split if not in array context.
- %ENV Contains the current environment.
- %INC List of files that have been included with require or do.
- %OVERLOAD Can be used to overload operators in a package.
- %SIG Used to set signal handlers for various signals.
Environment Variables
Perl uses the following environment variables.
- HOME Used if chdir has no argument.
- LOGDIR Used if chdir has no argument and HOME is not set.
- PATH Used in executing subprocesses, and in finding the Perl script if -S is used.
- PERL5LIB A colon-separated list of directories to look in for Perl library files before looking in the standard library and the current directory.
- PERL5DB The command to get the debugger code.
- Defaults to BEGIN { require 'perl5db.pl' }.
- PERLLIB Used instead of PERL5LIB if the latter is not defined.