home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-25 | 50.7 KB | 1,772 lines |
- Newsgroups: comp.sources.misc
- From: jv@mh.nl (Johan Vromans)
- Subject: v28i079: perlref - Perl Reference Guide 4.019.1 [LaTeX and Postscript], Part03/03
- Message-ID: <1992Feb26.175901.25635@sparky.imd.sterling.com>
- X-Md4-Signature: e72592e610c148d01f42310f0835e3c5
- Date: Wed, 26 Feb 1992 17:59:01 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: jv@mh.nl (Johan Vromans)
- Posting-number: Volume 28, Issue 79
- Archive-name: perlref/part03
- Environment: Perl, Postscript, Latex
-
- #!/bin/sh
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file refbase.sty continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 3; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping refbase.sty'
- else
- echo 'x - continuing file refbase.sty'
- sed 's/^X//' << 'SHAR_EOF' >> 'refbase.sty' &&
- %
- %%%%%%%%%%%%%%%% Macros %%%%%%%%%%%%%%%%
- %
- \chardef\other=12
- %
- % |lit| is used to represent literal things.
- % Representation is a fixed font.
- {\catcode`\|=\active
- \gdef|{\leavevmode%
- \begingroup\catcode`\\=\other\catcode`\{=\other%
- \catcode`\}=\other\catcode`\$=\other\catcode`\&=\other%
- \catcode`\#=\other\catcode`\~=\other%
- \catcode`\_=\other\catcode`\^=\other\catcode`\<=\other%
- \catcode`\[=\other%
- \obeyspaces\obeylines%
- \let|=\endgroup\escapechar`\|\catcode`\%=\other\tt}}
- \catcode`\|=\active
- X
- % <var> is used for variable things.
- % Representation is 10pt sans-serif uppercased.
- \catcode`\<=\active
- \def<{\leavevmode\italicizerest}
- \def\italicizerest#1>{{\small\sf\uppercase{#1}}}
- X
- % LaTeX active and 'hot' characters
- \def\|{\leavevmode\hbox{\tt\char`\|}}
- \def\<{\leavevmode\hbox{\tt\char`\<}}
- \def\>{\leavevmode\hbox{\tt\char`\>}}
- \def\^{\leavevmode\hbox{\tt\char`\^}}
- \def\${\leavevmode\hbox{\tt\char`\$}}
- \def\%{\leavevmode\hbox{\tt\char`\%}}
- \def\&{\leavevmode\hbox{\tt\char`\&}}
- \def\{{\leavevmode\hbox{\tt\char`\{}}
- \def\}{\leavevmode\hbox{\tt\char`\}}}
- \def\_{\leavevmode\hbox{\tt\char`\_}}
- X
- % Keywords
- % Representation is 10pt sans-serif bold.
- \def\kwd#1{{\small\bf #1}}
- X
- % Definitions
- \def\oEXPR{<expr>\dag}
- X
- %%%%%%%%%%%%%%%% Enumerations %%%%%%%%%%%%%%%%
- %
- % Usage:
- %
- % \begin{enum}{width}
- % \Xi{Blah} blah blah...
- % \Xi{Blah} bla ...
- % ...
- % \end{enum}
- %
- \newlength{\@xli}
- \newlength{\@xlj}
- \def\enum#1{
- X \list{}{
- X \setlength{\topsep}{0pt plus 1pt}
- X \setlength{\partopsep}{0pt plus 1pt}
- X \setlength{\itemsep}{0pt plus 1pt}
- X \setlength{\parsep}{\parskip}
- X \setlength{\itemindent}{0pt}
- X \setlength{\labelsep}{5pt}
- X \setlength{\labelwidth}{#1}
- X \setlength{\leftmargin}{\labelwidth}
- X \addtolength{\labelwidth}{-\labelsep}
- X \setlength{\@xli}{\labelwidth}
- X \def\makelabel##1{##1\hss}}}
- X
- % List element that overflows if it is too wide
- \def\Xi#1{
- X \settowidth{\@xlj}{#1}
- X \item[{#1}]
- X \ifnum\@xlj>\@xli
- X \strut\newline
- X \fi}
- % List element that does not overflow if it is too wide
- \def\Xj#1{\item[#1]}
- X
- \let\endenum=\endlist
- X
- %%%%%%%%%%%%%%%% Emacs support %%%%%%%%%%%%%%%%
- %
- % Local Variables:
- % eval:(auto-fill-mode 0)
- % eval:(headers)
- % eval:(setq comment-start "% ")
- % eval:(setq comment-start-skip "% +")
- % End:
- SHAR_EOF
- echo 'File refbase.sty is complete' &&
- chmod 0444 refbase.sty ||
- echo 'restore of refbase.sty failed'
- Wc_c="`wc -c < 'refbase.sty'`"
- test 6963 -eq "$Wc_c" ||
- echo 'refbase.sty: original size 6963, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= refbase.tex ==============
- if test -f 'refbase.tex' -a X"$1" != X"-c"; then
- echo 'x - skipping refbase.tex (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting refbase.tex (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'refbase.tex' &&
- \def\revision{1}
- \documentstyle{refbase}
- X
- \begin{document}
- X
- X
- \begin{titlepage}
- X
- \hbox{ }
- \end{titlepage}
- X
- \begin{titlepage}
- \addtolength{\evensidemargin}{2cm}
- \addtolength{\textwidth}{-2.1cm}
- \vspace*{2.5cm}
- X
- \unnumbered{Perl Reference Guide}
- {\bf for Perl version \perlrev}
- X
- \vskip1cm
- Perl program designed and created by \\
- Larry Wall \<lwall@netlabs.com\>
- X
- \vskip1cm
- Reference guide designed and created by \\
- Johan Vromans \<jv@mh.nl\>
- X
- \vskip1.5cm
- \unnumbered{Contents}
- X
- \newcounter{xx}
- \begin{list}{\thexx.}
- {\setlength{\topsep}{0pt plus 1pt}
- X \setlength{\itemsep}{0pt plus 1pt}
- X \setlength{\parsep}{0pt plus 1pt}
- X \usecounter{xx}}
- \item Command line options
- \item Literals
- \item Variables
- \item Statements
- \item Flow control
- \item Operators
- \item File test operators
- \item Arithmetic functions
- \item Conversion functions
- \item Structure conversion
- \item String functions
- \item Array and list functions
- \item File operations
- \item Directory reading routines
- \item Input / Output
- \item Search and replace functions
- \item System interaction
- \item Networking
- \item SystemV IPC
- \item Miscellaneous
- \item Formats
- \item Info from system files
- \item Regular expressions
- \item Special variables
- \item Special arrays
- \item The perl debugger
- \end{list}
- \vskip1cm
- {\catcode`\%=\other \small {Rev. \refrev}}
- \end{titlepage}
- X
- \unnumbered{Conventions}
- X
- \begin{enum}{2cm}
- \Xi{|fixed|} denotes literal text.
- X
- \Xi{<this>} means variable text, i.e. things you must fill in.
- X
- \Xi{<this>\dag} means that <this> will default to |$_| if omitted.
- X
- \Xi{\kwd{word}} is a keyword, i.e. a word with a special meaning.
- X
- \Xi{\fbox{<ret>}} denotes pressing a keyboard key.
- X
- \Xi{[\ldots]} denotes an optional part.
- X
- \Xi{(\ldots)*} means that the parentheses may be omitted.
- X
- \end{enum}
- X
- X
- \section{Command line options}
- X
- \begin{enum}{1cm}
- X
- \Xi{|-a|} turns on autosplit mode when used with |-n| or
- |-p|. Splits to |@F|.
- X
- \Xi{|-c|} checks syntax but does not execute.
- X
- \Xi{|-d|} runs the script under the debugger. Use |-de 0| to
- start the debugger without a script.
- X
- \Xi{|-D| <number>} sets debugging flags.
- X
- \Xi{|-e| <commandline>} may be used to enter one line of
- script. Multiple |-e| commands may be given to build up a
- multi-line script.
- X
- \Xi{|-i| <ext>} files processed by the |<>| construct are
- to be edited in-place.
- X
- \Xi{|-I| <dir>} with |-P|: tells the C preprocessor where
- to look for include files. The directory is prepended to |@INC|.
- X
- \Xi{|-L| <octnum>} enables automatic line ending processing.
- X
- \Xi{|-n|} assumes an input loop around your script. Lines are not
- printed.
- X
- \Xi{|-p|} assumes an input loop around your script. Lines are
- printed.
- X
- \Xi{|-P|} runs the C preprocessor on the script before
- compilation by perl.
- X
- \Xi{|-s|} interprets ``|-xxx|'' on the command line as
- switches and sets the corresponding variables \$|xxx| in the script.
- X
- \Xi{|-S|} uses the |PATH| environment variable to search for
- the script.
- X
- \Xi{|-u|} dumps core after compiling the script. To be used with
- the {\it undump\/} program (where available).
- X
- \Xi{|-U|} allows perl to do unsafe operations.
- X
- \Xi{|-v|} prints the version and patchlevel of your perl
- executable.
- X
- \Xi{|-w|} prints warnings about possible spelling errors and
- other error-prone constructs in the script.
- X
- \Xi{|-x|} extracts perl program from input stream.
- X
- \Xi{|-0| <val>} (that's the number zero) designates an
- initial value for the record terminator \$|/|.
- See also |-L|.
- X
- \end{enum}
- X
- \makeuppage
- X
- \section{Literals}
- X
- Numeric: |123 123.4 5E-10 0xff| (hex)| 0377| (octal).
- X
- \hangindent=2cm\hangafter=1
- String: |'abc'| literal string, no variable interpolation nor
- escape characters.
- \newline Also: |q/abc/|.
- \newline (Almost any pair of delimiters can be used instead of |/.../|.)
- X
- \hangindent=2cm\hangafter=1
- \makebox[1cm]{}|"abc"|
- Variables are interpolated and escape sequences are processed.
- \newline Also: |qq/abc/|.
- \newline Escape sequences: |\t| (Tab), |\n| (Newline), |\r| (Return),
- |\f| (Formfeed), |\b| (Backspace), |\a| (Alarm), |\e|
- (Escape), |\033|(octal), |\x1b|(hex), |\c[| (control).
- \newline |\l| and |\u| lowcase/upcase the following character;
- \newline |\L| and |\U| lowcase/upcase until a |\E| is encountered.
- X
- X
- \hangindent=2cm\hangafter=1
- \makebox[1cm]{}|`|<command>|`|
- evaluates to the output of the <command>.
- \newline Also: |qx/|<command>|/|.
- X
- \hangindent=1cm\hangafter=1
- Array: |(1,2,3)|. |()| is an empty array.
- \newline Also: |($a,$b,@rest) = (1,2,...);|
- \newline |(1..4)| is the same as |(1,2,3,4)|. Likewise |('abc'..'ade')|
- X
- \hangindent=1cm\hangafter=1
- Associative array:
- |(|<key1>|,|<val1>|,|<key2>|,|<val2>|,...)|
- X
- \hangindent=1cm\hangafter=1
- Filehandles:
- \newline Pre-defined: |<STDIN>|, |<STDOUT>|, |<STDERR>|, |<ARGV>|,
- |<DATA>|;
- \newline User-specified: |<|<handle>|>|, |<$|<var>|>|.
- \newline |<>| is the input stream formed by the files specified in
- |@ARGV|, or standard input if no arguments are supplied.
- X
- \hangindent=1cm\hangafter=1
- Globs: |<|<pattern>|>| evaluates to all filenames according
- to the pattern.
- \newline Use |<${|<var>|}>| to glob from a variable.
- X
- \hangindent=1cm\hangafter=1
- Here-Is: |<<|<identifier>
- \newline {\it See the manual for details.}
- X
- \hangindent=1cm\hangafter=1
- Special tokens:
- \newline \_\,\_|FILE|\_\,\_: filename; \_\,\_|LINE|\_\,\_: line number.
- \newline \_\,\_|END|\_\,\_: end of program; remaining lines can be read using
- \<<data>\>.
- X
- X
- \section{Variables}
- X
- \begin{enum}{3.2cm}
- X
- \Xi{|\$var|} a simple scalar variable
- X
- \Xi{|\$var[28]|} 29th element of array |@var| (the |[]| are
- part of it)
- X
- \Xi{|\$var\{'Feb'\}|} one value from associative array |%var|
- X
- \Xi{|\$\#var|} last index of array |@var|
- X
- \Xi{|@var|} the entire array;
- \\
- in scalar context: the number of elements in the array
- X
- \Xi{|@var[3,4,5]|} a slice of the array |@var|
- X
- \Xi{|@var\{'a','b'\}|} a slice of |%var|; same as
- |($var{'a'},$var{'b'})|
- X
- \Xi{|\%var|} the entire associative array;
- \\
- in scalar context: TRUE if the array has elements
- X
- \Xj{|\$var\{'a',1,...\}|} emulates a multi-dimensional array
- X
- \Xi{|('a'..'z')[4,7,9]|} a slice of an array literal
- X
- \Xi{|*|<name>} refers to all objects represented by <name>.
- ``|*name1 = *name2|'' makes |name1| a reference to |name2|.
- X
- \end{enum}
- X
- X
- \section{Statements}
- X
- Every statement is an expression, optionally followed by a modifier,
- and terminated by a semi-colon.
- X
- Execution of expressions can depend on other expressions using one of
- the modifiers \kwd{if}, \kwd{unless}, \kwd{while} or \kwd{until},
- e.g.:
- X
- \quad <expr1> \kwd{if} <expr2> |;| \\
- \quad <expr1> \kwd{until} <expr2> |;|
- X
- Also, by using one of the logical operators \|\|, |&&| or |? :|, e.g.:
- X
- \quad <expr1> \|\| <expr2> |;| \\
- \quad <expr1> |?| <expr2> |:| <expr3> |;|
- X
- Statements can be combined to form a <block> when enclosed in |{}|.
- X
- Compound statements may be used to control flow:
- X
- \quad \kwd{if} |(|<expr>|)| <block> [ [ \kwd{elsif}
- X |(|<expr>|)| <BLOCK ...> ] \kwd{else}
- X <block> ]
- \\
- \quad \kwd{unless} |(|<expr>|)| <block> [ \kwd{else}
- X <block> ]
- \\
- \quad [ <label>\kwd{:} ] \kwd{while} |(|<expr>|)|
- X <block> [ \kwd{continue} <block> ]
- \\
- \quad [ <label>\kwd{:} ] \kwd{until} |(|<expr>|)|
- X <block> [ \kwd{continue} <block> ]
- \\
- \quad [ <label>\kwd{:} ] \kwd{for} |(|<expr>|;|
- X <expr>|;| <expr>|)| <block>
- \\
- \quad [ <label>\kwd{:} ] \kwd{foreach} <var>\dag
- X |(|<array>|)| <block>
- \\
- \quad [ <label>\kwd{:} ] <block> [ \kwd{continue} < block> ]
- X
- Special forms are:
- X
- \quad \kwd{do} <block> \kwd{while} <expr> |;| \\
- \quad \kwd{do} <block> \kwd{until} <expr> |;| \\
- X
- which are guaranteed to perform <block> once before testing <expr>.
- X
- X
- X
- \section{Flow control}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{do} <block>}
- Returns the value of the last command in the sequence of commands indicated by <block>. \kwd{next}, \kwd{last} and \kwd{redo}
- X cannot be used here.
- X
- \Xi{\kwd{do} <subroutine>\kwd{(LIST)}}
- Executes a <subroutine> declared by a \kwd{sub} declaration, and
- returns the value of the last expression evaluated in <subroutine> .
- \newline Preferred form is: |&|<subroutine> .
- X
- \Xi{\kwd{do} <FILENAME>}
- Executes the contents of <filename> as a perl script. Errors are
- returned in |$@|.
- \newline Preferred form is: \kwd{require} <filename> .
- X
- \Xi{\kwd{goto} <label>}
- Continue execution at the specified label.
- X
- \Xi{\kwd{last} [<label>]}
- Immediately exits the loop in question. Skips continue block.
- X
- \Xi{\kwd{next} [<label>]}
- Starts the next iteration of the loop.
- X
- \Xi{\kwd{redo} [<label>]}
- Restarts the loop block without evaluating the conditional again.
- X
- \Xi{\kwd{return} <expr>}
- Returns from a subroutine with the value specified.
- X
- \end{enum}
- X
- X
- \section{Operators}
- X
- \begin{tabbing}
- | |\=| |\= \kill
- |+ -| \> |* /| \> Addition, subtraction, multiplication, division. \\
- |%| \> \> Modulo division. \\
- \| \& \> \^ \> Bitwise or, bitwise and, bitwise exclusive or. \\
- |>>| \> |<<| \> Bitwise shift right, bitwise shift left. \\
- |**| \> \> Exponentiation. \\
- |.| \> \> Concatenation of two strings. \\
- \kwd{x} \> \> Returns a string or array consisting of the left operand
- (an array or \\
- \> \> a string) repeated the number of times specified by the right operand.
- \end{tabbing}
- X
- All of the above operators also have an assignment operator, e.g. ``|.=|''.
- X
- \begin{tabbing}
- | |\=| |\= \kill
- |++| \> |--| \> Auto-increment (magical on strings), auto-decrement. \\
- |? :|\> \> Alternation (if-then-else) operator. \\
- \|\| \> \&\& \> Logical or, logical and. \\
- |=|\,|=| \> |!=| \> Numeric equality, inequality. \\
- \kwd{eq} \> \kwd{ne} \> String equality, inequality. \\
- |<| \> |>| \> Numeric less than, greater than. \\
- \kwd{lt} \> \kwd{gt} \> String less than, greater than. \\
- |<=| \> |>=| \> Numeric less (greater) than or equal to. \\
- \kwd{le} \> \kwd{ge} \> String less (greater) than or equal. \\
- |<=>| \> \> Numeric compare. Returns -1, 0 or 1. \\
- \kwd{cmp} \> \> String compare. Returns -1, 0 or 1. \\
- |=~| \> |!~| \> Search pattern, substitution, or translation (negated). \\
- |..| \> \> Enumeration, also input line range operator. \\
- |,| \> \> Comma operator.
- \end{tabbing}
- X
- X
- \section{File test operators}
- X
- These unary operators takes one argument, either a filename or a
- filehandle, and tests the associated file to see if something is true
- about it. If the argument is omitted, tests |$_| (except for |-t,|
- which tests |STDIN|). If the special argument |_| (underscore) is
- passed, uses the info of the preceding test.
- X
- \begin{enum}{2.5cm}
- X
- \Xi{|-r -w -x -o|} File is readable/writable/executable/owned by
- effective uid.
- X
- \Xi{|-R -W -X -O|} File is readable/writable/executable/owned by real
- uid.
- X
- \Xi{|-e -z -s|} File exists / has zero/non-zero size.
- X
- \Xi{|-f -d|} File is a plain file, a directory.
- X
- \Xi{|-l -S -p|} File is a symbolic link, a socket, a named pipe (FIFO).
- X
- \Xi{|-b -c|} File is a block/character special file.
- X
- \Xi{|-u -g -k|} File has setuid/setgid/sticky bit set.
- X
- \Xi{|-t|} Tests if filehandle (|STDIN| by default) is opened to a tty.
- X
- \Xi{|-T -B|} File is a text/non-text (binary) file. |-T| and |-B|
- return TRUE on a null file, or a file at EOF when testing a filehandle.
- X
- \Xi{|-M -A -C|} File creation / access / inode change time. Measured
- in days since this program started. See also |$^T| in section
- ``Special~Variables''.
- X
- \end{enum}
- X
- \makeuppage
- X
- A <list> is a (possibly parenthesised) list of expressions, variables
- or <list>s. An array variable or an array slice may always be used
- instead of a <list>.
- X
- \section{Arithmetic functions}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{atan2(}<y>\kwd{,}<x>\kwd{)}}
- Returns the arctangent of <Y>/<X> in the range -$\pi$ to $\pi$.
- X
- \Xi{\kwd{cos(}\oEXPR \kwd{)}*}
- Returns the cosine of <expr> (expressed in radians).
- X
- \Xi{\kwd{exp(}\oEXPR \kwd{)}*}
- Returns |e| to the power of <expr>.
- X
- \Xi{\kwd{int(}\oEXPR \kwd{)}*}
- Returns the integer portion of <expr>.
- X
- \Xi{\kwd{log(}\oEXPR \kwd{)}*}
- Returns natural logarithm (base |e|) of <expr>.
- X
- \Xi{\kwd{rand}[\kwd{(}<expr>\kwd{)}*]}
- Returns a random fractional number between 0 and the value of <expr>.
- If <expr> is omitted, returns a value between 0 and 1.
- X
- \Xi{\kwd{sin(}\oEXPR \kwd{)}*}
- Returns the sine of <expr> (expressed in radians).
- X
- \Xi{\kwd{sqrt(}\oEXPR \kwd{)}*}
- Return the square root of <expr>.
- X
- \Xi{\kwd{srand}[\kwd{(}<expr>\kwd{)}*]}
- Sets the random number seed for the rand operator.
- X
- \Xi{\kwd{time}}
- Returns the number of seconds since January 1, 1970. Suitable for
- feeding to \kwd{gmtime} and \kwd{localtime}.
- X
- \end{enum}
- X
- X
- \section{Conversion functions}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{gmtime(}<expr>\kwd{)}*}
- Converts a time as returned by the \kwd{time} function to a 9-element
- array (\$sec, \$min, \$hour, \$mday, \$mon, \$year, \$wday,
- \$yday, \$isdst) with the time analyzed for the Greenwich timezone.
- \$mon has the range 0..11 and \$wday has the range 0..6.
- X
- \Xi{\kwd{hex(}\oEXPR\kwd{)}*}
- Returns the decimal value of <expr> interpreted as an hex string.
- X
- \Xi{\kwd{localtime(}<expr>\kwd{)}*}
- Converts a time as returned by the \kwd{time} function to a 9-element
- array with the time analyzed for the local timezone.
- X
- \Xi{\kwd{oct(}\oEXPR\kwd{)}*}
- Returns the decimal value of <expr> interpreted as an octal string. If
- <expr> starts off with |0x|, interprets it as a hex string instead.
- X
- \Xi{\kwd{ord(}\oEXPR\kwd{)}*}
- Returns the ascii value of the first character of <expr>.
- X
- \Xi{\kwd{vec(}<expr>\kwd{,}<offset>\kwd{,}<bits>\kwd{)}}
- Treats <expr> as a string of unsigned ints, and yields the bit at
- <offset>. <bits> must be between 1 and 32. May be used as an lvalue.
- X
- \end{enum}
- X
- X
- \section{Structure conversion}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{pack(}<template>\kwd{,}<list>\kwd{)}}
- Packs the values into a binary structure using <template>.
- X
- \Xi{\kwd{unpack(}<template>\kwd{,}<expr>\kwd{)}}
- Unpacks the structure <expr> into an array, using <template>.
- X
- <template> is a sequence of characters as follows:
- X
- \begin{tabbing}
- | |\=|a |\=|/ |\=|A |\= \kill
- X \> |a| \> / \> |A| \> Ascii string, null / space padded \\
- X \> |b| \> / \> |B| \> Bit string in ascending / descending order \\
- X \> |c| \> / \> |C| \> Native / unsigned char value \\
- X \> |f| \> / \> |d| \> Single / double float in native format \\
- X \> |h| \> / \> |H| \> Hex string, low / high nybble first. \\
- X \> |i| \> / \> |I| \> Signed / unsigned integer value \\
- X \> |l| \> / \> |L| \> Signed / unsigned long value \\
- X \> |n| \> / \> |N| \> Short / long in network byte order \\
- X \> |s| \> / \> |S| \> Signed / unsigned short value \\
- X \> |u| \> / \> |p| \> Uuencoded string / Pointer to a string \\
- X \> |x| \> / \> |@| \> Null byte / null fill until position \\
- X \> |X| \> \> \> Backup a byte
- \end{tabbing}
- X
- Each character may be followed by a decimal number which will be used
- as a repeat count, an |*| specifies all remaining arguments. \\
- If the format is preceded with |%|<n>, \kwd{unpack} returns an
- <n>-bit checksum instead. \\
- Spaces may be included in the template for readability purposes.
- X
- \end{enum}
- X
- X
- \section{String functions}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{chop(}<list>\dag\kwd{)}}
- Chops off the last character on all elements of the list; returns the
- last chopped character. The parentheses may be omitted if <list> is a
- single variable.
- X
- \Xi{\kwd{crypt(}<plaintext>\kwd{,}<salt>\kwd{)}}
- Encrypts a string.
- X
- \Xi{\kwd{eval(}\oEXPR \kwd{)}*}
- <expr> is parsed and executed as if it were a perl program. The value
- returned is the value of the last expression evaluated. If there is a
- syntax error or runtime error, an undefined string is returned by
- \kwd{eval}, and |$@| is set to the error message.
- X
- \Xi{\kwd{eval\{}<expr>\kwd{;...\}}}
- Executes the code between \{ and \}. Traps run-time errors as described
- above.
- X
- \Xi{\kwd{index(}<str>\kwd{,}<substr>[\kwd{,}<offset>]\kwd{)}}
- Returns the position of <substr> in <str> at or after <offset>. If the
- substring is not found, returns |$[-1|.
- X
- \Xi{\kwd{length(}\oEXPR\kwd{)}*}
- Returns the length in characters of the value of <expr>.
- X
- \Xi{\kwd{rindex(}<str>\kwd{,}<substr>[\kwd{,}<offset>]\kwd{)}}
- Returns the position of the last occurrence of <substr> in <str> at or
- before <offset>.
- X
- \Xi{\kwd{substr(}<expr>\kwd{,}<offset>[\kwd{,}<len>]\kwd{)}}
- Extracts a substring out of <expr> and returns it. If <offset>
- is negative, counts from the end of the string. May be used as an lvalue.
- X
- \end{enum}
- X
- X
- \section{Array and list functions}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{delete} \$<array>\{<key>\}}
- Deletes the specified value from the specified associative array.
- Returns the deleted value.
- X
- \Xi{\kwd{each(}|\%|<array>\kwd{)}*}
- Returns a 2-element array consisting of the key and value for the next
- value of an associative array. Entries are returned in an apparently
- random order. When the array is entirely read, a null array is
- returned. The next call to \kwd{each} after that will start iterating again.
- X
- \Xi{\kwd{grep(}<expr>\kwd{,}<list>\kwd{)}}
- Evaluates <expr> for each element of the <list>, locally setting |$_|
- to refer to the element. Modifying |$_| will modify the corresponding
- element from <list>. Returns array of elements from <list> for which
- <expr> returned true.
- X
- \Xi{\kwd{join(}<expr>\kwd{,}<list>\kwd{)}}
- Joins the separate strings of <list> into a single string with fields
- separated by the value of <expr>, and returns the string.
- X
- \Xi{\kwd{keys(}|\%|<array>\kwd{)}*}
- Returns an array with of all the keys of the named
- associative array.
- X
- \Xi{\kwd{pop(}|@|<array>\kwd{)}*}
- Pops and returns the last value of the array, shortens the array by 1.
- X
- \Xi{\kwd{push(}|@|<array>\kwd{,}<list>\kwd{)}}
- Pushes the values of <list> onto the end of <array>. The length of the
- array increases by the length of <list>.
- X
- \Xi{\kwd{reverse(}<list>\kwd{)}*}
- In array context: returns the <list> in reverse order. \\
- In scalar
- context: returns the first element of <list> with bytes reversed.
- X
- \Xi{\kwd{scalar(}|@|<array>\kwd{)}}
- Returns the number of elements in the array.
- X
- \Xi{\kwd{scalar(}|\%|<array>\kwd{)}}
- Returns TRUE if the associative array has elements defined.
- X
- \Xi{\kwd{shift}[\kwd{(}|@|<array>\kwd{)}*]}
- Shifts the first value of the array off and returns it, shortening the
- array by 1 and moving everything down. If |@|<array> is omitted, shifts
- |@ARGV| in main and |@_| in subroutines.
- X
- \Xi{\kwd{sort(} [<subroutine> ] <list>\kwd{)}*}
- Sorts the <list> and returns the sorted array value. If <subroutine>
- is specified, gives the name of a subroutine that returns less than
- zero, zero, or greater than zero, depending on how the elements of the
- array, available to the routine as |$a| and |$b|, are to be ordered.
- \\
- <SUBROUTINE> may be the name of a user-defined routine, or a <block>
- (see ``Statements'' and ``Miscellaneous'').
- X
- \Xi{\kwd{splice(}|@|<array>\kwd{,}<offset>[\kwd{,}<length>[\kwd{,}<list>]]\kwd{)}}
- Removes the elements of |@|<array> designated by <offset> and
- <length>, and replaces them with <list> (if specified). \\
- Returns the elements removed.
- X
- \Xi{\kwd{split}[\kwd{(}<pattern>[\kwd{,}\oEXPR [\kwd{,}<limit>]]\kwd{)}]}
- Splits a string into an array of strings, and returns it. If <limit>
- is specified, splits in no more than that many fields. If <pattern> is
- also omitted, splits on whitespace. If
- not in array context: returns number of fields and splits to |@_|.
- See also: ``Search and Replace Functions''.
- X
- \Xi{\kwd{unshift(}|@|<array>\kwd{,}<list>\kwd{)}}
- Prepends list to the front of the array, and returns the number of
- elements in the new array.
- X
- \Xi{\kwd{values(}|\%|<array>\kwd{)}*}
- Returns a normal array consisting of all the values of the named
- associative array.
- X
- \end{enum}
- X
- X
- X
- X
- \section{File operations}
- X
- Functions operating on a list of files return the number of files
- successfully operated upon.
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{chmod(}<list>\kwd{)}*}
- Changes the permissions of a list of files. The first element of the
- list must be the numerical mode.
- X
- \Xi{\kwd{chown(}<list>\kwd{)}*}
- Changes the owner and group of a list of files. The first two elements
- of the list must be the numerical uid and gid.
- X
- \Xi{\kwd{truncate(}<file>\kwd{,}<size>\kwd{)}}
- truncates <file> to <size>. <file> may be a filename or a filehandle.
- X
- \Xi{\kwd{link(}<oldfile>\kwd{,}<newfile>\kwd{)}}
- Creates a new filename linked to the old filename.
- X
- \Xi{\kwd{lstat(}<file>\kwd{)}}
- Like stat, but does not traverse a final symbolic link.
- X
- \Xi{\kwd{mkdir(}<dir>\kwd{,}<mode>\kwd{)}}
- Creates a directory with given permissions. Sets |$!| on failure.
- X
- \Xi{\kwd{readlink(}\oEXPR\kwd{)}*}
- Returns the value of a symbolic link.
- X
- \Xi{\kwd{rename(}<oldname>\kwd{,}<newname>\kwd{)}}
- Changes the name of a file.
- X
- \Xi{\kwd{rmdir(}<filename>\dag\kwd{)}*}
- Deletes the directory if it is empty. Sets |$!| on failure.
- X
- \Xi{\kwd{stat(}<file>\kwd{)}}
- Returns a 13-element array (\$dev, \$ino, \$mode, \$nlink, \$uid, \$gid,
- \$rdev, \$size, \$atime, \$mtime, \$ctime, \$blksize, \$blocks). <file> can
- be a filehandle, an expression evaluating to a filename, or |_| to
- refer to the last file test operation.
- X
- \Xi{\kwd{symlink(}<oldfile>\kwd{,}<newfile>\kwd{)}}
- Creates a new filename symbolically linked to the old filename.
- X
- \Xi{\kwd{unlink(}<list>\kwd{)}*}
- Deletes a list of files.
- X
- \Xi{\kwd{utime(}<list>\kwd{)}*}
- Changes the access and modification times. The first two elements of
- the list must be the numerical access and modification times.
- X
- \end{enum}
- X
- X
- X
- \makeuppage
- X
- \section{Directory reading routines}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{closedir(}<dirhandle>\kwd{)}*}
- Closes a directory opened by opendir.
- X
- \Xi{\kwd{opendir(}<dirhandle>\kwd{,}<dirname>\kwd{)}}
- Opens a directory on the handle specified.
- X
- \Xi{\kwd{readdir(}<dirhandle>\kwd{)}*}
- Returns the next entry (or an array of entries) in the directory.
- X
- \Xi{\kwd{rewinddir(}<dirhandle>\kwd{)}*}
- Positions the directory to the beginning.
- X
- \Xi{\kwd{seekdir(}<dirhandle>\kwd{,}<pos>\kwd{)}}
- Sets position for readdir on the directory.
- X
- \Xi{\kwd{telldir(}<dirhandle>\kwd{)}*}
- Returns the postion in the directory.
- X
- \end{enum}
- X
- X
- \section{Input / Output}
- X
- In input/output operations, <filehandle> may be a filehandle as opened
- by the \kwd{open} operator, or a scalar variable which evaluates to
- the name of a filehandle to be used.
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{binmode(}<filehandle>\kwd{)}*}
- Arranges for the file opened on <filehandle> to be read in ``binary''
- mode as opposed to ``text'' mode (MS-DOS only).
- X
- \Xi{\kwd{close(}<filehandle>\kwd{)}*}
- Closes the file or pipe associated with the file handle.
- X
- \Xi{\kwd{dbmclose(}|\%|<array>\kwd{)}*}
- Breaks the binding between the array and the dbm file.
- X
- \Xi{\kwd{dbmopen(}|\%|<array>\kwd{,}<dbmname>\kwd{, }<mode>\kwd{)}}
- Binds a dbm or ndbm file to the associative array. If the database
- does not exist, it is created with the indicated mode.
- X
- \Xi{\kwd{eof(}<filehandle>\kwd{)}}
- Returns 1 if the next read will return end of file, or if the file is
- not open.
- X
- \Xi{\kwd{eof}}
- Returns the eof status for the last file read.
- X
- \Xi{\kwd{eof( )}}
- Indicates eof on the pseudo file formed of the files listed on the
- command line.
- X
- \Xi{\kwd{fcntl(}<filehandle>\kwd{,}<function>\kwd{,}|\$|<var>\kwd{)}}
- Implements the {\it fcntl\/}(2) function. This function has non-standard
- return values. See the manual for details.
- X
- \Xi{\kwd{fileno(}<filehandle>\kwd{)}*}
- Returns the file descriptor for a given (open) file.
- X
- \Xi{\kwd{flock(}<filehandle>\kwd{,}<operation>\kwd{)}}
- Calls {\it flock\/}(2) on the file. <operation> adds from 1 (shared), 2
- (exclusive), 4 (non-blocking) or 8 (unlock).
- X
- X
- \Xi{\kwd{getc}[\kwd{(}<filehandle>\kwd{)}*]}
- Yields the next character from the file, or |""| on EOF. If
- <filehandle> is omitted, reads from |STDIN|.
- X
- \Xi{\kwd{ioctl(}<filehandle>\kwd{,}<function>\kwd{,}|\$|<var>\kwd{)}}
- performs {\it ioctl}(2) on the file. This function has non-standard
- return values. See the manual for details.
- X
- \Xi{\kwd{open(}<filehandle>[\kwd{,}<filename>]\kwd{)}}
- Opens a file and associates it with <filehandle>. If <filename> is
- omitted, the scalar variable of the same name as the <filehandle> must
- contain the filename.
- X
- The following filename conventions apply when opening a file.
- X
- \begin{enum}{2cm}
- \Xi{|"|<file>|"|} open <file> for input. Also |"<|<file>|"|.
- X
- \Xi{|">|<file>|"|} open <file> for output, creating it if necessary.
- X
- \Xi{|">>|<file>|"|} open <file> in append mode.
- X
- \Xi{|"+>|<file>|"|} open <file> with read/write access.
- X
- \Xi{|"\||<cmd>|"|} opens a pipe to command <cmd>.
- X
- \Xi{|"|<cmd>|\|"|} opens a pipe from command <cmd>.
- \end{enum}
- X
- <file> may be |&|<filehnd> in which case the new file handle is
- connected to the (previously opened) filehandle <filehnd>.
- X
- \kwd{open}
- returns 1 upon success, \kwd{undef} otherwise, except for pipes. The
- parentheses may be omitted, if only a <filehandle> is specified.
- X
- \Xi{\kwd{pipe(}<readhandle>\kwd{,}<writehandle>\kwd{)}}
- Returns a pair of connected pipes.
- X
- \Xi{\kwd{print}[\kwd{(}[<filehandle>]<list>\dag\kwd{)}*]}
- Prints a string or a comma-separated list of strings. If <filehandle>
- is omitted, prints by default to standard output (or to the last
- selected output channel - see \kwd{select}).
- X
- \Xi{\kwd{printf}[\kwd{(}[<filehandle>] <list>\kwd{)}*]}
- Equivalent to \kwd{print} <filehandle> \kwd {sprintf(}<list>\kwd{)}.
- X
- \Xi{\kwd{read(}<filehandle>\kwd{,}|\$|<var>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
- Read <length> binary bytes from the file into the variable at
- <offset>. Returns number of bytes actually read.
- X
- \Xi{\kwd{seek(}<filehandle>\kwd{,}<position>\kwd{,}<whence>\kwd{)}}
- Arbitrarily positions the file. Returns 1 upon success, 0 otherwise.
- X
- \Xi{\kwd{select}[\kwd{(}<filehandle>\kwd{)}]}
- Returns the currently selected filehandle.
- Sets the current default filehandle for output operations if
- <filehandle> is supplied.
- X
- \Xi{\kwd{select(}<rbits>\kwd{,}<wbits>\kwd{,}<nbits>\kwd{,}<timeout>\kwd{)}}
- Performs a {\it select\/}(2) system call with the same parameters.
- X
- \Xi{\kwd{sprintf(}<format>\kwd{,}<list>\kwd{)}}
- Returns a string formatted by (almost all of) the usual printf
- conventions.
- X
- \Xi{\kwd{sysread(}<filehandle>\kwd{,}|\$|<var>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
- Reads <length> bytes into |$|<var> at <offset>.
- X
- \Xi{\kwd{syswrite(}<filehandle>\kwd{,}<scalar>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
- Writes <length> bytes from <scalar> at <offset>.
- X
- \Xi{\kwd{tell}[\kwd{(}<filehandle>\kwd{)}]*}
- Returns the current file position for the file. If <filehandle> is
- omitted, assumes the file last read.
- X
- \Xi{\kwd{write}[\kwd{(}<filehandle>\kwd{)}]*}
- Writes a formatted record to the specified file, using the format
- associated with that file. See ``Formats''.
- X
- \end{enum}
- X
- \makeuppage
- X
- \section{Search and replace functions}
- X
- \begin{enum}{1cm}
- X
- \catcode`\~=\other
- X
- \Xi{[<expr> |=~|] [\kwd{m}]|/|<pattern>|/|[\kwd{g}][\kwd{i}][\kwd{o}]}
- Searches <expr> (default: |$_|) for a pattern. If you prepend an
- \kwd{m} you can use almost any pair of characters as delimiters. If
- used in array context, an array is returned consisting of the
- subexpressions matched by the parentheses in pattern, i.e.
- |($1,$2,$3,...)|.
- \\
- Optional modifiers: \kwd{g} matches as many times as possible; \kwd{i}
- searches in a case-insensitive manner; \kwd{o} interpolates variables
- only once.
- \\
- If <pattern> is empty, the most recent pattern from a
- previous match or replacement is used.
- \\
- With \kwd{g} the match can be used as an iterator in scalar context.
- X
- \Xi{|?|<pattern>|?|}
- This is just like the |/|<pattern>|/| search, except that it matches
- only once between calls to the reset operator. If <pattern> is empty,
- the most recent pattern from a previous match or replacement is used.
- X
- \Xi{[|\$|<var> |=~|] \kwd{s}|/|<pattern>|/|<replacement>|/|[\kwd{g}][\kwd{i}][\kwd{e}][\kwd{o}]}
- Searches a string for a pattern, and if found, replaces that pattern
- with the replacement text and returns the number of substitutions
- made. Otherwise it returns false.
- \\
- Optional modifiers: \kwd{g} replaces all occurrences of the pattern;
- \kwd{e} interprets the replacement string as an expression; \kwd{i}
- and \kwd{o} as with |/|<pattern>|/| matching. Almost any delimiter may
- replace the slashes; if single quotes are used, no interpretation is
- done on the replacement string.
- \\
- If <pattern> is empty, the most recent pattern from a previous match or replacement is used.
- X
- \Xi{\kwd{study}[\kwd{(}|\$|<var>\dag\kwd{)}*]}
- Study the contents of |$|<var> in anticipation of doing many pattern
- matches on the contents before it is next modified.
- X
- \Xi{[|\$|<var> |=~|] \kwd{tr}|/|<searchlist>|/|<replacementlist>|/|[\kwd{c}][\kwd{d}][\kwd{s}]}
- Translates all occurrences of the characters found in the search list
- with the corresponding character in the replacement list. It returns
- the number of characters replaced. \kwd{y} may be used instead of \kwd{tr}.
- \\
- Optional modifiers: \kwd{c} complements the <searchlist>; \kwd{d}
- deletes all characters not found in <searchlist>; \kwd{s} squeezes all
- sequences of characters that are translated into the same target
- character into one occurrence of this character.
- X
- \end{enum}
- X
- X
- \section{System interaction}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{alarm(}<expr>\kwd{)}*}
- Schedules a |SIGALRM| to be delivered after <expr> seconds.
- X
- \Xi{\kwd{chdir} [\kwd{(}<expr>\kwd{)}*]}
- Changes the working directory, |$ENV{"HOME"}| if <expr> is omitted.
- X
- \Xi{\kwd{chroot(}<filename>\dag\kwd{)}*}
- Changes the root directory for the process and its children.
- X
- \Xi{\kwd{die}[\kwd{(}<list>\kwd{)}*]}
- Prints the value of <list> to |STDERR| and exits with the current
- value of |$!| (errno). If |$!| is 0, exits with the value of |($? >> 8)|.
- If |($? >> 8)| is 0, exits with 255. <list> defaults to
- |"Died."|.
- X
- \Xi{\kwd{exec(}<list>\kwd{)}*}
- Executes the system command in <list>; does not return.
- X
- \Xi{\kwd{exit(}<expr>\kwd{)}*}
- Exits immediately with the value of |EXPR|.
- X
- \Xi{\kwd{fork}}
- Does a {\it fork\/}(2) system call. Returns the child pid to the parent
- process and zero to the child process.
- X
- \Xi{\kwd{getlogin}}
- Returns the current login name as known by the system.
- X
- \Xi{\kwd{getpgrp}[\kwd{(}<pid>\kwd{)}*]}
- Returns the process group for process <pid> (0, or omitted, means the
- current process).
- X
- \Xi{\kwd{getppid}}
- Returns the process id of the parent process.
- X
- \Xi{\kwd{getpriority(}<which>\kwd{,}<who>\kwd{)}}
- Returns the current priority for a process, process group, or user.
- X
- \Xi{\kwd{kill(}<list>\kwd{)}*}
- Sends a signal to a list of processes. The first element of the list
- must be the signal to send (numeric, or its name as a string).
- X
- \Xi{\kwd{setpgrp(}<pid>\kwd{,}<pgrp>\kwd{)}}
- Sets the process group for the <pid> (0 = current process).
- X
- \Xi{\kwd{setpriority(}<which>\kwd{,}<who>\kwd{,}<prio>\kwd{)}}
- Sets the current priority for a process, process group, or a user.
- X
- \Xi{\kwd{sleep}[\kwd{(}<expr>\kwd{)}*]}
- Causes the script to sleep for <expr> seconds, or forever if no
- <expr>. Returns the number of seconds actually slept.
- X
- \Xi{\kwd{syscall(}<list>\kwd{)}*}
- Calls the system call specified in the first element of the list,
- passing the rest of the list as arguments to the call.
- X
- \Xi{\kwd{system(}<list>\kwd{)}*}
- Does exactly the same thing as \kwd{exec }<list> except that a fork is
- done first, and the parent process waits for the child process to complete.
- X
- \Xi{\kwd{times}}
- Returns a 4-element array (\$user, \$system, \$cuser, \$csystem) giving
- the user and system times, in seconds, for this process and the
- children of this process.
- X
- \Xi{\kwd{umask}[\kwd{(}<expr>\kwd{)}*]}
- Sets the umask for the process and returns the old one. If <expr> is
- omitted, returns current umask value.
- X
- \Xi{\kwd{wait}}
- Waits for a child process to terminate and returns the pid of the
- deceased process (-1 if none). The status is returned in |$?|.
- X
- \Xi{\kwd{waitpid(}<pid>\kwd{,}<flags>\kwd{)}}
- Performs the same function as the corresponding system call.
- X
- \Xi{\kwd{warn(}<list>\kwd{)}*}
- Prints the message on |STDERR| like \kwd{die}, but doesn't exit.
- X
- \end{enum}
- X
- \makeuppage
- X
- \section{Networking}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{accept(}<newsocket>\kwd{,}<genericsocket>\kwd{)}}
- Accepts a new socket.
- X
- \Xi{\kwd{bind(}<socket>\kwd{,}<name>\kwd{)}}
- Binds the <name> to the <socket>.
- X
- \Xi{\kwd{connect(}<socket>\kwd{,}<name>\kwd{)}}
- Connects the <name> to the <socket>.
- X
- \Xi{\kwd{getpeername(}<socket>\kwd{)}}
- Returns the socket address of the other end of the <socket>.
- X
- \Xi{\kwd{getsockname(}<socket>\kwd{)}}
- Returns the name of the socket.
- X
- \Xi{\kwd{getsockopt(}<socket>\kwd{,}<level>\kwd{,}<optname>\kwd{)}}
- Returns the socket options.
- X
- \Xi{\kwd{listen(}<socket>\kwd{,}<queuesize>\kwd{)}}
- Starts listening on the specified <socket>.
- X
- \Xi{\kwd{recv(}<socket>\kwd{,}<scalar>\kwd{,}<length>\kwd{,}<flags>\kwd{)}}
- Receives a message on <socket>.
- X
- \Xi{\kwd{send(}<socket>\kwd{,}<msg>\kwd{,}<FLAGS[>\kwd{,}<to>]\kwd{)}}
- Sends a message on the <socket>.
- X
- \Xi{\kwd{setsockopt(}<socket>\kwd{,}<level>\kwd{,}<optname>\kwd{,}<optval>\kwd{)}}
- Sets the requested socket option.
- X
- \Xi{\kwd{shutdown(}<socket>\kwd{,}<how>\kwd{)}}
- Shuts down a <socket>.
- X
- \Xi{\kwd{socket(}<socket>\kwd{,}<domain>\kwd{,}<type>\kwd{,}<protocol>\kwd{)}}
- Creates a <socket> in <domain> with <type> and <protocol>.
- X
- \Xi{\kwd{socketpair(}<socket1>\kwd{,}<socket2>\kwd{,}<domain>\kwd{,}<type>\kwd{,}<protocol>\kwd{)}}
- As socket, but creates a pair of bi-directional sockets.
- X
- \end{enum}
- X
- X
- \section{SystemV IPC}
- X
- The following functions all perform the same action as the
- corresponding system calls.
- X
- \kwd{msgctl(}<id>\kwd{,}<cmd>\kwd{,}<args>\kwd{)} \\
- \kwd{msgget(}<key>\kwd{,}<flags>\kwd{)} \\
- \kwd{msgsnd(}<id>\kwd{,}<msg>\kwd{,}<flags>\kwd{)} \\
- \kwd{msgrcv(}<id>\kwd{,}\$<var>\kwd{,}<size>\kwd{,}<type>\kwd{,}<flags>\kwd{)} \\
- \kwd{semctl(}<id>\kwd{,}<semnum>\kwd{,}<cmd>\kwd{,}<arg>\kwd{)} \\
- \kwd{semget(}<key>\kwd{,}<nsems>\kwd{,}<size>\kwd{,}<flags>\kwd{)} \\
- \kwd{semop(}<key>\kwd{,}...\kwd{)} \\
- \kwd{shmctl(}<id>\kwd{,}<cmd>\kwd{,}<arg>\kwd{)} \\
- \kwd{shmget(}<key>\kwd{,}<size>\kwd{,}<flags>\kwd{)} \\
- \kwd{shmread(}<id>\kwd{,}\$<var>\kwd{,}<pos>\kwd{,}<size>\kwd{)} \\
- \kwd{shmwrite(}<id>\kwd{,}<string>\kwd{,}<pos>\kwd{,}<size>\kwd{)}
- X
- \makeuppage
- X
- \section{Miscellaneous}
- X
- \begin{enum}{1cm}
- X
- \Xi{\kwd{caller}[\kwd{(}<expr>\kwd{)}]}
- Returns an array (\$package,\$file,\$line,...) for a specific subroutine
- call. ``|caller|'' returns this info for the current subroutine,
- ``|caller(1)|'' for the caller of this subroutine etc..
- X
- \Xi{\kwd{defined(}<expr>\kwd{)}*}
- Tests whether the lvalue <expr> has a real value.
- X
- \Xi{\kwd{dump} [<label>]}
- Immediate core dump. When reincarnated, starts at <label>.
- X
- \Xi{\kwd{local(}<list>\kwd{)}}
- Creates a scope for the listed variables local to the enclosing block,
- subroutine or eval.
- X
- \Xi{\kwd{package} <name>}
- Designates the remainder of the current block as a package.
- X
- \Xi{\kwd{require(}\oEXPR\kwd{)}*}
- Includes the specified file from the perl library. Does not include
- more than once, and yields a fatal error if the file does include not OK.
- X
- \Xi{\kwd{reset} [\kwd{(}<expr>\kwd{)}*]}
- Resets |??| searches so that they work again. <expr> is a list of
- single letters. All variables and arrays beginning with one of those
- letters are reset to their pristine state. Only affects the current
- package.
- X
- \Xi{\kwd{scalar(}<expr>\kwd{)}}
- Forces evaluation of <expr> in scalar context.
- X
- \Xi{\kwd{sub} <name> \{ <expr> |;| ... \}}
- Designates <name> as a subroutine. Parameters are passed by reference
- as array |@_|. Returns the value of the last expression evaluated.
- X
- \Xi{\kwd{undef}[\kwd{(}<lvalue>\kwd{)}*]}
- Undefines the <lvalue>. Always returns the undefined value.
- X
- \Xi{\kwd{wantarray}}
- Returns true if the current context expects an array value.
- X
- \end{enum}
- X
- X
- \section{Formats}
- X
- \kwd{format} [<name>] |=| \\
- <formlist> \\
- |.|
- X
- <formlist> pictures the lines, and contains the arguments which will
- give values to the fields in the lines. Picture fields are:
- X
- | @<<<... | left adjusted field, repeat the |<| to denote the desired
- width; \\
- | @>>>... | right adjusted field; \\
- | @|\|\|\||... | centered field; \\
- | @#.##... | numeric format with implied decimal point; \\
- | @* | a multi-line field.
- X
- Use \^ instead of |@| for multi-line block filling.
- X
- Use |~| at the beginning of a line to suppress unwanted empty lines.
- X
- Use |~~| at the beginning of a line to have this format line repeated
- until all fields are exhausted.
- X
- Use |$-| to zero to force a page break.
- X
- See also |$|\^, |$~|, |$-| and |$=| in section ``Special Variables''.
- X
- X
- \section{Info from system files}
- X
- {\large\sl passwd} \\
- Info is (\$name, \$passwd, \$uid, \$gid, \$quota, \$comment, \$gcos, \$dir, \$shell).
- X
- \begin{enum}{6cm}
- X
- \Xi{\kwd{endpwent}} Ends lookup processing.
- X
- \Xi{\kwd{getpwent}} Gets next info.
- X
- \Xi{\kwd{getpwnam(}<name>\kwd{)}} Gets info by name.
- X
- \Xi{\kwd{getpwuid(}<uid>\kwd{)}} Gets info by uid.
- X
- \Xi{\kwd{setpwent}} Resets lookup processing.
- X
- \end{enum}
- X
- {\vskip6pt\large\sl group} \\
- Info is a 4-item array: (\$name, \$passwd, \$gid, \$members).
- X
- \begin{enum}{6cm}
- X
- \Xi{\kwd{endgrent}} Ends lookup processing.
- X
- \Xi{\kwd{getgrgid(}<gid>\kwd{)}} Gets info by group id.
- X
- \Xi{\kwd{getgrnam(}<name>\kwd{)}} Gets info by name.
- X
- \Xi{\kwd{getgrent}} Gets next info.
- X
- \Xi{\kwd{setgrent}} Resets lookup processing.
- X
- \end{enum}
- X
- {\vskip6pt\large\sl hosts} \\
- Info is (\$name, \$aliases, \$addrtype, \$length, @addrs).
- X
- \begin{enum}{6cm}
- X
- \Xi{\kwd{endhostent}} Ends lookup processing.
- X
- \Xi{\kwd{gethostbyaddr(}<addr>\kwd{,}<addrtype>\kwd{)}} Gets info by address.
- X
- \Xi{\kwd{gethostbyname(}<name>\kwd{)}} Gets info by name.
- X
- \Xi{\kwd{gethostent}} Gets next info.
- X
- \Xi{\kwd{sethostent(}<stayopen>\kwd{)}} Resets lookup processing.
- X
- \end{enum}
- X
- {\vskip6pt\large\sl networks} \\
- Info is (\$name, \$aliases, \$addrtype, \$net).
- X
- \begin{enum}{6cm}
- X
- \Xi{\kwd{endnetent}} Ends lookup processing.
- X
- \Xi{\kwd{getnetbyaddr(}<addr>\kwd{,}<type>\kwd{)}} Gets info by address and type.
- X
- \Xi{\kwd{getnetbyname(}<name>\kwd{)}} Gets info by name.
- X
- \Xi{\kwd{getnetent}} Gets next info.
- X
- \Xi{\kwd{setnetent(}<stayopen>\kwd{)}} Resets lookup processing.
- X
- \end{enum}
- X
- {\vskip6pt\large\sl services} \\
- Info is (\$name, \$aliases, \$port, \$proto).
- X
- \begin{enum}{6cm}
- X
- \Xi{\kwd{endservent}} Ends lookup processing.
- X
- \Xi{\kwd{getservbyname(}<name>\kwd{, }<proto>\kwd{)}} Gets info by name.
- X
- \Xi{\kwd{getservbyport(}<port>\kwd{, }<proto>\kwd{)}} Gets info by port.
- X
- \Xi{\kwd{getservent}} Gets next info.
- X
- \Xi{\kwd{setservent(}<stayopen>\kwd{)}} Resets lookup processing.
- X
- \end{enum}
- X
- {\vskip6pt\large\sl protocols} \\
- X
- Info is (\$name, \$aliases, \$proto).
- X
- \begin{enum}{6cm}
- X
- \Xi{\kwd{endprotoent}} Ends lookup processing.
- X
- \Xi{\kwd{getprotobyname(}<name>\kwd{)}} Gets info by name.
- X
- \Xi{\kwd{getprotobynumber(}<number>\kwd{)}} Gets info by number.
- X
- \Xi{\kwd{getprotoent}} Gets next info.
- X
- \Xi{\kwd{setprotoent(}<stayopen>\kwd{)}} Resets lookup processing.
- X
- \end{enum}
- X
- X
- \section{Regular expressions}
- X
- Each character matches itself, unless it is one of the special
- characters |+?.*()[]{}|\||\|.
- X
- \begin{enum}{1cm}
- X
- \Xj{|.|}
- matches an arbitrary character, but not a newline.
- X
- \Xj{|(|\ldots|)|}
- groups a series of pattern elements to a single element.
- X
- \Xj{|+|}
- matches the preceding pattern element one or more times.
- X
- \Xj{|?|}
- matches zero or one times.
- X
- \Xj{|*|}
- matches zero or more times.
- X
- \Xj{\{<n>|,|<m>\}}
- denotes the minimum <n> and maximum <m> match count. |{|<n>|}| means
- exactly <n> times; |{|<n>|,}| means at least <n> times.
- X
- \Xj{|\char`\[|\ldots|\char`\]|}
- denotes a class of characters to match. |[|\^\ldots|]| negates the class.
- X
- \Xj{|(|\ldots\|\ldots\|\ldots|)|}
- matches one of the alternatives.
- X
- \end{enum}
- X
- Non-alphanumerics can be escaped from their special meaning using a
- |\|.
- X
- \begin{enum}{1cm}
- X
- \Xj{|\char`\\w|}
- matches alphanumeric, including ``|_|'', |\W| matches non-alphanumeric.
- X
- \Xj{|\char`\\b|}
- matches word boundaries, |\B| matches non-boundaries.
- X
- \Xj{|\char`\\s|}
- matches whitespace, |\S| matches non-whitespace.
- X
- \Xj{|\char`\\d|}
- matches numeric, |\D| matches non-numeric.
- X
- \Xj{|\char`\\n|, |\char`\\r|, |\char`\\f|, |\char`\\t| etc.}
- have their usual meaning.
- X
- \Xj{|\char`\\w|, |\char`\\s| and |\char`\\d|}
- X may be used within character classes, |\b| denotes backspace in this context.
- X
- \Xj{|\char`\\1|\ldots|\char`\\9|}
- refer to matched sub-expressions, grouped with |()|, inside
- the match.
- X
- \Xj{|\char`\\10|}
- and up can also be used if the pattern
- matches that many sub-expressions.
- X
- \end{enum}
- X
- See also |$1|\ldots|$9|, |$+|, |$&|, |$`| and |$'| in section ``Special
- Variables''.
- X
- X
- X
- \section{Special variables}
- X
- The following variables are global and should be localized in subroutines:
- X
- \begin{enum}{1cm}
- X
- \Xi{|\char`\$\char`\_|}
- The default input and pattern-searching space.
- X
- \Xi{|\char`\$\char`\.|}
- The current input line number of the last filehandle that was read.
- X
- \Xi{|\char`\$\char`\/|}
- The input record separator, newline by default. May be multi-character.
- X
- \Xi{|\char`\$\char`\,|}
- The output field separator for the print operator.
- X
- \Xi{|\char`\$\char`\"|}
- The separator which joins elements of arrays interpolated in strings.
- X
- \Xi{|\char`\$\char`\\|}
- The output record separator for the print operator.
- X
- \Xi{|\char`\$\char`\#|}
- The output format for printed numbers. Initial value is ``|%.20g|''.
- X
- \Xi{|\char`\$\char`\*|}
- Set to 1 to do multiline matching within a string, 0 to assume strings
- contain a single line. Default is 0.
- X
- \Xi{|\char`\$\char`\?|}
- The status returned by the last |`|<command>|`|, pipe close or
- \kwd{system} operator.
- X
- \Xi{|\char`\$\char`\]|}
- The perl version string (as displayed with |perl -v|), or version number.
- X
- \Xi{|\char`\$\char`\[|}
- The index of the first element in an array, and of the first character
- in a substring. Default is 0.
- X
- \Xi{|\char`\$\char`\;|}
- The subscript separator for multi-dimensional array emulation. Default
- is |"\034"|.
- X
- \Xi{|\char`\$\char`\!|}
- If used in a numeric context, yields the current value of errno. If
- used in a string context, yields the corresponding error string.
- X
- \Xi{|\char`\$\char`\@|}
- The perl error message from the last eval or \kwd{do} <expr> command.
- X
- \Xi{|\char`\$\char`\:|}
- The set of characters after which a string may be broken to fill
- continuation fields (starting with ``|^|'') in a format.
- X
- \Xi{|\char`\$\char`\0|}
- The name of the file containing the perl script being executed. May be
- assigned to.
- X
- \Xi{|\char`\$\char`\$|}
- The process number of the perl running this script. Altered (in the
- child process) by \kwd{fork}.
- X
- \Xi{|\char`\$\char`\<|}
- The real uid of this process.
- X
- \Xi{|\char`\$\char`\>|}
- The effective uid of this process.
- X
- \Xi{|\char`\$\char`\(|}
- The real gid of this process.
- X
- \Xi{|\char`\$\char`\)|}
- The effective gid of this process.
- X
- \Xi{|\char`\$\char`\^D|}
- The debug flags as passed to perl using |-D| .
- X
- \Xi{|\char`\$\char`\^F|}
- The highest system file descriptor, ordinarily 2.
- X
- \Xi{|\char`\${\char`\^}I|}
- In-place edit extension as passed to perl using |-i| .
- X
- \Xi{|\char`\$\char`\^P|}
- Internal debugging flag.
- X
- \Xi{|\char`\$\char`\^T|}
- The time (as delivered by \kwd{time}) when the program started. This
- value is used by the file test operators ``|-M|'', ``|-A|'' and
- ``|-C|''.
- X
- \Xi{|\char`\$\char`\^W|}
- The value if the |-w| option as passed to perl.
- X
- \Xi{|\char`\$\char`\^X|}
- The name by which this perl was invoked.
- X
- \end{enum}
- X
- The following variables are context dependent and need not be
- localized:
- X
- \begin{enum}{1cm}
- X
- \Xi{|\char`\$\char`\%|}
- The current page number of the currently selected output channel.
- X
- \Xi{|\char`\$\char`\=|}
- The page length of the current output channel. Default is 60 lines.
- X
- \Xi{|\char`\$\char`\-|}
- The number of lines left on the page.
- X
- \Xi{|\char`\$\char`\~|}
- The name of the current report format.
- X
- \Xi{|\char`\$\char`\^|}
- The name of the current top-of-page format.
- X
- \Xi{|\char`\$\char`\||}
- If set to nonzero, forces a flush after every write or print on the
- currently selected output channel. Default is 0.
- X
- \Xi{|\char`\$ARGV|}
- The name of the current file when reading from |<>| .
- \end{enum}
- X
- The following variables are always local to the current block:
- X
- \begin{enum}{1cm}
- X
- \Xi{|\char`\$\char`\&|}
- The string matched by the last pattern match.
- X
- \Xi{|\char`\$\char`\`|}
- The string preceding what was matched by the last pattern match.
- X
- \Xi{|\char`\$\char`\'|}
- The string following what was matched by the last pattern match.
- X
- \Xi{|\char`\$\char`\+|}
- The last bracket matched by the last search pattern.
- X
- \Xi{\$|1|\ldots\$|9|\ldots}
- Contains the subpattern from the corresponding set of parentheses in
- the last pattern matched. |$10|\ldots and up are only available if the
- match contained that many sub-expressions.
- X
- \end{enum}
- X
- X
- X
- X
- \section{Special arrays}
- X
- \begin{enum}{1.5cm}
- X
- \Xi{|@ARGV|}
- Contains the command line arguments for the script (not including the command name).
- X
- \Xi{|@INC|}
- Contains the list of places to look for perl scripts to be evaluated
- by the \kwd{do} <filename> and \kwd{require} commands.
- X
- \Xi{|@\char`\_|}
- Parameter array for subroutines. Also used by \kwd{split} if not in
- array context.
- X
- \Xi{|\char`\%ENV|}
- Contains the current environment.
- X
- \Xi{|\char`\%INC|}
- List of files that have been \kwd{require}d or \kwd{do}ne.
- X
- \Xi{|\char`\%SIG|}Used to set signal handlers for various signals.
- X
- \end{enum}
- X
- X
- \section{The perl debugger}
- X
- The perl symbolic debugger is invoked with |perl -d|.
- X
- \begin{enum}{2.5cm}
- X
- \Xi{|h|}
- Prints out a help message.
- X
- \Xi{|T|}
- Stack trace.
- X
- \Xi{|s|}
- Single steps.
- X
- \Xi{|n|}
- Single steps around subroutine call.
- X
- \Xi{|r|}
- Returns from the current subroutine.
- X
- \Xi{|c| [<line>]}
- Continues (until <line>, or another breakpoint or exit).
- X
- \Xi{\fbox{<ret>}}
- Repeats last |s| or |n|.
- X
- \Xi{|l| [<range>]}
- Lists a range of lines. <range> may be a number, start-end,
- start+amount, or a subroutine name. If omitted, lists next window.
- X
- \Xi{|f| <file>}
- Switches to <file> and start listing it.
- X
- \Xi{|-|}
- Lists previous window.
- X
- \Xi{|w|}
- Lists window around current line.
- X
- \Xi{|l| <sub>}
- Lists the named <sub>routine.
- X
- \Xi{|/|<pattern>|/|}
- Forward search for <pattern>.
- X
- \Xi{|?|<pattern>|?|}
- Backward search for <pattern>.
- X
- \Xi{|L|}
- Lists lines that have breakpoints or actions.
- X
- \Xi{|S|}
- List the names of all subroutines.
- X
- \Xi{|t|}
- Toggles trace mode.
- X
- \Xi{|b| [<line> [<condition>]]}
- Sets breakpoint at <line>, default: current line.
- X
- \Xi{|b| <subname> [<condition>]}
- Sets breakpoint at the subroutine.
- X
- \Xi{|S|}
- Lists names of all subroutines.
- X
- \Xi{|d| [<line>]}
- Deletes breakpoint at the given line.
- X
- \Xi{|D|}
- Deletes all breakpoints.
- X
- \Xi{|a| <line command>}
- Sets an action for line.
- X
- \Xi{|A|}
- Deletes all line actions.
- X
- \Xi{|\char`\<| <command>}
- Sets an action to be executed before every debugger prompt.
- X
- \Xi{|\char`\>| <command>}
- Sets an action to be executed before every |s|, |c| or |n| command.
- X
- \Xi{|V| [<package> [<vars>] ]}
- Lists all variables in a package. Default package is main.
- X
- \Xi{|X| [<vars>]}
- Like |V|, but assumes current package.
- X
- \Xi{|!| [ [-]<number>]}
- Redo a debugging command. Default is previous command.
- X
- \Xi{|H| [-<number>]}
- Displays the last -<number> commands of more than one letter.
- X
- \Xi{|q|}
- Quits. You may also use your \fbox{<eof>} character.
- X
- \Xi{<command>}
- Executes <command> as a perl statement.
- X
- \Xi{|p| \oEXPR}
- Prints <expr>.
- X
- \Xi{|=|< >[<alias value>]}
- Sets alias, or lists current aliases.
- X
- \end{enum}
- X
- X
- \newpage
- \unnumbered{Notes}
- \vfill
- \makebox[\textwidth]{Perl Reference Guide Revision \refrev \hfill
- \copyright 1989,1992 Johan Vromans}
- X
- X
- \end{document}
- SHAR_EOF
- chmod 0644 refbase.tex ||
- echo 'restore of refbase.tex failed'
- Wc_c="`wc -c < 'refbase.tex'`"
- test 47244 -eq "$Wc_c" ||
- echo 'refbase.tex: original size 47244, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- rm -f _shar_seq_.tmp
- echo You have unpacked the last part
- exit 0
- exit 0 # Just in case...
-