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 (read Scheck if test "$Scheck" != 3; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 ) < _shar_seq_.tmp || exit 1 if test ! -f _shar_wnt_.tmp; then echo 'x - still skipping refbase.sty' 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 % is used for variable things. % Representation is 10pt sans-serif uppercased. \catcode`\<=\active \def<{\leavevmode\italicizerest} \def\italicizerest#1>{{\small\sf\uppercase{#1}}} % 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`\_}} % Keywords % Representation is 10pt sans-serif bold. \def\kwd#1{{\small\bf #1}} % Definitions \def\oEXPR{\dag} %%%%%%%%%%%%%%%% 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}}} % 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]} \let\endenum=\endlist %%%%%%%%%%%%%%%% 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 # ============= 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 > _shar_wnt_.tmp echo 'x - extracting refbase.tex (Text)' sed 's/^X//' << 'SHAR_EOF' > 'refbase.tex' && \def\revision{1} \documentstyle{refbase} \begin{document} \begin{titlepage} \hbox{ } \end{titlepage} \begin{titlepage} \addtolength{\evensidemargin}{2cm} \addtolength{\textwidth}{-2.1cm} \vspace*{2.5cm} \unnumbered{Perl Reference Guide} {\bf for Perl version \perlrev} \vskip1cm Perl program designed and created by \\ Larry Wall \ \vskip1cm Reference guide designed and created by \\ Johan Vromans \ \vskip1.5cm \unnumbered{Contents} \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} \unnumbered{Conventions} \begin{enum}{2cm} \Xi{|fixed|} denotes literal text. \Xi{} means variable text, i.e. things you must fill in. \Xi{\dag} means that will default to |$_| if omitted. \Xi{\kwd{word}} is a keyword, i.e. a word with a special meaning. \Xi{\fbox{}} denotes pressing a keyboard key. \Xi{[\ldots]} denotes an optional part. \Xi{(\ldots)*} means that the parentheses may be omitted. \end{enum} \section{Command line options} \begin{enum}{1cm} \Xi{|-a|} turns on autosplit mode when used with |-n| or |-p|. Splits to |@F|. \Xi{|-c|} checks syntax but does not execute. \Xi{|-d|} runs the script under the debugger. Use |-de 0| to start the debugger without a script. \Xi{|-D| } sets debugging flags. \Xi{|-e| } may be used to enter one line of script. Multiple |-e| commands may be given to build up a multi-line script. \Xi{|-i| } files processed by the |<>| construct are to be edited in-place. \Xi{|-I| } with |-P|: tells the C preprocessor where to look for include files. The directory is prepended to |@INC|. \Xi{|-L| } enables automatic line ending processing. \Xi{|-n|} assumes an input loop around your script. Lines are not printed. \Xi{|-p|} assumes an input loop around your script. Lines are printed. \Xi{|-P|} runs the C preprocessor on the script before compilation by perl. \Xi{|-s|} interprets ``|-xxx|'' on the command line as switches and sets the corresponding variables \$|xxx| in the script. \Xi{|-S|} uses the |PATH| environment variable to search for the script. \Xi{|-u|} dumps core after compiling the script. To be used with the {\it undump\/} program (where available). \Xi{|-U|} allows perl to do unsafe operations. \Xi{|-v|} prints the version and patchlevel of your perl executable. \Xi{|-w|} prints warnings about possible spelling errors and other error-prone constructs in the script. \Xi{|-x|} extracts perl program from input stream. \Xi{|-0| } (that's the number zero) designates an initial value for the record terminator \$|/|. See also |-L|. \end{enum} \makeuppage \section{Literals} Numeric: |123 123.4 5E-10 0xff| (hex)| 0377| (octal). \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 |/.../|.) \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. \hangindent=2cm\hangafter=1 \makebox[1cm]{}|`||`| evaluates to the output of the . \newline Also: |qx/||/|. \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')| \hangindent=1cm\hangafter=1 Associative array: |(||,||,||,||,...)| \hangindent=1cm\hangafter=1 Filehandles: \newline Pre-defined: ||, ||, ||, ||, ||; \newline User-specified: |<||>|, |<$||>|. \newline |<>| is the input stream formed by the files specified in |@ARGV|, or standard input if no arguments are supplied. \hangindent=1cm\hangafter=1 Globs: |<||>| evaluates to all filenames according to the pattern. \newline Use |<${||}>| to glob from a variable. \hangindent=1cm\hangafter=1 Here-Is: |<<| \newline {\it See the manual for details.} \hangindent=1cm\hangafter=1 Special tokens: \newline \_\,\_|FILE|\_\,\_: filename; \_\,\_|LINE|\_\,\_: line number. \newline \_\,\_|END|\_\,\_: end of program; remaining lines can be read using \<\>. \section{Variables} \begin{enum}{3.2cm} \Xi{|\$var|} a simple scalar variable \Xi{|\$var[28]|} 29th element of array |@var| (the |[]| are part of it) \Xi{|\$var\{'Feb'\}|} one value from associative array |%var| \Xi{|\$\#var|} last index of array |@var| \Xi{|@var|} the entire array; in scalar context: the number of elements in the array \Xi{|@var[3,4,5]|} a slice of the array |@var| \Xi{|@var\{'a','b'\}|} a slice of |%var|; same as |($var{'a'},$var{'b'})| \Xi{|\%var|} the entire associative array; in scalar context: TRUE if the array has elements \Xj{|\$var\{'a',1,...\}|} emulates a multi-dimensional array \Xi{|('a'..'z')[4,7,9]|} a slice of an array literal \Xi{|*|} refers to all objects represented by . ``|*name1 = *name2|'' makes |name1| a reference to |name2|. \end{enum} \section{Statements} Every statement is an expression, optionally followed by a modifier, and terminated by a semi-colon. Execution of expressions can depend on other expressions using one of the modifiers \kwd{if}, \kwd{unless}, \kwd{while} or \kwd{until}, e.g.: \quad \kwd{if} |;| \\ \quad \kwd{until} |;| Also, by using one of the logical operators \|\|, |&&| or |? :|, e.g.: \quad \|\| |;| \\ \quad |?| |:| |;| Statements can be combined to form a when enclosed in |{}|. Compound statements may be used to control flow: \quad \kwd{if} |(||)| [ [ \kwd{elsif} X |(||)| ] \kwd{else} X ] \quad \kwd{unless} |(||)| [ \kwd{else} X ] \quad [