home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / perlref / part03 (.txt) < prev    next >
LaTeX Document  |  1992-02-26  |  52KB  |  1,213 lines

  1. Newsgroups: comp.sources.misc
  2. From: jv@mh.nl (Johan Vromans)
  3. Subject:  v28i079:  perlref - Perl Reference Guide 4.019.1 [LaTeX and Postscript], Part03/03
  4. Message-ID: <1992Feb26.175901.25635@sparky.imd.sterling.com>
  5. X-Md4-Signature: e72592e610c148d01f42310f0835e3c5
  6. Date: Wed, 26 Feb 1992 17:59:01 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8. Submitted-by: jv@mh.nl (Johan Vromans)
  9. Posting-number: Volume 28, Issue 79
  10. Archive-name: perlref/part03
  11. Environment: Perl, Postscript, Latex
  12. #!/bin/sh
  13. # do not concatenate these parts, unpack them in order with /bin/sh
  14. # file refbase.sty continued
  15. if test ! -r _shar_seq_.tmp; then
  16.     echo 'Please unpack part 1 first!'
  17.     exit 1
  18. (read Scheck
  19.  if test "$Scheck" != 3; then
  20.     echo Please unpack part "$Scheck" next!
  21.     exit 1
  22.  else
  23.     exit 0
  24. ) < _shar_seq_.tmp || exit 1
  25. if test ! -f _shar_wnt_.tmp; then
  26.     echo 'x - still skipping refbase.sty'
  27. echo 'x - continuing file refbase.sty'
  28. sed 's/^X//' << 'SHAR_EOF' >> 'refbase.sty' &&
  29. %%%%%%%%%%%%%%%% Macros %%%%%%%%%%%%%%%%
  30. \chardef\other=12
  31. % |lit| is used to represent literal things.
  32. % Representation is a fixed font.
  33. {\catcode`\|=\active
  34. \gdef|{\leavevmode%
  35. \begingroup\catcode`\\=\other\catcode`\{=\other%
  36. \catcode`\}=\other\catcode`\$=\other\catcode`\&=\other%
  37. \catcode`\#=\other\catcode`\~=\other%
  38. \catcode`\_=\other\catcode`\^=\other\catcode`\<=\other%
  39. \catcode`\[=\other%
  40. \obeyspaces\obeylines%
  41. \let|=\endgroup\escapechar`\|\catcode`\%=\other\tt}}
  42. \catcode`\|=\active
  43. % <var> is used for variable things. 
  44. % Representation is 10pt sans-serif uppercased.
  45. \catcode`\<=\active
  46. \def<{\leavevmode\italicizerest}
  47. \def\italicizerest#1>{{\small\sf\uppercase{#1}}}
  48. % LaTeX active and 'hot' characters
  49. \def\|{\leavevmode\hbox{\tt\char`\|}}
  50. \def\<{\leavevmode\hbox{\tt\char`\<}}
  51. \def\>{\leavevmode\hbox{\tt\char`\>}}
  52. \def\^{\leavevmode\hbox{\tt\char`\^}}
  53. \def\${\leavevmode\hbox{\tt\char`\$}}
  54. \def\%{\leavevmode\hbox{\tt\char`\%}}
  55. \def\&{\leavevmode\hbox{\tt\char`\&}}
  56. \def\{{\leavevmode\hbox{\tt\char`\{}}
  57. \def\}{\leavevmode\hbox{\tt\char`\}}}
  58. \def\_{\leavevmode\hbox{\tt\char`\_}}
  59. % Keywords
  60. % Representation is 10pt sans-serif bold.
  61. \def\kwd#1{{\small\bf #1}}
  62. % Definitions
  63. \def\oEXPR{<expr>\dag}
  64. %%%%%%%%%%%%%%%% Enumerations %%%%%%%%%%%%%%%%
  65. % Usage:
  66. %  \begin{enum}{width}
  67. %  \Xi{Blah} blah blah...
  68. %  \Xi{Blah} bla ...
  69. %  ...
  70. %  \end{enum}
  71. \newlength{\@xli}
  72. \newlength{\@xlj}
  73. \def\enum#1{
  74. X    \list{}{
  75. X      \setlength{\topsep}{0pt plus 1pt}
  76. X      \setlength{\partopsep}{0pt plus 1pt}
  77. X      \setlength{\itemsep}{0pt plus 1pt}
  78. X      \setlength{\parsep}{\parskip}
  79. X      \setlength{\itemindent}{0pt}
  80. X      \setlength{\labelsep}{5pt}
  81. X      \setlength{\labelwidth}{#1}
  82. X      \setlength{\leftmargin}{\labelwidth}
  83. X      \addtolength{\labelwidth}{-\labelsep}
  84. X      \setlength{\@xli}{\labelwidth}
  85. X      \def\makelabel##1{##1\hss}}}
  86. % List element that overflows if it is too wide
  87. \def\Xi#1{
  88. X    \settowidth{\@xlj}{#1}
  89. X    \item[{#1}]
  90. X    \ifnum\@xlj>\@xli
  91. X           \strut\newline
  92. X    \fi}
  93. % List element that does not overflow if it is too wide
  94. \def\Xj#1{\item[#1]}
  95. \let\endenum=\endlist
  96. %%%%%%%%%%%%%%%% Emacs support %%%%%%%%%%%%%%%%
  97. % Local Variables:
  98. % eval:(auto-fill-mode 0)
  99. % eval:(headers)
  100. % eval:(setq comment-start "% ")
  101. % eval:(setq comment-start-skip "% +")
  102. % End:
  103. SHAR_EOF
  104. echo 'File refbase.sty is complete' &&
  105. chmod 0444 refbase.sty ||
  106. echo 'restore of refbase.sty failed'
  107. Wc_c="`wc -c < 'refbase.sty'`"
  108. test 6963 -eq "$Wc_c" ||
  109.     echo 'refbase.sty: original size 6963, current size' "$Wc_c"
  110. rm -f _shar_wnt_.tmp
  111. # ============= refbase.tex ==============
  112. if test -f 'refbase.tex' -a X"$1" != X"-c"; then
  113.     echo 'x - skipping refbase.tex (File already exists)'
  114.     rm -f _shar_wnt_.tmp
  115. > _shar_wnt_.tmp
  116. echo 'x - extracting refbase.tex (Text)'
  117. sed 's/^X//' << 'SHAR_EOF' > 'refbase.tex' &&
  118. \def\revision{1}
  119. \documentstyle{refbase}
  120. \begin{document}
  121. \begin{titlepage}
  122. \hbox{ }
  123. \end{titlepage}
  124. \begin{titlepage}
  125. \addtolength{\evensidemargin}{2cm}
  126. \addtolength{\textwidth}{-2.1cm}
  127. \vspace*{2.5cm}
  128. \unnumbered{Perl Reference Guide}
  129. {\bf for Perl version \perlrev}
  130. \vskip1cm
  131. Perl program designed and created by \\
  132. Larry Wall \<lwall@netlabs.com\>
  133. \vskip1cm
  134. Reference guide designed and created by \\
  135. Johan Vromans \<jv@mh.nl\>
  136. \vskip1.5cm
  137. \unnumbered{Contents}
  138. \newcounter{xx}
  139. \begin{list}{\thexx.}
  140. {\setlength{\topsep}{0pt plus 1pt}
  141. X \setlength{\itemsep}{0pt plus 1pt}
  142. X \setlength{\parsep}{0pt plus 1pt}
  143. X \usecounter{xx}}
  144. \item Command line options
  145. \item Literals
  146. \item Variables
  147. \item Statements
  148. \item Flow control
  149. \item Operators
  150. \item File test operators
  151. \item Arithmetic functions
  152. \item Conversion functions
  153. \item Structure conversion
  154. \item String functions
  155. \item Array and list functions
  156. \item File operations
  157. \item Directory reading routines
  158. \item Input / Output
  159. \item Search and replace functions
  160. \item System interaction
  161. \item Networking
  162. \item SystemV IPC
  163. \item Miscellaneous
  164. \item Formats
  165. \item Info from system files
  166. \item Regular expressions
  167. \item Special variables
  168. \item Special arrays
  169. \item The perl debugger
  170. \end{list}
  171. \vskip1cm
  172. {\catcode`\%=\other \small {Rev. \refrev}}
  173. \end{titlepage}
  174. \unnumbered{Conventions}
  175. \begin{enum}{2cm}
  176. \Xi{|fixed|} denotes literal text.
  177. \Xi{<this>} means variable text, i.e. things you must fill in.
  178. \Xi{<this>\dag} means that <this> will default to |$_| if omitted.
  179. \Xi{\kwd{word}} is a keyword, i.e. a word with a special meaning.
  180. \Xi{\fbox{<ret>}} denotes pressing a keyboard key.
  181. \Xi{[\ldots]} denotes an optional part.
  182. \Xi{(\ldots)*} means that the parentheses may be omitted.
  183. \end{enum}
  184. \section{Command line options} 
  185. \begin{enum}{1cm}
  186. \Xi{|-a|} turns on autosplit mode when used with |-n| or
  187. |-p|. Splits to |@F|.
  188. \Xi{|-c|} checks syntax but does not execute.
  189. \Xi{|-d|} runs the script under the debugger. Use |-de 0| to
  190. start the debugger without a script.
  191. \Xi{|-D| <number>} sets debugging flags. 
  192. \Xi{|-e| <commandline>} may be used to enter one line of
  193. script. Multiple |-e| commands may be given to build up a
  194. multi-line script.
  195. \Xi{|-i| <ext>} files processed by the |<>| construct are
  196. to be edited in-place.
  197. \Xi{|-I| <dir>} with |-P|: tells the C preprocessor where
  198. to look for include files. The directory is prepended to |@INC|.
  199. \Xi{|-L| <octnum>} enables automatic line ending processing.
  200. \Xi{|-n|} assumes an input loop around your script. Lines are not
  201. printed.
  202. \Xi{|-p|} assumes an input loop around your script. Lines are
  203. printed.
  204. \Xi{|-P|} runs the C preprocessor on the script before
  205. compilation by perl.
  206. \Xi{|-s|} interprets ``|-xxx|'' on the command line as
  207. switches and sets the corresponding variables \$|xxx| in the script.
  208. \Xi{|-S|} uses the |PATH| environment variable to search for
  209. the script.
  210. \Xi{|-u|} dumps core after compiling the script. To be used with
  211. the {\it undump\/} program (where available).
  212. \Xi{|-U|} allows perl to do unsafe operations.
  213. \Xi{|-v|} prints the version and patchlevel of your perl
  214. executable.
  215. \Xi{|-w|} prints warnings about possible spelling errors and
  216. other error-prone constructs in the script.
  217. \Xi{|-x|} extracts perl program from input stream.
  218. \Xi{|-0| <val>} (that's the number zero) designates an
  219. initial value for the record terminator \$|/|.
  220. See also |-L|.
  221. \end{enum}
  222. \makeuppage
  223. \section{Literals} 
  224. Numeric: |123  123.4  5E-10  0xff| (hex)|  0377| (octal).
  225. \hangindent=2cm\hangafter=1
  226. String: |'abc'| literal string, no variable interpolation nor
  227. escape characters.
  228. \newline Also: |q/abc/|.
  229. \newline (Almost any pair of delimiters can be used instead of |/.../|.)
  230. \hangindent=2cm\hangafter=1
  231. \makebox[1cm]{}|"abc"|
  232. Variables are interpolated and escape sequences are processed. 
  233. \newline Also: |qq/abc/|.
  234. \newline Escape sequences: |\t| (Tab), |\n| (Newline), |\r| (Return),
  235. |\f| (Formfeed), |\b| (Backspace), |\a| (Alarm), |\e|
  236. (Escape), |\033|(octal), |\x1b|(hex), |\c[| (control).
  237. \newline |\l| and |\u| lowcase/upcase the following character; 
  238. \newline |\L| and |\U| lowcase/upcase until a |\E| is encountered.
  239. \hangindent=2cm\hangafter=1
  240. \makebox[1cm]{}|`|<command>|`|
  241. evaluates to the output of the <command>. 
  242. \newline Also: |qx/|<command>|/|.
  243. \hangindent=1cm\hangafter=1
  244. Array: |(1,2,3)|. |()| is an empty array.  
  245. \newline Also: |($a,$b,@rest) = (1,2,...);|
  246. \newline |(1..4)| is the same as |(1,2,3,4)|. Likewise |('abc'..'ade')|
  247. \hangindent=1cm\hangafter=1
  248. Associative array:
  249. |(|<key1>|,|<val1>|,|<key2>|,|<val2>|,...)|
  250. \hangindent=1cm\hangafter=1
  251. Filehandles: 
  252. \newline Pre-defined: |<STDIN>|, |<STDOUT>|, |<STDERR>|, |<ARGV>|,
  253. |<DATA>|;
  254. \newline User-specified: |<|<handle>|>|, |<$|<var>|>|.
  255. \newline |<>| is the input stream formed by the files specified in
  256. |@ARGV|, or standard input if no arguments are supplied.
  257. \hangindent=1cm\hangafter=1
  258. Globs: |<|<pattern>|>| evaluates to all filenames according
  259. to the pattern.
  260. \newline Use |<${|<var>|}>| to glob from a variable.
  261. \hangindent=1cm\hangafter=1
  262. Here-Is: |<<|<identifier>
  263. \newline {\it See the manual for details.}
  264. \hangindent=1cm\hangafter=1
  265. Special tokens:
  266. \newline \_\,\_|FILE|\_\,\_: filename; \_\,\_|LINE|\_\,\_: line number.
  267. \newline \_\,\_|END|\_\,\_: end of program; remaining lines can be read using
  268. \<<data>\>.
  269. \section{Variables} 
  270. \begin{enum}{3.2cm}
  271. \Xi{|\$var|} a simple scalar variable
  272. \Xi{|\$var[28]|} 29th element of array |@var| (the |[]| are
  273. part of it)
  274. \Xi{|\$var\{'Feb'\}|} one value from associative array |%var|
  275. \Xi{|\$\#var|} last index of array |@var|
  276. \Xi{|@var|} the entire array;
  277. in scalar context: the number of elements in the array
  278. \Xi{|@var[3,4,5]|} a slice of the array |@var|
  279. \Xi{|@var\{'a','b'\}|} a slice of |%var|; same as
  280. |($var{'a'},$var{'b'})|
  281. \Xi{|\%var|} the entire associative array;
  282. in scalar context: TRUE if the array has elements
  283. \Xj{|\$var\{'a',1,...\}|} emulates a multi-dimensional array
  284. \Xi{|('a'..'z')[4,7,9]|} a slice of an array literal
  285. \Xi{|*|<name>} refers to all objects represented by <name>.
  286. ``|*name1 = *name2|'' makes |name1| a reference to |name2|.
  287. \end{enum}
  288. \section{Statements} 
  289. Every statement is an expression, optionally followed by a modifier,
  290. and terminated by a semi-colon.
  291. Execution of expressions can depend on other expressions using one of
  292. the modifiers \kwd{if}, \kwd{unless}, \kwd{while} or \kwd{until},
  293. e.g.:
  294. \quad    <expr1> \kwd{if} <expr2> |;| \\
  295. \quad    <expr1> \kwd{until} <expr2> |;|
  296. Also, by using one of the logical operators \|\|, |&&| or |? :|, e.g.:
  297. \quad    <expr1> \|\| <expr2> |;| \\
  298. \quad    <expr1> |?| <expr2> |:| <expr3> |;| 
  299. Statements can be combined to form a <block> when enclosed in |{}|.
  300. Compound statements may be used to control flow:
  301. \quad    \kwd{if} |(|<expr>|)| <block> [ [ \kwd{elsif}
  302. X    |(|<expr>|)| <BLOCK ...> ] \kwd{else}
  303. X    <block> ]
  304. \quad    \kwd{unless} |(|<expr>|)| <block> [ \kwd{else}
  305. X    <block> ]
  306. \quad    [ <label>\kwd{:} ] \kwd{while} |(|<expr>|)|
  307. X    <block> [ \kwd{continue} <block> ]
  308. \quad    [ <label>\kwd{:} ] \kwd{until} |(|<expr>|)|
  309. X    <block> [ \kwd{continue} <block> ]
  310. \quad    [ <label>\kwd{:} ] \kwd{for} |(|<expr>|;|
  311. X    <expr>|;| <expr>|)| <block>
  312. \quad    [ <label>\kwd{:} ] \kwd{foreach} <var>\dag
  313. X    |(|<array>|)| <block>
  314. \quad    [ <label>\kwd{:} ] <block> [ \kwd{continue} < block> ]
  315. Special forms are:
  316. \quad    \kwd{do} <block> \kwd{while} <expr> |;| \\
  317. \quad    \kwd{do} <block> \kwd{until} <expr> |;| \\
  318. which are guaranteed to perform <block> once before testing <expr>.
  319. \section{Flow control} 
  320. \begin{enum}{1cm}
  321. \Xi{\kwd{do} <block>}
  322. Returns the value of the last command in the sequence of commands indicated by <block>. \kwd{next}, \kwd{last} and \kwd{redo}
  323. X cannot be used here.
  324. \Xi{\kwd{do} <subroutine>\kwd{(LIST)}} 
  325. Executes a <subroutine> declared by a \kwd{sub} declaration, and
  326. returns the value of the last expression evaluated in <subroutine> .
  327. \newline Preferred form is: |&|<subroutine> .
  328. \Xi{\kwd{do} <FILENAME>}
  329. Executes the contents of <filename> as a perl script. Errors are
  330. returned in |$@|.
  331. \newline Preferred form is: \kwd{require} <filename> .
  332. \Xi{\kwd{goto} <label>}
  333. Continue execution at the specified label.
  334. \Xi{\kwd{last} [<label>]}
  335. Immediately exits the loop in question. Skips continue block.
  336. \Xi{\kwd{next} [<label>]}
  337. Starts the next iteration of the loop.
  338. \Xi{\kwd{redo} [<label>]}
  339. Restarts the loop block without evaluating the conditional again.
  340. \Xi{\kwd{return} <expr>}
  341. Returns from a subroutine with the value specified.
  342. \end{enum}
  343. \section{Operators} 
  344. \begin{tabbing}
  345. |    |\=|    |\= \kill
  346. |+ -| \> |* /| \> Addition, subtraction, multiplication, division. \\
  347. |%| \> \> Modulo division. \\
  348. \| \& \> \^ \> Bitwise or, bitwise and, bitwise exclusive or. \\
  349. |>>| \> |<<| \> Bitwise shift right, bitwise shift left. \\
  350. |**| \> \> Exponentiation. \\
  351. |.| \> \> Concatenation of two strings. \\
  352. \kwd{x} \> \> Returns a string or array consisting of the left operand
  353. (an array or \\
  354. \> \> a string) repeated the number of times specified by the right operand.
  355. \end{tabbing}
  356. All of the above operators also have an assignment operator, e.g. ``|.=|''.
  357. \begin{tabbing}
  358. |    |\=|    |\= \kill
  359. |++| \> |--| \> Auto-increment (magical on strings), auto-decrement. \\
  360. |? :|\>      \> Alternation (if-then-else) operator. \\
  361. \|\| \> \&\&   \> Logical or, logical and. \\
  362. |=|\,|=| \> |!=| \> Numeric equality, inequality. \\
  363. \kwd{eq} \> \kwd{ne} \> String equality, inequality. \\
  364. |<|  \>  |>|  \> Numeric less than, greater than. \\
  365. \kwd{lt} \> \kwd{gt} \> String less than, greater than. \\
  366. |<=| \> |>=| \> Numeric less (greater) than or equal to. \\
  367. \kwd{le} \> \kwd{ge} \> String less (greater) than or equal. \\
  368. |<=>| \> \> Numeric compare. Returns -1, 0 or 1. \\
  369. \kwd{cmp} \> \> String compare. Returns -1, 0 or 1. \\
  370. |=~| \> |!~| \> Search pattern, substitution, or translation (negated). \\
  371. |..| \> \> Enumeration, also input line range operator. \\
  372. |,| \> \> Comma operator.
  373. \end{tabbing}
  374. \section{File test operators} 
  375. These unary operators takes one argument, either a filename or a
  376. filehandle, and tests the associated file to see if something is true
  377. about it. If the argument is omitted, tests |$_| (except for |-t,|
  378. which tests |STDIN|). If the special argument |_| (underscore) is
  379. passed, uses the info of the preceding test. 
  380. \begin{enum}{2.5cm}
  381. \Xi{|-r -w -x -o|}  File is readable/writable/executable/owned by
  382. effective uid. 
  383. \Xi{|-R -W -X -O|}  File is readable/writable/executable/owned by real
  384. uid.  
  385. \Xi{|-e  -z  -s|}  File exists / has zero/non-zero size. 
  386. \Xi{|-f  -d|}  File is a plain file, a directory.
  387. \Xi{|-l  -S  -p|}  File is a symbolic link, a socket, a named pipe (FIFO). 
  388. \Xi{|-b  -c|}  File is a block/character special file. 
  389. \Xi{|-u  -g  -k|}  File has setuid/setgid/sticky bit set. 
  390. \Xi{|-t|}  Tests if filehandle (|STDIN| by default) is opened to a tty.
  391. \Xi{|-T  -B|}  File is a text/non-text (binary) file.  |-T| and |-B|
  392. return TRUE on a null file, or a file at EOF when testing a filehandle. 
  393. \Xi{|-M  -A  -C|}  File creation / access / inode change time. Measured
  394. in days since this program started. See also |$^T| in section
  395. ``Special~Variables''.
  396. \end{enum}
  397. \makeuppage
  398. A <list> is a (possibly parenthesised) list of expressions, variables
  399. or <list>s. An array variable or an array slice may always be used
  400. instead of a <list>.  
  401. \section{Arithmetic functions} 
  402. \begin{enum}{1cm}
  403. \Xi{\kwd{atan2(}<y>\kwd{,}<x>\kwd{)}}
  404. Returns the arctangent of <Y>/<X> in the range -$\pi$ to $\pi$.
  405. \Xi{\kwd{cos(}\oEXPR \kwd{)}*}
  406. Returns the cosine of <expr> (expressed in radians).
  407. \Xi{\kwd{exp(}\oEXPR \kwd{)}*}
  408. Returns |e| to the power of <expr>.
  409. \Xi{\kwd{int(}\oEXPR \kwd{)}*}
  410. Returns the integer portion of <expr>.
  411. \Xi{\kwd{log(}\oEXPR \kwd{)}*}
  412. Returns natural logarithm (base |e|) of <expr>.
  413. \Xi{\kwd{rand}[\kwd{(}<expr>\kwd{)}*]}
  414. Returns a random fractional number between 0 and the value of <expr>.
  415. If <expr> is omitted, returns a value between 0 and 1. 
  416. \Xi{\kwd{sin(}\oEXPR \kwd{)}*}
  417. Returns the sine of <expr> (expressed in radians).
  418. \Xi{\kwd{sqrt(}\oEXPR \kwd{)}*}
  419. Return the square root of <expr>.
  420. \Xi{\kwd{srand}[\kwd{(}<expr>\kwd{)}*]}
  421. Sets the random number seed for the rand operator.
  422. \Xi{\kwd{time}}
  423. Returns the number of seconds since January 1, 1970. Suitable for
  424. feeding to \kwd{gmtime} and \kwd{localtime}. 
  425. \end{enum}
  426. \section{Conversion functions} 
  427. \begin{enum}{1cm}
  428. \Xi{\kwd{gmtime(}<expr>\kwd{)}*}
  429. Converts a time as returned by the \kwd{time} function to a 9-element
  430. array (\$sec, \$min, \$hour, \$mday, \$mon, \$year, \$wday,
  431. \$yday, \$isdst) with the time analyzed for the Greenwich timezone.
  432. \$mon has the range 0..11 and \$wday has the range 0..6.
  433. \Xi{\kwd{hex(}\oEXPR\kwd{)}*}
  434. Returns the decimal value of <expr> interpreted as an hex string.
  435. \Xi{\kwd{localtime(}<expr>\kwd{)}*}
  436. Converts a time as returned by the \kwd{time} function to a 9-element
  437. array with the time analyzed for the local timezone. 
  438. \Xi{\kwd{oct(}\oEXPR\kwd{)}*}
  439. Returns the decimal value of <expr> interpreted as an octal string. If
  440. <expr> starts off with |0x|, interprets it as a hex string instead.
  441. \Xi{\kwd{ord(}\oEXPR\kwd{)}*}
  442. Returns the ascii value of the first character of <expr>.
  443. \Xi{\kwd{vec(}<expr>\kwd{,}<offset>\kwd{,}<bits>\kwd{)}}
  444. Treats <expr> as a string of unsigned ints, and yields the bit at
  445. <offset>. <bits> must be between 1 and 32. May be used as an lvalue.
  446. \end{enum}
  447. \section{Structure conversion} 
  448. \begin{enum}{1cm}
  449. \Xi{\kwd{pack(}<template>\kwd{,}<list>\kwd{)}}
  450. Packs the values into a binary structure using <template>.
  451. \Xi{\kwd{unpack(}<template>\kwd{,}<expr>\kwd{)}}
  452. Unpacks the structure <expr> into an array, using <template>.
  453. <template> is a sequence of characters as follows:
  454. \begin{tabbing}
  455. |  |\=|a |\=|/ |\=|A  |\= \kill
  456. X  \> |a| \> / \> |A| \> Ascii string, null / space padded \\
  457. X  \> |b| \> / \> |B| \> Bit string in ascending / descending order \\
  458. X  \> |c| \> / \> |C| \> Native / unsigned char value \\
  459. X  \> |f| \> / \> |d| \> Single / double float in native format \\
  460. X  \> |h| \> / \> |H| \> Hex string, low / high nybble first. \\
  461. X  \> |i| \> / \> |I| \> Signed / unsigned integer value \\
  462. X  \> |l| \> / \> |L| \> Signed / unsigned long value \\
  463. X  \> |n| \> / \> |N| \> Short / long in network byte order \\
  464. X  \> |s| \> / \> |S| \> Signed / unsigned short value \\
  465. X  \> |u| \> / \> |p| \> Uuencoded string / Pointer to a string \\
  466. X  \> |x| \> / \> |@| \> Null byte / null fill until position \\
  467. X  \> |X| \>   \>     \> Backup a byte
  468. \end{tabbing}
  469. Each character may be followed by a decimal number which will be used
  470. as a repeat count, an |*| specifies all remaining arguments. \\
  471. If the format is preceded with |%|<n>, \kwd{unpack} returns an
  472. <n>-bit checksum instead. \\
  473. Spaces may be included in the template for readability purposes.
  474. \end{enum}
  475. \section{String functions} 
  476. \begin{enum}{1cm}
  477. \Xi{\kwd{chop(}<list>\dag\kwd{)}}
  478. Chops off the last character on all elements of the list; returns the
  479. last chopped character. The parentheses may be omitted if <list> is a
  480. single variable.
  481. \Xi{\kwd{crypt(}<plaintext>\kwd{,}<salt>\kwd{)}}
  482. Encrypts a string.
  483. \Xi{\kwd{eval(}\oEXPR \kwd{)}*}
  484. <expr> is parsed and executed as if it were a perl program. The value
  485. returned is the value of the last expression evaluated. If there is a
  486. syntax error or runtime error, an undefined string is returned by
  487. \kwd{eval}, and |$@| is set to the error message.
  488. \Xi{\kwd{eval\{}<expr>\kwd{;...\}}}
  489. Executes the code between \{ and \}. Traps run-time errors as described
  490. above.
  491. \Xi{\kwd{index(}<str>\kwd{,}<substr>[\kwd{,}<offset>]\kwd{)}}
  492. Returns the position of <substr> in <str> at or after <offset>. If the
  493. substring is not found, returns |$[-1|.
  494. \Xi{\kwd{length(}\oEXPR\kwd{)}*}
  495. Returns the length in characters of the value of <expr>.
  496. \Xi{\kwd{rindex(}<str>\kwd{,}<substr>[\kwd{,}<offset>]\kwd{)}}
  497. Returns the position of the last occurrence of <substr> in <str> at or
  498. before <offset>.
  499. \Xi{\kwd{substr(}<expr>\kwd{,}<offset>[\kwd{,}<len>]\kwd{)}}
  500. Extracts a substring out of <expr> and returns it. If <offset>
  501. is negative, counts from the end of the string. May be used as an lvalue.
  502. \end{enum}
  503. \section{Array and list functions} 
  504. \begin{enum}{1cm}
  505. \Xi{\kwd{delete} \$<array>\{<key>\}}
  506. Deletes the specified value from the specified associative array.
  507. Returns the deleted value. 
  508. \Xi{\kwd{each(}|\%|<array>\kwd{)}*}
  509. Returns a 2-element array consisting of the key and value for the next
  510. value of an associative array. Entries are returned in an apparently
  511. random order. When the array is entirely read, a null array is
  512. returned. The next call to \kwd{each} after that will start iterating again.
  513. \Xi{\kwd{grep(}<expr>\kwd{,}<list>\kwd{)}}
  514. Evaluates <expr> for each element of the <list>, locally setting |$_|
  515. to refer to the element. Modifying |$_| will modify the corresponding
  516. element from <list>. Returns array of elements from <list> for which
  517. <expr> returned true. 
  518. \Xi{\kwd{join(}<expr>\kwd{,}<list>\kwd{)}}
  519. Joins the separate strings of <list> into a single string with fields
  520. separated by the value of <expr>, and returns the string.
  521. \Xi{\kwd{keys(}|\%|<array>\kwd{)}*}
  522. Returns an array with of all the keys of the named
  523. associative array.
  524. \Xi{\kwd{pop(}|@|<array>\kwd{)}*}
  525. Pops and returns the last value of the array, shortens the array by 1. 
  526. \Xi{\kwd{push(}|@|<array>\kwd{,}<list>\kwd{)}}
  527. Pushes the values of <list> onto the end of <array>. The length of the
  528. array increases by the length of <list>.
  529. \Xi{\kwd{reverse(}<list>\kwd{)}*}
  530. In array context: returns the <list> in reverse order. \\
  531. In scalar
  532. context: returns the first element of <list> with bytes reversed. 
  533. \Xi{\kwd{scalar(}|@|<array>\kwd{)}}
  534. Returns the number of elements in the array.
  535. \Xi{\kwd{scalar(}|\%|<array>\kwd{)}}
  536. Returns TRUE if the associative array has elements defined.
  537. \Xi{\kwd{shift}[\kwd{(}|@|<array>\kwd{)}*]}
  538. Shifts the first value of the array off and returns it, shortening the
  539. array by 1 and moving everything down. If |@|<array> is omitted, shifts
  540. |@ARGV| in main and |@_| in subroutines.  
  541. \Xi{\kwd{sort(} [<subroutine> ] <list>\kwd{)}*}
  542. Sorts the <list> and returns the sorted array value. If <subroutine>
  543. is specified, gives the name of a subroutine that returns less than
  544. zero, zero, or greater than zero, depending on how the elements of the
  545. array, available to the routine as |$a| and |$b|, are to be ordered.
  546. <SUBROUTINE> may be the name of a user-defined routine, or a <block>
  547. (see ``Statements'' and ``Miscellaneous'').
  548. \Xi{\kwd{splice(}|@|<array>\kwd{,}<offset>[\kwd{,}<length>[\kwd{,}<list>]]\kwd{)}}
  549. Removes the elements of |@|<array> designated by <offset> and
  550. <length>, and replaces them with <list> (if specified). \\
  551. Returns the elements removed.
  552. \Xi{\kwd{split}[\kwd{(}<pattern>[\kwd{,}\oEXPR [\kwd{,}<limit>]]\kwd{)}]}
  553. Splits a string into an array of strings, and returns it. If <limit>
  554. is specified, splits in no more than that many fields. If <pattern> is
  555. also omitted, splits on whitespace. If
  556. not in array context: returns number of fields and splits to |@_|.
  557. See also: ``Search and Replace Functions''. 
  558. \Xi{\kwd{unshift(}|@|<array>\kwd{,}<list>\kwd{)}}
  559. Prepends list to the front of the array, and returns the number of
  560. elements in the new array.
  561. \Xi{\kwd{values(}|\%|<array>\kwd{)}*}
  562. Returns a normal array consisting of all the values of the named
  563. associative array. 
  564. \end{enum}
  565. \section{File operations} 
  566. Functions operating on a list of files return the number of files
  567. successfully operated upon.
  568. \begin{enum}{1cm}
  569. \Xi{\kwd{chmod(}<list>\kwd{)}*}
  570. Changes the permissions of a list of files. The first element of the
  571. list must be the numerical mode. 
  572. \Xi{\kwd{chown(}<list>\kwd{)}*}
  573. Changes the owner and group of a list of files. The first two elements
  574. of the list must be the numerical uid and gid. 
  575. \Xi{\kwd{truncate(}<file>\kwd{,}<size>\kwd{)}}
  576. truncates <file> to <size>. <file> may be a filename or a filehandle.
  577. \Xi{\kwd{link(}<oldfile>\kwd{,}<newfile>\kwd{)}}
  578. Creates a new filename linked to the old filename.
  579. \Xi{\kwd{lstat(}<file>\kwd{)}}
  580. Like stat, but does not traverse a final symbolic link.
  581. \Xi{\kwd{mkdir(}<dir>\kwd{,}<mode>\kwd{)}}
  582. Creates a directory with given permissions. Sets |$!| on failure.
  583. \Xi{\kwd{readlink(}\oEXPR\kwd{)}*}
  584. Returns the value of a symbolic link.
  585. \Xi{\kwd{rename(}<oldname>\kwd{,}<newname>\kwd{)}}
  586. Changes the name of a file.
  587. \Xi{\kwd{rmdir(}<filename>\dag\kwd{)}*}
  588. Deletes the directory if it is empty. Sets |$!| on failure.
  589. \Xi{\kwd{stat(}<file>\kwd{)}}
  590. Returns a 13-element array (\$dev, \$ino, \$mode, \$nlink, \$uid, \$gid,
  591. \$rdev, \$size, \$atime, \$mtime, \$ctime, \$blksize, \$blocks). <file> can
  592. be a filehandle, an expression evaluating to a filename, or |_| to
  593. refer to the last file test operation. 
  594. \Xi{\kwd{symlink(}<oldfile>\kwd{,}<newfile>\kwd{)}}
  595. Creates a new filename symbolically linked to the old filename.
  596. \Xi{\kwd{unlink(}<list>\kwd{)}*}
  597. Deletes a list of files.
  598. \Xi{\kwd{utime(}<list>\kwd{)}*}
  599. Changes the access and modification times. The first two elements of
  600. the list must be the numerical access and modification times.
  601. \end{enum}
  602. \makeuppage
  603. \section{Directory reading routines} 
  604. \begin{enum}{1cm}
  605. \Xi{\kwd{closedir(}<dirhandle>\kwd{)}*}
  606. Closes a directory opened by opendir.
  607. \Xi{\kwd{opendir(}<dirhandle>\kwd{,}<dirname>\kwd{)}}
  608. Opens a directory on the handle specified.
  609. \Xi{\kwd{readdir(}<dirhandle>\kwd{)}*}
  610. Returns the next entry (or an array of entries) in the directory.
  611. \Xi{\kwd{rewinddir(}<dirhandle>\kwd{)}*}
  612. Positions the directory to the beginning.
  613. \Xi{\kwd{seekdir(}<dirhandle>\kwd{,}<pos>\kwd{)}}
  614. Sets position for readdir on the directory.
  615. \Xi{\kwd{telldir(}<dirhandle>\kwd{)}*}
  616. Returns the postion in the directory.
  617. \end{enum}
  618. \section{Input / Output} 
  619. In input/output operations, <filehandle> may be a filehandle as opened
  620. by the \kwd{open} operator, or a scalar variable which evaluates to
  621. the name of a filehandle to be used.  
  622. \begin{enum}{1cm}
  623. \Xi{\kwd{binmode(}<filehandle>\kwd{)}*}
  624. Arranges for the file opened on <filehandle> to be read in ``binary''
  625. mode as opposed to ``text'' mode (MS-DOS only). 
  626. \Xi{\kwd{close(}<filehandle>\kwd{)}*}
  627. Closes the file or pipe associated with the file handle.
  628. \Xi{\kwd{dbmclose(}|\%|<array>\kwd{)}*}
  629. Breaks the binding between the array and the dbm file.
  630. \Xi{\kwd{dbmopen(}|\%|<array>\kwd{,}<dbmname>\kwd{, }<mode>\kwd{)}}
  631. Binds a dbm or ndbm file to the associative array. If the database
  632. does not exist, it is created with the indicated mode. 
  633. \Xi{\kwd{eof(}<filehandle>\kwd{)}}
  634. Returns 1 if the next read will return end of file, or if the file is
  635. not open. 
  636. \Xi{\kwd{eof}}
  637. Returns the eof status for the last file read.
  638. \Xi{\kwd{eof( )}}
  639. Indicates eof on the pseudo file formed of the files listed on the
  640. command line. 
  641. \Xi{\kwd{fcntl(}<filehandle>\kwd{,}<function>\kwd{,}|\$|<var>\kwd{)}}
  642. Implements the {\it fcntl\/}(2) function. This function has non-standard
  643. return values. See the manual for details. 
  644. \Xi{\kwd{fileno(}<filehandle>\kwd{)}*}
  645. Returns the file descriptor for a given (open) file.
  646. \Xi{\kwd{flock(}<filehandle>\kwd{,}<operation>\kwd{)}}
  647. Calls {\it flock\/}(2) on the file. <operation> adds from 1 (shared), 2
  648. (exclusive), 4 (non-blocking) or 8 (unlock). 
  649. \Xi{\kwd{getc}[\kwd{(}<filehandle>\kwd{)}*]}
  650. Yields the next character from the file, or |""| on EOF. If
  651. <filehandle> is omitted, reads from |STDIN|. 
  652. \Xi{\kwd{ioctl(}<filehandle>\kwd{,}<function>\kwd{,}|\$|<var>\kwd{)}}
  653. performs {\it ioctl}(2) on the file. This function has non-standard
  654. return values. See the manual for details. 
  655. \Xi{\kwd{open(}<filehandle>[\kwd{,}<filename>]\kwd{)}}
  656. Opens a file and associates it with <filehandle>. If <filename> is
  657. omitted, the scalar variable of the same name as the <filehandle> must
  658. contain the filename.
  659. The following filename conventions apply when opening a file.
  660. \begin{enum}{2cm}
  661. \Xi{|"|<file>|"|} open <file> for input. Also |"<|<file>|"|.
  662. \Xi{|">|<file>|"|} open <file> for output, creating it if necessary.
  663. \Xi{|">>|<file>|"|} open <file> in append mode.
  664. \Xi{|"+>|<file>|"|} open <file> with read/write access.
  665. \Xi{|"\||<cmd>|"|} opens a pipe to command <cmd>.
  666. \Xi{|"|<cmd>|\|"|} opens a pipe from command <cmd>.
  667. \end{enum}
  668. <file> may be |&|<filehnd> in which case the new file handle is
  669. connected to the (previously opened) filehandle <filehnd>.
  670. \kwd{open} 
  671. returns 1 upon success, \kwd{undef} otherwise, except for pipes. The
  672. parentheses may be omitted, if only a <filehandle> is specified.
  673. \Xi{\kwd{pipe(}<readhandle>\kwd{,}<writehandle>\kwd{)}}
  674. Returns a pair of connected pipes.
  675. \Xi{\kwd{print}[\kwd{(}[<filehandle>]<list>\dag\kwd{)}*]}
  676. Prints a string or a comma-separated list of strings. If <filehandle>
  677. is omitted, prints by default to standard output (or to the last
  678. selected output channel - see \kwd{select}).  
  679. \Xi{\kwd{printf}[\kwd{(}[<filehandle>] <list>\kwd{)}*]}
  680. Equivalent to \kwd{print} <filehandle> \kwd {sprintf(}<list>\kwd{)}.
  681. \Xi{\kwd{read(}<filehandle>\kwd{,}|\$|<var>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
  682. Read <length> binary bytes from the file into the variable at
  683. <offset>. Returns number of bytes actually read. 
  684. \Xi{\kwd{seek(}<filehandle>\kwd{,}<position>\kwd{,}<whence>\kwd{)}}
  685. Arbitrarily positions the file. Returns 1 upon success, 0 otherwise.
  686. \Xi{\kwd{select}[\kwd{(}<filehandle>\kwd{)}]}
  687. Returns the currently selected filehandle. 
  688. Sets the current default filehandle for output operations if
  689. <filehandle> is supplied.
  690. \Xi{\kwd{select(}<rbits>\kwd{,}<wbits>\kwd{,}<nbits>\kwd{,}<timeout>\kwd{)}}
  691. Performs a {\it select\/}(2) system call with the same parameters.
  692. \Xi{\kwd{sprintf(}<format>\kwd{,}<list>\kwd{)}}
  693. Returns a string formatted by (almost all of) the usual printf
  694. conventions. 
  695. \Xi{\kwd{sysread(}<filehandle>\kwd{,}|\$|<var>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
  696. Reads <length> bytes into |$|<var> at <offset>.
  697. \Xi{\kwd{syswrite(}<filehandle>\kwd{,}<scalar>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
  698. Writes <length> bytes from <scalar> at <offset>.
  699. \Xi{\kwd{tell}[\kwd{(}<filehandle>\kwd{)}]*}
  700. Returns the current file position for the file. If <filehandle> is
  701. omitted, assumes the file last read. 
  702. \Xi{\kwd{write}[\kwd{(}<filehandle>\kwd{)}]*}
  703. Writes a formatted record to the specified file, using the format
  704. associated with that file. See ``Formats''. 
  705. \end{enum}
  706. \makeuppage
  707. \section{Search and replace functions}
  708. \begin{enum}{1cm}
  709. \catcode`\~=\other
  710. \Xi{[<expr> |=~|] [\kwd{m}]|/|<pattern>|/|[\kwd{g}][\kwd{i}][\kwd{o}]}
  711. Searches <expr> (default: |$_|) for a pattern. If you prepend an
  712. \kwd{m} you can use almost any pair of characters as delimiters. If
  713. used in array context, an array is returned consisting of the
  714. subexpressions matched by the parentheses in pattern, i.e.
  715. |($1,$2,$3,...)|.
  716. Optional modifiers: \kwd{g} matches as many times as possible; \kwd{i}
  717. searches in a case-insensitive manner; \kwd{o} interpolates variables
  718. only once.
  719. If <pattern> is empty, the most recent pattern from a
  720. previous match or replacement is used.
  721. With \kwd{g} the match can be used as an iterator in scalar context.
  722. \Xi{|?|<pattern>|?|}
  723. This is just like the |/|<pattern>|/| search, except that it matches
  724. only once between calls to the reset operator. If <pattern> is empty,
  725. the most recent pattern from a previous match or replacement is used.
  726. \Xi{[|\$|<var> |=~|] \kwd{s}|/|<pattern>|/|<replacement>|/|[\kwd{g}][\kwd{i}][\kwd{e}][\kwd{o}]}
  727. Searches a string for a pattern, and if found, replaces that pattern
  728. with the replacement text and returns the number of substitutions
  729. made. Otherwise it returns false. 
  730. Optional modifiers: \kwd{g} replaces all occurrences of the pattern;
  731. \kwd{e} interprets the replacement string as an expression; \kwd{i}
  732. and \kwd{o} as with |/|<pattern>|/| matching. Almost any delimiter may
  733. replace the slashes; if single quotes are used, no interpretation is
  734. done on the replacement string.
  735. If <pattern> is empty, the most recent pattern from a previous match or replacement is used.
  736. \Xi{\kwd{study}[\kwd{(}|\$|<var>\dag\kwd{)}*]}
  737. Study the contents of |$|<var> in anticipation of doing many pattern
  738. matches on the contents before it is next modified.
  739. \Xi{[|\$|<var> |=~|] \kwd{tr}|/|<searchlist>|/|<replacementlist>|/|[\kwd{c}][\kwd{d}][\kwd{s}]}
  740. Translates all occurrences of the characters found in the search list
  741. with the corresponding character in the replacement list. It returns
  742. the number of characters replaced. \kwd{y} may be used instead of \kwd{tr}. 
  743. Optional modifiers: \kwd{c} complements the <searchlist>; \kwd{d}
  744. deletes all characters not found in <searchlist>; \kwd{s} squeezes all
  745. sequences of characters that are translated into the same target
  746. character into one occurrence of this character.
  747. \end{enum}
  748. \section{System interaction} 
  749. \begin{enum}{1cm}
  750. \Xi{\kwd{alarm(}<expr>\kwd{)}*}
  751. Schedules a |SIGALRM| to be delivered after <expr> seconds. 
  752. \Xi{\kwd{chdir} [\kwd{(}<expr>\kwd{)}*]}
  753. Changes the working directory, |$ENV{"HOME"}| if <expr> is omitted.
  754. \Xi{\kwd{chroot(}<filename>\dag\kwd{)}*}
  755. Changes the root directory for the process and its children.
  756. \Xi{\kwd{die}[\kwd{(}<list>\kwd{)}*]}
  757. Prints the value of <list> to |STDERR| and exits with the current
  758. value of |$!| (errno). If |$!| is 0, exits with the value of |($? >> 8)|.
  759. If |($? >> 8)| is 0, exits with 255. <list> defaults to
  760. |"Died."|.
  761. \Xi{\kwd{exec(}<list>\kwd{)}*}
  762. Executes the system command in <list>; does not return.
  763. \Xi{\kwd{exit(}<expr>\kwd{)}*}
  764. Exits immediately with the value of |EXPR|.
  765. \Xi{\kwd{fork}}
  766. Does a {\it fork\/}(2) system call. Returns the child pid to the parent
  767. process and zero to the child process. 
  768. \Xi{\kwd{getlogin}}
  769. Returns the current login name as known by the system.
  770. \Xi{\kwd{getpgrp}[\kwd{(}<pid>\kwd{)}*]}
  771. Returns the process group for process <pid> (0, or omitted,  means the
  772. current process). 
  773. \Xi{\kwd{getppid}}
  774. Returns the process id of the parent process.
  775. \Xi{\kwd{getpriority(}<which>\kwd{,}<who>\kwd{)}}
  776. Returns the current priority for a process, process group, or user.
  777. \Xi{\kwd{kill(}<list>\kwd{)}*}
  778. Sends a signal to a list of processes. The first element of the list
  779. must be the signal to send (numeric, or its name as a string). 
  780. \Xi{\kwd{setpgrp(}<pid>\kwd{,}<pgrp>\kwd{)}}
  781. Sets the process group for the <pid> (0 = current process).
  782. \Xi{\kwd{setpriority(}<which>\kwd{,}<who>\kwd{,}<prio>\kwd{)}}
  783. Sets the current priority for a process, process group, or a user.
  784. \Xi{\kwd{sleep}[\kwd{(}<expr>\kwd{)}*]}
  785. Causes the script to sleep for <expr> seconds, or forever if no
  786. <expr>. Returns the number of seconds actually slept. 
  787. \Xi{\kwd{syscall(}<list>\kwd{)}*}
  788. Calls the system call specified in the first element of the list,
  789. passing the rest of the list as arguments to the call. 
  790. \Xi{\kwd{system(}<list>\kwd{)}*}
  791. Does exactly the same thing as \kwd{exec }<list> except that a fork is
  792. done first, and the parent process waits for the child process to complete. 
  793. \Xi{\kwd{times}}
  794. Returns a 4-element array (\$user, \$system, \$cuser, \$csystem) giving
  795. the user and system times, in seconds, for this process and the
  796. children of this process.  
  797. \Xi{\kwd{umask}[\kwd{(}<expr>\kwd{)}*]}
  798. Sets the umask for the process and returns the old one. If <expr> is
  799. omitted, returns current umask value. 
  800. \Xi{\kwd{wait}}
  801. Waits for a child process to terminate and returns the pid of the
  802. deceased process (-1 if none). The status is returned in |$?|. 
  803. \Xi{\kwd{waitpid(}<pid>\kwd{,}<flags>\kwd{)}}
  804. Performs the same function as the corresponding system call.
  805. \Xi{\kwd{warn(}<list>\kwd{)}*}
  806. Prints the message on |STDERR| like \kwd{die}, but doesn't exit.
  807. \end{enum}
  808. \makeuppage
  809. \section{Networking} 
  810. \begin{enum}{1cm}
  811. \Xi{\kwd{accept(}<newsocket>\kwd{,}<genericsocket>\kwd{)}}
  812. Accepts a new socket.
  813. \Xi{\kwd{bind(}<socket>\kwd{,}<name>\kwd{)}}
  814. Binds the <name> to the <socket>.
  815. \Xi{\kwd{connect(}<socket>\kwd{,}<name>\kwd{)}}
  816. Connects the <name> to the <socket>.
  817. \Xi{\kwd{getpeername(}<socket>\kwd{)}}
  818. Returns the socket address of the other end of the <socket>.
  819. \Xi{\kwd{getsockname(}<socket>\kwd{)}}
  820. Returns the name of the socket.
  821. \Xi{\kwd{getsockopt(}<socket>\kwd{,}<level>\kwd{,}<optname>\kwd{)}}
  822. Returns the socket options.
  823. \Xi{\kwd{listen(}<socket>\kwd{,}<queuesize>\kwd{)}}
  824. Starts listening on the specified <socket>.
  825. \Xi{\kwd{recv(}<socket>\kwd{,}<scalar>\kwd{,}<length>\kwd{,}<flags>\kwd{)}}
  826. Receives a message on <socket>.
  827. \Xi{\kwd{send(}<socket>\kwd{,}<msg>\kwd{,}<FLAGS[>\kwd{,}<to>]\kwd{)}}
  828. Sends a message on the <socket>.
  829. \Xi{\kwd{setsockopt(}<socket>\kwd{,}<level>\kwd{,}<optname>\kwd{,}<optval>\kwd{)}}
  830. Sets the requested socket option.
  831. \Xi{\kwd{shutdown(}<socket>\kwd{,}<how>\kwd{)}}
  832. Shuts down a <socket>.
  833. \Xi{\kwd{socket(}<socket>\kwd{,}<domain>\kwd{,}<type>\kwd{,}<protocol>\kwd{)}}
  834. Creates a <socket> in <domain> with <type> and <protocol>.
  835. \Xi{\kwd{socketpair(}<socket1>\kwd{,}<socket2>\kwd{,}<domain>\kwd{,}<type>\kwd{,}<protocol>\kwd{)}}
  836. As socket, but creates a pair of bi-directional sockets.
  837. \end{enum}
  838. \section{SystemV IPC} 
  839. The following functions all perform the same action as the
  840. corresponding system calls.
  841. \kwd{msgctl(}<id>\kwd{,}<cmd>\kwd{,}<args>\kwd{)} \\
  842. \kwd{msgget(}<key>\kwd{,}<flags>\kwd{)} \\
  843. \kwd{msgsnd(}<id>\kwd{,}<msg>\kwd{,}<flags>\kwd{)} \\
  844. \kwd{msgrcv(}<id>\kwd{,}\$<var>\kwd{,}<size>\kwd{,}<type>\kwd{,}<flags>\kwd{)} \\
  845. \kwd{semctl(}<id>\kwd{,}<semnum>\kwd{,}<cmd>\kwd{,}<arg>\kwd{)} \\
  846. \kwd{semget(}<key>\kwd{,}<nsems>\kwd{,}<size>\kwd{,}<flags>\kwd{)} \\
  847. \kwd{semop(}<key>\kwd{,}...\kwd{)} \\
  848. \kwd{shmctl(}<id>\kwd{,}<cmd>\kwd{,}<arg>\kwd{)} \\
  849. \kwd{shmget(}<key>\kwd{,}<size>\kwd{,}<flags>\kwd{)} \\
  850. \kwd{shmread(}<id>\kwd{,}\$<var>\kwd{,}<pos>\kwd{,}<size>\kwd{)} \\
  851. \kwd{shmwrite(}<id>\kwd{,}<string>\kwd{,}<pos>\kwd{,}<size>\kwd{)}
  852. \makeuppage
  853. \section{Miscellaneous} 
  854. \begin{enum}{1cm}
  855. \Xi{\kwd{caller}[\kwd{(}<expr>\kwd{)}]}
  856. Returns an array (\$package,\$file,\$line,...) for a specific subroutine
  857. call. ``|caller|'' returns this info for the current subroutine,
  858. ``|caller(1)|'' for the caller of this subroutine etc..  
  859. \Xi{\kwd{defined(}<expr>\kwd{)}*}
  860. Tests whether the lvalue <expr> has a real value.
  861. \Xi{\kwd{dump} [<label>]}
  862. Immediate core dump. When reincarnated, starts at <label>.
  863. \Xi{\kwd{local(}<list>\kwd{)}}
  864. Creates a scope for the listed variables local to the enclosing block,
  865. subroutine or eval. 
  866. \Xi{\kwd{package} <name>}
  867. Designates the remainder of the current block as a package.
  868. \Xi{\kwd{require(}\oEXPR\kwd{)}*}
  869. Includes the specified file from the perl library. Does not include
  870. more than once, and yields a fatal error if the file does include not OK. 
  871. \Xi{\kwd{reset} [\kwd{(}<expr>\kwd{)}*]}
  872. Resets |??| searches so that they work again. <expr> is a list of
  873. single letters. All variables and arrays beginning with one of those
  874. letters are reset to their pristine state.  Only affects the current
  875. package.
  876. \Xi{\kwd{scalar(}<expr>\kwd{)}}
  877. Forces evaluation of <expr> in scalar context.
  878. \Xi{\kwd{sub} <name> \{ <expr> |;| ... \}}
  879. Designates <name> as a subroutine. Parameters are passed by reference
  880. as array |@_|. Returns the value of the last expression evaluated. 
  881. \Xi{\kwd{undef}[\kwd{(}<lvalue>\kwd{)}*]}
  882. Undefines the <lvalue>. Always returns the undefined value.
  883. \Xi{\kwd{wantarray}}
  884. Returns true if the current context expects an array value.
  885. \end{enum}
  886. \section{Formats} 
  887. \kwd{format} [<name>] |=| \\
  888. <formlist> \\
  889. <formlist> pictures the lines, and contains the arguments which will
  890. give values to the fields in the lines. Picture fields are:
  891. |  @<<<...  | left adjusted field, repeat the |<| to denote the desired
  892. width; \\
  893. |  @>>>...  | right adjusted field; \\
  894. |  @|\|\|\||...  | centered field; \\
  895. |  @#.##... | numeric format with implied decimal point; \\
  896. |  @*       | a multi-line field.
  897. Use \^ instead of |@| for multi-line block filling.
  898. Use |~| at the beginning of a line to suppress unwanted empty lines.
  899. Use |~~| at the beginning of a line to have this format line repeated
  900. until all fields are exhausted. 
  901. Use |$-| to zero to force a page break.
  902. See also |$|\^, |$~|, |$-| and |$=| in section ``Special Variables''.
  903. \section{Info from system files} 
  904. {\large\sl passwd} \\
  905. Info is (\$name, \$passwd, \$uid, \$gid, \$quota, \$comment, \$gcos, \$dir, \$shell).
  906. \begin{enum}{6cm}
  907. \Xi{\kwd{endpwent}}    Ends lookup processing.
  908. \Xi{\kwd{getpwent}}    Gets next info.
  909. \Xi{\kwd{getpwnam(}<name>\kwd{)}}    Gets info by name. 
  910. \Xi{\kwd{getpwuid(}<uid>\kwd{)}}    Gets info by uid.
  911. \Xi{\kwd{setpwent}}    Resets lookup processing.
  912. \end{enum}
  913. {\vskip6pt\large\sl group} \\
  914. Info is a 4-item array: (\$name, \$passwd, \$gid, \$members).
  915. \begin{enum}{6cm}
  916. \Xi{\kwd{endgrent}}    Ends lookup processing.
  917. \Xi{\kwd{getgrgid(}<gid>\kwd{)}}    Gets info by group id. 
  918. \Xi{\kwd{getgrnam(}<name>\kwd{)}}    Gets info by name.
  919. \Xi{\kwd{getgrent}}    Gets next info.
  920. \Xi{\kwd{setgrent}}    Resets lookup processing.
  921. \end{enum}
  922. {\vskip6pt\large\sl hosts} \\
  923. Info is (\$name, \$aliases, \$addrtype, \$length, @addrs).
  924. \begin{enum}{6cm}
  925. \Xi{\kwd{endhostent}}    Ends lookup processing.
  926. \Xi{\kwd{gethostbyaddr(}<addr>\kwd{,}<addrtype>\kwd{)}}    Gets info by address.
  927. \Xi{\kwd{gethostbyname(}<name>\kwd{)}}    Gets info by name.
  928. \Xi{\kwd{gethostent}}    Gets next info.
  929. \Xi{\kwd{sethostent(}<stayopen>\kwd{)}}    Resets lookup processing.
  930. \end{enum}
  931. {\vskip6pt\large\sl networks} \\
  932. Info is (\$name, \$aliases, \$addrtype, \$net).
  933. \begin{enum}{6cm}
  934. \Xi{\kwd{endnetent}}    Ends lookup processing.
  935. \Xi{\kwd{getnetbyaddr(}<addr>\kwd{,}<type>\kwd{)}}    Gets info by address and type.
  936. \Xi{\kwd{getnetbyname(}<name>\kwd{)}}    Gets info by name.
  937. \Xi{\kwd{getnetent}}    Gets next info.
  938. \Xi{\kwd{setnetent(}<stayopen>\kwd{)}}    Resets lookup processing.
  939. \end{enum}
  940. {\vskip6pt\large\sl services} \\
  941. Info is (\$name, \$aliases, \$port, \$proto).
  942. \begin{enum}{6cm}
  943. \Xi{\kwd{endservent}}    Ends lookup processing.
  944. \Xi{\kwd{getservbyname(}<name>\kwd{, }<proto>\kwd{)}}    Gets info by name. 
  945. \Xi{\kwd{getservbyport(}<port>\kwd{, }<proto>\kwd{)}}    Gets info by port.
  946. \Xi{\kwd{getservent}}    Gets next info.
  947. \Xi{\kwd{setservent(}<stayopen>\kwd{)}}    Resets lookup processing.
  948. \end{enum}
  949. {\vskip6pt\large\sl protocols} \\
  950. Info is (\$name, \$aliases, \$proto).
  951. \begin{enum}{6cm}
  952. \Xi{\kwd{endprotoent}}    Ends lookup processing.
  953. \Xi{\kwd{getprotobyname(}<name>\kwd{)}}    Gets info by name.
  954. \Xi{\kwd{getprotobynumber(}<number>\kwd{)}}    Gets info by number.
  955. \Xi{\kwd{getprotoent}}    Gets next info.
  956. \Xi{\kwd{setprotoent(}<stayopen>\kwd{)}}    Resets lookup processing.
  957. \end{enum}
  958. \section{Regular expressions} 
  959. Each character matches itself, unless it is one of the special
  960. characters |+?.*()[]{}|\||\|.
  961. \begin{enum}{1cm}
  962. \Xj{|.|}
  963. matches an arbitrary character, but not a newline.
  964. \Xj{|(|\ldots|)|}
  965. groups a series of pattern elements to a single element.
  966. \Xj{|+|}
  967. matches the preceding pattern element one or more times.
  968. \Xj{|?|}
  969. matches zero or one times.
  970. \Xj{|*|}
  971. matches zero or more times.
  972. \Xj{\{<n>|,|<m>\}}
  973. denotes the minimum <n> and maximum <m> match count. |{|<n>|}| means
  974. exactly <n> times; |{|<n>|,}| means at least <n> times. 
  975. \Xj{|\char`\[|\ldots|\char`\]|}
  976. denotes a class of characters to match. |[|\^\ldots|]| negates the class.
  977. \Xj{|(|\ldots\|\ldots\|\ldots|)|}
  978. matches one of the alternatives.
  979. \end{enum}
  980. Non-alphanumerics can be escaped from their special meaning using a
  981. \begin{enum}{1cm}
  982. \Xj{|\char`\\w|}
  983. matches alphanumeric, including ``|_|'', |\W| matches non-alphanumeric.
  984. \Xj{|\char`\\b|}
  985. matches word boundaries, |\B| matches non-boundaries.
  986. \Xj{|\char`\\s|}
  987. matches whitespace, |\S| matches non-whitespace.
  988. \Xj{|\char`\\d|}
  989. matches numeric, |\D| matches non-numeric.
  990. \Xj{|\char`\\n|, |\char`\\r|, |\char`\\f|, |\char`\\t| etc.} 
  991. have their usual meaning.
  992. \Xj{|\char`\\w|, |\char`\\s| and |\char`\\d|}
  993. X may be used within character classes, |\b| denotes backspace in this context.
  994. \Xj{|\char`\\1|\ldots|\char`\\9|}
  995. refer to matched sub-expressions, grouped with |()|, inside
  996. the match. 
  997. \Xj{|\char`\\10|}
  998. and up can also be used if the pattern
  999. matches that many sub-expressions. 
  1000. \end{enum}
  1001. See also |$1|\ldots|$9|, |$+|, |$&|, |$`| and |$'| in section ``Special
  1002. Variables''.
  1003. \section{Special variables} 
  1004. The following variables are global and should be localized in subroutines:
  1005. \begin{enum}{1cm}
  1006. \Xi{|\char`\$\char`\_|}
  1007. The default input and pattern-searching space.
  1008. \Xi{|\char`\$\char`\.|}
  1009. The current input line number of the last filehandle that was read.
  1010. \Xi{|\char`\$\char`\/|}
  1011. The input record separator, newline by default. May be multi-character.
  1012. \Xi{|\char`\$\char`\,|}
  1013. The output field separator for the print operator.
  1014. \Xi{|\char`\$\char`\"|}
  1015. The separator which joins elements of arrays interpolated in strings.
  1016. \Xi{|\char`\$\char`\\|}
  1017. The output record separator for the print operator.
  1018. \Xi{|\char`\$\char`\#|}
  1019. The output format for printed numbers. Initial value is ``|%.20g|''.
  1020. \Xi{|\char`\$\char`\*|}
  1021. Set to 1 to do multiline matching within a string, 0 to assume strings
  1022. contain a single line. Default is 0. 
  1023. \Xi{|\char`\$\char`\?|}
  1024. The status returned by the last |`|<command>|`|, pipe close or
  1025. \kwd{system} operator. 
  1026. \Xi{|\char`\$\char`\]|}
  1027. The perl version string (as displayed with |perl -v|), or version number.
  1028. \Xi{|\char`\$\char`\[|}
  1029. The index of the first element in an array, and of the first character
  1030. in a substring. Default is 0. 
  1031. \Xi{|\char`\$\char`\;|}
  1032. The subscript separator for multi-dimensional array emulation. Default
  1033. is |"\034"|. 
  1034. \Xi{|\char`\$\char`\!|}
  1035. If used in a numeric context, yields the current value of errno. If
  1036. used in a string context, yields the corresponding error string. 
  1037. \Xi{|\char`\$\char`\@|}
  1038. The perl error message from the last eval or \kwd{do} <expr> command.
  1039. \Xi{|\char`\$\char`\:|}
  1040. The set of characters after which a string may be broken to fill
  1041. continuation fields (starting with ``|^|'') in a format. 
  1042. \Xi{|\char`\$\char`\0|}
  1043. The name of the file containing the perl script being executed. May be
  1044. assigned to. 
  1045. \Xi{|\char`\$\char`\$|}
  1046. The process number of the perl running this script. Altered (in the
  1047. child process) by \kwd{fork}. 
  1048. \Xi{|\char`\$\char`\<|}
  1049. The real uid of this process.
  1050. \Xi{|\char`\$\char`\>|}
  1051. The effective uid of this process. 
  1052. \Xi{|\char`\$\char`\(|}
  1053. The real gid of this process.
  1054. \Xi{|\char`\$\char`\)|}
  1055. The effective gid of this process.
  1056. \Xi{|\char`\$\char`\^D|}
  1057. The debug flags as passed to perl using |-D| .
  1058. \Xi{|\char`\$\char`\^F|}
  1059. The highest system file descriptor, ordinarily 2.
  1060. \Xi{|\char`\${\char`\^}I|}
  1061. In-place edit extension as passed to perl using |-i| .
  1062. \Xi{|\char`\$\char`\^P|}
  1063. Internal debugging flag.
  1064. \Xi{|\char`\$\char`\^T|}
  1065. The time (as delivered by \kwd{time}) when the program started. This
  1066. value is used by the file test operators ``|-M|'', ``|-A|'' and
  1067. ``|-C|''.
  1068. \Xi{|\char`\$\char`\^W|}
  1069. The value if the |-w| option as passed to perl.
  1070. \Xi{|\char`\$\char`\^X|}
  1071. The name by which this perl was invoked.
  1072. \end{enum}
  1073. The following variables are context dependent and need not be
  1074. localized:
  1075. \begin{enum}{1cm}
  1076. \Xi{|\char`\$\char`\%|}
  1077. The current page number of the currently selected output channel.
  1078. \Xi{|\char`\$\char`\=|}
  1079. The page length of the current output channel. Default is 60 lines.
  1080. \Xi{|\char`\$\char`\-|}
  1081. The number of lines left on the page.
  1082. \Xi{|\char`\$\char`\~|}
  1083. The name of the current report format.
  1084. \Xi{|\char`\$\char`\^|}
  1085. The name of the current top-of-page format.
  1086. \Xi{|\char`\$\char`\||}
  1087. If set to nonzero, forces a flush after every write or print on the
  1088. currently selected output channel. Default is 0. 
  1089. \Xi{|\char`\$ARGV|}
  1090. The name of the current file when reading from |<>| .
  1091. \end{enum}
  1092. The following variables are always local to the current block:
  1093. \begin{enum}{1cm}
  1094. \Xi{|\char`\$\char`\&|}
  1095. The string matched by the last pattern match.
  1096. \Xi{|\char`\$\char`\`|}
  1097. The string preceding what was matched by the last pattern match.
  1098. \Xi{|\char`\$\char`\'|}
  1099. The string following what was matched by the last pattern match. 
  1100. \Xi{|\char`\$\char`\+|}
  1101. The last bracket matched by the last search pattern.
  1102. \Xi{\$|1|\ldots\$|9|\ldots}
  1103. Contains the subpattern from the corresponding set of parentheses in
  1104. the last pattern matched. |$10|\ldots and up are only available if the
  1105. match contained that many sub-expressions. 
  1106. \end{enum}
  1107. \section{Special arrays} 
  1108. \begin{enum}{1.5cm}
  1109. \Xi{|@ARGV|}
  1110. Contains the command line arguments for the script (not including the command name).
  1111. \Xi{|@INC|}
  1112. Contains the list of places to look for perl scripts to be evaluated
  1113. by the \kwd{do} <filename> and \kwd{require} commands. 
  1114. \Xi{|@\char`\_|}
  1115. Parameter array for subroutines. Also used by \kwd{split} if not in
  1116. array context. 
  1117. \Xi{|\char`\%ENV|}
  1118. Contains the current environment.
  1119. \Xi{|\char`\%INC|}
  1120. List of files that have been \kwd{require}d or \kwd{do}ne.
  1121. \Xi{|\char`\%SIG|}Used to set signal handlers for various signals.
  1122. \end{enum}
  1123. \section{The perl debugger} 
  1124. The perl symbolic debugger is invoked with |perl -d|.
  1125. \begin{enum}{2.5cm}
  1126. \Xi{|h|}
  1127. Prints out a help message.
  1128. \Xi{|T|}
  1129. Stack trace.
  1130. \Xi{|s|}
  1131. Single steps.
  1132. \Xi{|n|}
  1133. Single steps around subroutine call.
  1134. \Xi{|r|}
  1135. Returns from the current subroutine.
  1136. \Xi{|c| [<line>]}
  1137. Continues (until <line>, or another breakpoint or exit).
  1138. \Xi{\fbox{<ret>}}
  1139. Repeats last |s| or |n|.
  1140. \Xi{|l| [<range>]}
  1141. Lists a range of lines. <range> may be a number, start-end,
  1142. start+amount, or a subroutine name. If omitted, lists next window. 
  1143. \Xi{|f| <file>}
  1144. Switches to <file> and start listing it.
  1145. \Xi{|-|}
  1146. Lists previous window.
  1147. \Xi{|w|}
  1148. Lists window around current line.
  1149. \Xi{|l| <sub>}
  1150. Lists the named <sub>routine.
  1151. \Xi{|/|<pattern>|/|}
  1152. Forward search for <pattern>.
  1153. \Xi{|?|<pattern>|?|}
  1154. Backward search for <pattern>.
  1155. \Xi{|L|}
  1156. Lists lines that have breakpoints or actions.
  1157. \Xi{|S|}
  1158. List the names of all subroutines.
  1159. \Xi{|t|}
  1160. Toggles trace mode.
  1161. \Xi{|b| [<line> [<condition>]]}
  1162. Sets breakpoint at <line>, default: current line.
  1163. \Xi{|b| <subname> [<condition>]}
  1164. Sets breakpoint at the subroutine.
  1165. \Xi{|S|}
  1166. Lists names of all subroutines.
  1167. \Xi{|d| [<line>]}
  1168. Deletes breakpoint at the given line.
  1169. \Xi{|D|}
  1170. Deletes all breakpoints.
  1171. \Xi{|a| <line command>}
  1172. Sets an action for line.
  1173. \Xi{|A|}
  1174. Deletes all line actions.
  1175. \Xi{|\char`\<| <command>}
  1176. Sets an action to be executed before every debugger prompt.
  1177. \Xi{|\char`\>| <command>}
  1178. Sets an action to be executed before every |s|, |c| or |n| command.
  1179. \Xi{|V| [<package> [<vars>] ]}
  1180. Lists all variables in a package. Default package is main.
  1181. \Xi{|X| [<vars>]}
  1182. Like |V|, but assumes current package.
  1183. \Xi{|!| [ [-]<number>]}
  1184. Redo a debugging command. Default is previous command.
  1185. \Xi{|H| [-<number>]}
  1186. Displays the last -<number> commands of more than one letter.
  1187. \Xi{|q|}
  1188. Quits. You may also use your \fbox{<eof>} character.
  1189. \Xi{<command>}
  1190. Executes <command> as a perl statement.
  1191. \Xi{|p| \oEXPR}
  1192. Prints <expr>.
  1193. \Xi{|=|< >[<alias value>]}
  1194. Sets alias, or lists current aliases.
  1195. \end{enum}
  1196. \newpage
  1197. \unnumbered{Notes}
  1198. \vfill
  1199. \makebox[\textwidth]{Perl Reference Guide Revision \refrev \hfill
  1200. \copyright 1989,1992 Johan Vromans}
  1201. \end{document}
  1202. SHAR_EOF
  1203. chmod 0644 refbase.tex ||
  1204. echo 'restore of refbase.tex failed'
  1205. Wc_c="`wc -c < 'refbase.tex'`"
  1206. test 47244 -eq "$Wc_c" ||
  1207.     echo 'refbase.tex: original size 47244, current size' "$Wc_c"
  1208. rm -f _shar_wnt_.tmp
  1209. rm -f _shar_seq_.tmp
  1210. echo You have unpacked the last part
  1211. exit 0
  1212. exit 0 # Just in case...
  1213.