Jan 3, 2007

MISC #1, Reserved Variables

$_, $ARG
default input and pattern searching space

$
contains the reg expression specified within the parentheses from the last reg expression match

$&, $MATCH
String matched by last successful pattern match

$', $PREMATCH
string preceeding information matched by the last pattern match

$', $POSTMATCH
string following information matched by the last pattern match

$+, $LAST_PAREN_MATCH
last bracket match by the last regular expression search pattern

$*, $MULTILINE_MATCHING
Set to 1 to do multiline pattern matching within a string. default 0

$., $NR, $INPUT_LINE_NUMBER, input_line_number HANDLE EXPR
current input line no. of the last file read, can be either keyboard, ext file or other file handle

$/, $RS, $INPUT_RECORD_SEPARATOR, input_record_separator HANDLE EXPR
current input record separator. newline by default, can be undefined to read in entire file

$|, $OUTPUT_AUTOFLUSH, autoflush HANDLE EXPR
all output is buffered by default, periodically flushed. Value is thus set to 0. If value is non-zero, file handle will be auto-flushed after each write operation

$, $OFS, $OUTPUT_FIELD_SEPARATOR, output_field_separator HANDLE EXPR
default output separator for the print series of functions. default is comma separated

$\, $ORS, $OUTPUT_RECORD_SEPARATOR, output_record_separator HANDLE EXPR
default output record separator. Ordinarily, none

$", $LIST_SEPARATOR
defines the separator inserted between elements of array output within a double-quoted string. Default is single space

$;, $SUBSEP, $SUBSCRIPT_SEPARATOR
separator used when emulating multi-dimensional arrays. default "\034"

$#, $OFMT
default number format to use when printing numbers

$%, $FORMAT_PAGE_NUMBER
page number of current output channel

$=, $FORMAT_LINES_PER_PAGE
no. of printable lines of the current page

$-, $FORMAT_LINES_LEFT
no. of lines available to print on the current page

$~, $FORMAT_NAME
name of the current report format in used by the current output channel. default to name of file handle

$^, $FORMAT_TOP_NAME
name of current top-of-page output format for the current output channel. default is the filehandle with _TOP appended

$:, $FORMAT_LINE_BREAK_CHARACTERS
set of characters after which aa string may be broken to fill continuation fields. Default is "\n-"

$^L, $FORMAT_FORMFEED
character to be used to send a form feed to the output channel. default '\b'

$ARGV
name of current file when reading from the default filehandle <>

$^A, $ACCUMULATOR
when outputting formatted information via the reporting system, the formline functions put the formatted results into $^A, and the write function then outputs and empties the accumulator variable. This the current value of the write accumulator for format lines.

$?, $CHILD_ERROR
status returned by the last external command or last pipe close. This is the value returned by wait, so the true return value is $? >> 8, and $? &127 is the number of the signal received by the process, if appropriate

$!, $ERRNO, $OS_ERROR
returns the error number or error string according to the context in which it is used

$^E, $EXTENDED_OS_ERROR
contains extended error info for OSs other than Unix. In unix, $^E = $!

$@, $EVAL_ERROR
error msg returned by the Perl interpreter after executing the eval function. if null, last eval call is successful.

$$, $PID, $PROCESS_ID
process no. of Perl Interpreter executing the current script

$<, $UID, $REAL_USER_ID
real ID of the user currently executing the interpreter that is executing the script

$>, $EUID, $EFFECTIVE_USER_ID
effective user id of the current process

$(, $GID, $REAL_GROUP_ID
real group id of current process. If OS supports multi-simultaneous group membership, this returns a space-separated list of group ids

$), $EGID, $EFFECTIVE_GROUP_ID
effective group id of the current process

$0, $PROGRAM_NAME
name of the current file containing the script currently being executed

$[
index of 1st element in array or first character in a substring

$], $PERL_VERSION
version + patchlevel\1000 of the Perl interpreter

$^D, $DEBUGGING
value of current debugging flag

$^F, $SYSTEM_FD_MAX
max system file descriptor no. - usually 2. System file descriptors are duplicated across exec'd processes, although higher descriptors are not

$^H
status of syntax checks enabled by compiler hints, such as use strict

$^I, $INPLACE_EDIT
value of inplace-edit extension (enabled via the -i switch on the cmd line)

$^M
size of emergency pool reserved for use by Perl and the die function when Perl runs out of memory. The only standard method available for trapping Perl memory overuse during execution

$^O, $OSNAME
operating system name

$^P, $PERLDB
interval variable that enables you to specify the debugging value.

$^R
value of last evaluation in a (?{ code }) block within a reg expression

$^S
current interpreter state. Value is undefined if parsing of the current module is not finished. It is true if inside and evaluation block, otherwise false.

$^T, $BASETIME
time at which the script starts running, defined as no of seconds since Epoch

$^W, $WARNING
current value of the warning switch (specified via the -w cmd line option)

$^X, $EXECUTABLE_NAME
name of the Perl binary being executed, determined via the value of C's argv[0].

No comments: