home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sources / misc / 3892 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  54.4 KB

  1. Xref: sparky comp.sources.misc:3892 comp.lang.perl:5716
  2. Newsgroups: comp.sources.misc,comp.lang.perl
  3. Path: sparky!kent
  4. From: jv@mh.nl (Johan Vromans)
  5. Subject:  v32i002:  perlref - Perl Reference Guide 4.035.1, Part02/04
  6. Message-ID: <1992Sep4.023901.11943@sparky.imd.sterling.com>
  7. Followup-To: comp.sources.d
  8. X-Md4-Signature: 3d807c649ea5e54444c2b2a792f93f8c
  9. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  10. Organization: Sterling Software
  11. References: <csm-v32i001=perlref.213734@sparky.IMD.Sterling.COM>
  12. Date: Fri, 4 Sep 1992 02:39:01 GMT
  13. Approved: kent@sparky.imd.sterling.com
  14. Lines: 1822
  15.  
  16. Submitted-by: jv@mh.nl (Johan Vromans)
  17. Posting-number: Volume 32, Issue 2
  18. Archive-name: perlref/part02
  19. Supersedes: perlref: Volume 28, Issue 77-79
  20. Environment: Perl v4.035
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then feed it
  24. # into a shell via "sh file" or similar.  To overwrite existing files,
  25. # type "sh file -c".
  26. # Contents:  Makefile refbase.tex
  27. # Wrapped by kent@sparky on Wed Sep  2 21:35:21 1992
  28. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  29. echo If this archive is complete, you will see the following message:
  30. echo '          "shar: End of archive 2 (of 4)."'
  31. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'Makefile'\"
  33. else
  34.   echo shar: Extracting \"'Makefile'\" \(3058 characters\)
  35.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  36. X# @(#)@ Makefile 4.2.7 - Makefile for Perl Reference Guide
  37. X
  38. X# This Makefile requires perl to be in your PATH.
  39. X
  40. XSHELL    = /bin/sh
  41. XLATEX    = latex
  42. XDVIPS    = dvips
  43. X
  44. X# Delete the next line if you use US Letter paper format
  45. XPAPER    = -a4
  46. X
  47. Xall:    refguide.ps
  48. X
  49. X2pass:    guide-odd.ps guide-even1.ps guide-even2.ps
  50. X
  51. X# 2 pages per page, suitable for centrefold printing.
  52. Xrefguide.ps:    refbase.ps parr
  53. X    perl ./parr $(PAPER) \
  54. X        -o 21,2,3,20,19,4,5,18,17,6,7,16,15,8,9,14,13,10,11,12 \
  55. X        refbase.ps > refguide.ps
  56. X
  57. X# Odd and even passes for centerfold printing. 
  58. X# First print guide-odd.ps, then find out which of the others to use.
  59. X# guide-even1.ps is for printers with correct output stacking like
  60. X# Apple LaserWriter II. 
  61. X# guide-even2.ps for printers with reverse output stacking, like old
  62. X# Apple LaserWriters. 
  63. X
  64. Xguide-odd.ps:    refbase.ps parr
  65. X    perl ./parr $(PAPER) \
  66. X        -o 21,2,19,4,17,6,15,8,13,10 refbase.ps > guide-odd.ps
  67. X
  68. Xguide-even1.ps:    refbase.ps parr
  69. X    perl ./parr $(PAPER) \
  70. X        -o 11,12,9,14,7,16,5,18,3,20 refbase.ps > guide-even1.ps
  71. X
  72. Xguide-even2.ps:    refbase.ps parr
  73. X    perl ./parr $(PAPER) \
  74. X        -o 3,20,5,18,7,16,9,14,11,12 refbase.ps > guide-even2.ps
  75. X
  76. Xguide-test.ps:    refbase.ps parr
  77. X    perl ./parr $(PAPER) \
  78. X        -o 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 refbase.ps > guide-test.ps
  79. X
  80. Xclean:
  81. X    rm -f refguide.ps guide-odd.ps guide-even1.ps guide-even2.ps \
  82. X        refbase.dvi core *~
  83. X
  84. X# For maintenance use only ...
  85. X
  86. XVER    = 4.035
  87. X
  88. XCH    = ch00.tex ch01.tex ch02.tex ch03.tex ch04.tex ch05.tex \
  89. X      ch06.tex ch07.tex ch08.tex ch09.tex ch10.tex ch11.tex \
  90. X      ch12.tex ch13.tex ch14.tex ch15.tex ch16.tex ch17.tex \
  91. X      ch18.tex ch19.tex ch20.tex ch21.tex ch22.tex ch23.tex \
  92. X      ch24.tex ch25.tex ch26.tex ch27.tex \
  93. X      ch99.tex
  94. XSRC    = refbase.tex refbase.sty
  95. XAUX    = README ChangeLog Makefile parr Layout
  96. X
  97. X# Our TeX places its output here, never mind if yours doesn't.
  98. XTEXTMP = /usr/tmp/$(USER)TeX.
  99. X
  100. X# NOTE: DO NOT REMOVE OR CHANGE '-ta4' EVEN IF USING NON-A4 PAPER
  101. Xrefbase-ps:    refbase.dvi
  102. X    $(DVIPS) -r0 -ta4 refbase.dvi 
  103. X
  104. X#    -if [ -f psneat.pl ]; then \
  105. X#        mv refbase.ps refbase.ps~; \
  106. X#        perl ./psneat.pl refbase.ps~ > refbase.ps; \
  107. X#    else true; \
  108. X#    fi
  109. X
  110. Xrefbase.dvi:    $(SRC)
  111. X    $(LATEX) refbase.tex < /dev/null
  112. X    -if [ -f $(TEXTMP)dvi ]; then \
  113. X        mv $(TEXTMP)dvi refbase.dvi; \
  114. X    else true; \
  115. X    fi
  116. X
  117. XMASTER  = ref
  118. Xrefbase-tex:  $(MASTER)master.tex $(CH) makebase.pl
  119. X    perl ./makebase.pl $(REV) $(MASTER)master.tex > refbase.tex
  120. X
  121. Xkit:    
  122. X    REV=`cat Revision.SEQ`; \
  123. X    expr $$REV + 1 >Revision.SEQ; \
  124. X    (echo ""; echo Revision: $(VER).$$REV; what $(SRC) $(CH)) >> Revision; \
  125. X    $(MAKE) -$(MAKEFLAGS) REV=$$REV refbase-tex refbase-ps kitinternal
  126. X
  127. Xkitinternal:
  128. X    rm -f perlref_shr.* perlref_ltx.* perlref-$(VER).$(REV).tar.Z
  129. X    shar -c -n perlref-$(VER).$(REV) -a -s 'jv@mh.nl' \
  130. X        -o perlref-$(VER).$(REV)_shr -L30 -f $(AUX) refbase.ps
  131. X    shar -c -n perlltx-$(VER).$(REV) -a -s 'jv@mh.nl' \
  132. X        -o perlref-$(VER).$(REV)_ltx -L30 -f $(AUX) $(SRC)
  133. X    pdtar -zcvf perlref-$(VER).$(REV).tar.Z $(AUX) $(SRC) refbase.ps
  134. X    ls -l perlref-*_shr.* perlref-*_ltx.* perlref-*.tar.Z
  135. X
  136. Xident:
  137. X    what $(AUX) $(SRC)
  138. END_OF_FILE
  139.   if test 3058 -ne `wc -c <'Makefile'`; then
  140.     echo shar: \"'Makefile'\" unpacked with wrong size!
  141.   fi
  142.   # end of 'Makefile'
  143. fi
  144. if test -f 'refbase.tex' -a "${1}" != "-c" ; then 
  145.   echo shar: Will not clobber existing file \"'refbase.tex'\"
  146. else
  147.   echo shar: Extracting \"'refbase.tex'\" \(48498 characters\)
  148.   sed "s/^X//" >'refbase.tex' <<'END_OF_FILE'
  149. X\def\revision{1}
  150. X\documentstyle{refbase}
  151. X
  152. X\begin{document}
  153. X
  154. X
  155. X\begin{titlepage}
  156. X
  157. X\hbox{ }
  158. X\end{titlepage}
  159. X
  160. X\begin{titlepage}
  161. X\addtolength{\evensidemargin}{2cm}
  162. X\addtolength{\textwidth}{-2.1cm}
  163. X\vspace*{2.5cm}
  164. X
  165. X\unnumbered{Perl Reference Guide}
  166. X{\bf for Perl version \perlrev}
  167. X
  168. X\vskip1cm
  169. XPerl program designed and created by \\
  170. XLarry Wall \<lwall@netlabs.com\>
  171. X
  172. X\vskip1cm
  173. XReference guide designed and created by \\
  174. XJohan Vromans \<jv@mh.nl\>
  175. X
  176. X\vskip1.3cm
  177. X\unnumbered{Contents}
  178. X
  179. X\newcounter{xx}
  180. X\begin{list}{\thexx.}
  181. X{\setlength{\topsep}{0pt plus 1pt}
  182. X \setlength{\itemsep}{0pt plus 1pt}
  183. X \setlength{\parsep}{0pt plus 1pt}
  184. X \usecounter{xx}}
  185. X\item Command line options
  186. X\item Literals
  187. X\item Variables
  188. X\item Statements
  189. X\item Flow control
  190. X\item Operators
  191. X\item File test operators
  192. X\item Arithmetic functions
  193. X\item Conversion functions
  194. X\item Structure conversion
  195. X\item String functions
  196. X\item Array and list functions
  197. X\item File operations
  198. X\item Directory reading routines
  199. X\item Input / Output
  200. X\item Search and replace functions
  201. X\item System interaction
  202. X\item Networking
  203. X\item SystemV IPC
  204. X\item Miscellaneous
  205. X\item Formats
  206. X\item Info from system files
  207. X\item Regular expressions
  208. X\item Special variables
  209. X\item Special arrays
  210. X\item The perl debugger
  211. X\item Environment variables
  212. X\end{list}
  213. X\vskip1cm
  214. X{\catcode`\%=\other \small {Rev. \refrev}}
  215. X\end{titlepage}
  216. X
  217. X\unnumbered{Conventions}
  218. X
  219. X\begin{enum}{2cm}
  220. X\Xi{|fixed|} denotes literal text.
  221. X
  222. X\Xi{<this>} means variable text, i.e. things you must fill in.
  223. X
  224. X\Xi{<this>\dag} means that <this> will default to |$_| if omitted.
  225. X
  226. X\Xi{\kwd{word}} is a keyword, i.e. a word with a special meaning.
  227. X
  228. X\Xi{\fbox{<ret>}} denotes pressing a keyboard key.
  229. X
  230. X\Xi{[\ldots]} denotes an optional part.
  231. X
  232. X\Xi{(\ldots)*} means that the parentheses may be omitted.
  233. X
  234. X\end{enum}
  235. X
  236. X
  237. X\section{Command line options} 
  238. X
  239. X\begin{enum}{1cm}
  240. X
  241. X\Xi{|-a|} turns on autosplit mode when used with |-n| or
  242. X|-p|. Splits to |@F|.
  243. X
  244. X\Xi{|-c|} checks syntax but does not execute.
  245. X
  246. X\Xi{|-d|} runs the script under the debugger. Use |-de 0| to
  247. Xstart the debugger without a script.
  248. X
  249. X\Xi{|-D| <number>} sets debugging flags. 
  250. X
  251. X\Xi{|-e| <commandline>} may be used to enter one line of
  252. Xscript. Multiple |-e| commands may be given to build up a
  253. Xmulti-line script.
  254. X
  255. X\Xi{|-i| <ext>} files processed by the |<>| construct are
  256. Xto be edited in-place.
  257. X
  258. X\Xi{|-I| <dir>} with |-P|: tells the C preprocessor where
  259. Xto look for include files. The directory is prepended to |@INC|.
  260. X
  261. X\Xi{|-l| [ <octnum> ] } enables automatic line ending processing, e.g. |-l013|.
  262. X
  263. X\Xi{|-n|} assumes an input loop around your script. Lines are not
  264. Xprinted.
  265. X
  266. X\Xi{|-p|} assumes an input loop around your script. Lines are
  267. Xprinted.
  268. X
  269. X\Xi{|-P|} runs the C preprocessor on the script before
  270. Xcompilation by perl.
  271. X
  272. X\Xi{|-s|} interprets ``|-xxx|'' on the command line as
  273. Xswitches and sets the corresponding variables \$|xxx| in the script.
  274. X
  275. X\Xi{|-S|} uses the |PATH| environment variable to search for
  276. Xthe script.
  277. X
  278. X\Xi{|-u|} dumps core after compiling the script. To be used with
  279. Xthe {\it undump\/} program (where available).
  280. X
  281. X\Xi{|-U|} allows perl to do unsafe operations.
  282. X
  283. X\Xi{|-v|} prints the version and patchlevel of your perl
  284. Xexecutable.
  285. X
  286. X\Xi{|-w|} prints warnings about possible spelling errors and
  287. Xother error-prone constructs in the script.
  288. X
  289. X\Xi{|-x|} extracts perl program from input stream.
  290. X
  291. X\Xi{|-0| <val>} (that's the number zero) designates an
  292. Xinitial value for the record terminator \$|/|.
  293. XSee also |-l|.
  294. X
  295. X\end{enum}
  296. X
  297. X\makeuppage
  298. X
  299. X\section{Literals} 
  300. X
  301. XNumeric: |123  1_234  123.4  5E-10  0xff| (hex)|  0377| (octal).
  302. X
  303. X\hangindent=2cm\hangafter=1
  304. XString: |'abc'| literal string, no variable interpolation nor
  305. Xescape characters.
  306. X\newline Also: |q/abc/|.
  307. X\newline (Almost any pair of delimiters can be used instead of |/.../|.)
  308. X
  309. X\hangindent=2cm\hangafter=1
  310. X\makebox[1cm]{}|"abc"|
  311. XVariables are interpolated and escape sequences are processed. 
  312. X\newline Also: |qq/abc/|.
  313. X\newline Escape sequences: |\t| (Tab), |\n| (Newline), |\r| (Return),
  314. X|\f| (Formfeed), |\b| (Backspace), |\a| (Alarm), |\e|
  315. X(Escape), |\033|(octal), |\x1b|(hex), |\c[| (control).
  316. X\newline |\l| and |\u| lowcase/upcase the following character; 
  317. X\newline |\L| and |\U| lowcase/upcase until a |\E| is encountered.
  318. X
  319. X
  320. X\hangindent=2cm\hangafter=1
  321. X\makebox[1cm]{}|`|<command>|`|
  322. Xevaluates to the output of the <command>. 
  323. X\newline Also: |qx/|<command>|/|.
  324. X
  325. X\hangindent=1cm\hangafter=1
  326. XArray: |(1,2,3)|. |()| is an empty array.  
  327. X\newline Also: |($a,$b,@rest) = (1,2,...);|
  328. X\newline |(1..4)| is the same as |(1,2,3,4)|. Likewise |('abc'..'ade')|
  329. X
  330. X\hangindent=1cm\hangafter=1
  331. XAssociative array:
  332. X|(|<key1>|,|<val1>|,|<key2>|,|<val2>|,...)|
  333. X
  334. X\hangindent=1cm\hangafter=1
  335. XFilehandles: 
  336. X\newline Pre-defined: |<STDIN>|, |<STDOUT>|, |<STDERR>|, |<ARGV>|,
  337. X|<DATA>|;
  338. X\newline User-specified: |<|<handle>|>|, |<$|<var>|>|.
  339. X\newline |<>| is the input stream formed by the files specified in
  340. X|@ARGV|, or standard input if no arguments are supplied.
  341. X
  342. X\hangindent=1cm\hangafter=1
  343. XGlobs: |<|<pattern>|>| evaluates to all filenames according
  344. Xto the pattern.
  345. X\newline Use |<${|<var>|}>| to glob from a variable.
  346. X
  347. X\hangindent=1cm\hangafter=1
  348. XHere-Is: |<<|<identifier>
  349. X\newline {\it See the manual for details.}
  350. X
  351. X\hangindent=1cm\hangafter=1
  352. XSpecial tokens:
  353. X\newline \_\,\_|FILE|\_\,\_: filename; \_\,\_|LINE|\_\,\_: line number.
  354. X\newline \_\,\_|END|\_\,\_: end of program; remaining lines can be read using
  355. X\<<data>\>.
  356. X
  357. X
  358. X\section{Variables} 
  359. X
  360. X\begin{enum}{3.2cm}
  361. X
  362. X\Xi{|\$var|} a simple scalar variable
  363. X
  364. X\Xi{|\$var[28]|} 29th element of array |@var| (the |[]| are
  365. Xpart of it)
  366. X
  367. X\Xi{|\$var\{'Feb'\}|} one value from associative array |%var|
  368. X
  369. X\Xi{|\$\#var|} last index of array |@var|
  370. X
  371. X\Xi{|@var|} the entire array;
  372. X\\
  373. Xin scalar context: the number of elements in the array
  374. X
  375. X\Xi{|@var[3,4,5]|} a slice of the array |@var|
  376. X
  377. X\Xi{|@var\{'a','b'\}|} a slice of |%var|; same as
  378. X|($var{'a'},$var{'b'})|
  379. X
  380. X\Xi{|\%var|} the entire associative array;
  381. X\\
  382. Xin scalar context: TRUE if the array has elements
  383. X
  384. X\Xj{|\$var\{'a',1,...\}|} emulates a multi-dimensional array
  385. X
  386. X\Xi{|('a'..'z')[4,7,9]|} a slice of an array literal
  387. X
  388. X\Xi{|*|<name>} refers to all objects represented by <name>.
  389. X``|*name1 = *name2|'' makes |name1| a reference to |name2|.
  390. X
  391. X\end{enum}
  392. X
  393. X
  394. X\section{Statements} 
  395. X
  396. XEvery statement is an expression, optionally followed by a modifier,
  397. Xand terminated by a semicolon.  The semicolon may be omitted if the
  398. Xstatement is the final one in a BLOCK.
  399. X
  400. XExecution of expressions can depend on other expressions using one of
  401. Xthe modifiers \kwd{if}, \kwd{unless}, \kwd{while} or \kwd{until},
  402. Xe.g.:
  403. X
  404. X\quad    <expr1> \kwd{if} <expr2> |;| \\
  405. X\quad    <expr1> \kwd{until} <expr2> |;|
  406. X
  407. XAlso, by using one of the logical operators \|\|, |&&| or |? :|, e.g.:
  408. X
  409. X\quad    <expr1> \|\| <expr2> |;| \\
  410. X\quad    <expr1> |?| <expr2> |:| <expr3> |;| 
  411. X
  412. XStatements can be combined to form a <block> when enclosed in |{}|.
  413. X
  414. XCompound statements may be used to control flow:
  415. X
  416. X\quad    \kwd{if} |(|<expr>|)| <block> [ [ \kwd{elsif}
  417. X    |(|<expr>|)| <BLOCK ...> ] \kwd{else}
  418. X    <block> ]
  419. X\\
  420. X\quad    \kwd{unless} |(|<expr>|)| <block> [ \kwd{else}
  421. X    <block> ]
  422. X\\
  423. X\quad    [ <label>\kwd{:} ] \kwd{while} |(|<expr>|)|
  424. X    <block> [ \kwd{continue} <block> ]
  425. X\\
  426. X\quad    [ <label>\kwd{:} ] \kwd{until} |(|<expr>|)|
  427. X    <block> [ \kwd{continue} <block> ]
  428. X\\
  429. X\quad    [ <label>\kwd{:} ] \kwd{for} |(|<expr>|;|
  430. X    <expr>|;| <expr>|)| <block>
  431. X\\
  432. X\quad    [ <label>\kwd{:} ] \kwd{foreach} <var>\dag
  433. X    |(|<array>|)| <block>
  434. X\\
  435. X\quad    [ <label>\kwd{:} ] <block> [ \kwd{continue} < block> ]
  436. X
  437. XSpecial forms are:
  438. X
  439. X\quad    \kwd{do} <block> \kwd{while} <expr> |;| \\
  440. X\quad    \kwd{do} <block> \kwd{until} <expr> |;| \\
  441. X
  442. Xwhich are guaranteed to perform <block> once before testing <expr>.
  443. X
  444. X
  445. X
  446. X\section{Flow control} 
  447. X
  448. X\begin{enum}{1cm}
  449. X
  450. X\Xi{\kwd{do} <block>}
  451. XReturns the value of the last command in the sequence of commands indicated by <block>. \kwd{next}, \kwd{last} and \kwd{redo}
  452. X cannot be used here.
  453. X
  454. X\Xi{\kwd{do} <subroutine>\kwd{(LIST)}} 
  455. XExecutes a <subroutine> declared by a \kwd{sub} declaration, and
  456. Xreturns the value of the last expression evaluated in <subroutine> .
  457. X\newline Preferred form is: |&|<subroutine> .
  458. X
  459. X\Xi{\kwd{do} <FILENAME>}
  460. XExecutes the contents of <filename> as a perl script. Errors are
  461. Xreturned in |$@|.
  462. X\newline Preferred form is: \kwd{require} <filename> .
  463. X
  464. X\Xi{\kwd{goto} <label>}
  465. XContinue execution at the specified label.
  466. X
  467. X\Xi{\kwd{last} [<label>]}
  468. XImmediately exits the loop in question. Skips continue block.
  469. X
  470. X\Xi{\kwd{next} [<label>]}
  471. XStarts the next iteration of the loop.
  472. X
  473. X\Xi{\kwd{redo} [<label>]}
  474. XRestarts the loop block without evaluating the conditional again.
  475. X
  476. X\Xi{\kwd{return} <expr>}
  477. XReturns from a subroutine with the value specified.
  478. X
  479. X\end{enum}
  480. X
  481. X
  482. X\section{Operators} 
  483. X
  484. X\begin{tabbing}
  485. X|    |\=|    |\= \kill
  486. X|+ -| \> |* /| \> Addition, subtraction, multiplication, division. \\
  487. X|%| \> \> Modulo division. \\
  488. X\| \& \> \^ \> Bitwise or, bitwise and, bitwise exclusive or. \\
  489. X|>>| \> |<<| \> Bitwise shift right, bitwise shift left. \\
  490. X|**| \> \> Exponentiation. \\
  491. X|.| \> \> Concatenation of two strings. \\
  492. X\kwd{x} \> \> Returns a string or array consisting of the left operand
  493. X(an array or \\
  494. X\> \> a string) repeated the number of times specified by the right operand.
  495. X\end{tabbing}
  496. X
  497. XAll of the above operators also have an assignment operator, e.g. ``|.=|''.
  498. X
  499. X\begin{tabbing}
  500. X|    |\=|    |\= \kill
  501. X|++| \> |--| \> Auto-increment (magical on strings), auto-decrement. \\
  502. X|? :|\>      \> Alternation (if-then-else) operator. \\
  503. X\|\| \> \&\&   \> Logical or, logical and. \\
  504. X|=|\,|=| \> |!=| \> Numeric equality, inequality. \\
  505. X\kwd{eq} \> \kwd{ne} \> String equality, inequality. \\
  506. X|<|  \>  |>|  \> Numeric less than, greater than. \\
  507. X\kwd{lt} \> \kwd{gt} \> String less than, greater than. \\
  508. X|<=| \> |>=| \> Numeric less (greater) than or equal to. \\
  509. X\kwd{le} \> \kwd{ge} \> String less (greater) than or equal. \\
  510. X|<=>| \> \> Numeric compare. Returns -1, 0 or 1. \\
  511. X\kwd{cmp} \> \> String compare. Returns -1, 0 or 1. \\
  512. X|=~| \> |!~| \> Search pattern, substitution, or translation (negated). \\
  513. X|..| \> \> Enumeration, also input line range operator. \\
  514. X|,| \> \> Comma operator.
  515. X\end{tabbing}
  516. X
  517. X
  518. X\section{File test operators} 
  519. X
  520. XThese unary operators takes one argument, either a filename or a
  521. Xfilehandle, and tests the associated file to see if something is true
  522. Xabout it. If the argument is omitted, tests |$_| (except for |-t,|
  523. Xwhich tests |STDIN|). If the special argument |_| (underscore) is
  524. Xpassed, uses the info of the preceding test. 
  525. X
  526. X\begin{enum}{2.5cm}
  527. X
  528. X\Xi{|-r -w -x|}  File is readable/writable/executable by effective uid/gid.
  529. X
  530. X\Xi{|-R -W -X|}  File is readable/writable/executable by real uid/gid.
  531. X
  532. X\Xi{|-o  -O|}  File is owned by effective/real uid. 
  533. X
  534. X\Xi{|-e  -z|}  File exists / has zero size. 
  535. X
  536. X\Xi{|-s|}  File exists and has non-zero size. Returns the size.
  537. X
  538. X\Xi{|-f  -d|}  File is a plain file, a directory.
  539. X
  540. X\Xi{|-l  -S  -p|}  File is a symbolic link, a socket, a named pipe (FIFO). 
  541. X
  542. X\Xi{|-b  -c|}  File is a block/character special file. 
  543. X
  544. X\Xi{|-u  -g  -k|}  File has setuid/setgid/sticky bit set. 
  545. X
  546. X\Xi{|-t|}  Tests if filehandle (|STDIN| by default) is opened to a tty.
  547. X
  548. X\Xi{|-T  -B|}  File is a text/non-text (binary) file.  |-T| and |-B|
  549. Xreturn TRUE on a null file, or a file at EOF when testing a filehandle. 
  550. X
  551. X\Xi{|-M  -A  -C|}  File creation / access / inode change time. Measured
  552. Xin days since this program started. See also |$^T| in section
  553. X``Special~Variables''.
  554. X
  555. X\end{enum}
  556. X
  557. X\makeuppage
  558. X
  559. XA <list> is a (possibly parenthesised) list of expressions, variables
  560. Xor <list>s. An array variable or an array slice may always be used
  561. Xinstead of a <list>.  
  562. X
  563. X\section{Arithmetic functions} 
  564. X
  565. X\begin{enum}{1cm}
  566. X
  567. X\Xi{\kwd{atan2(}<y>\kwd{,}<x>\kwd{)}}
  568. XReturns the arctangent of <Y>/<X> in the range -$\pi$ to $\pi$.
  569. X
  570. X\Xi{\kwd{cos(}\oEXPR \kwd{)}*}
  571. XReturns the cosine of <expr> (expressed in radians).
  572. X
  573. X\Xi{\kwd{exp(}\oEXPR \kwd{)}*}
  574. XReturns |e| to the power of <expr>.
  575. X
  576. X\Xi{\kwd{int(}\oEXPR \kwd{)}*}
  577. XReturns the integer portion of <expr>.
  578. X
  579. X\Xi{\kwd{log(}\oEXPR \kwd{)}*}
  580. XReturns natural logarithm (base |e|) of <expr>.
  581. X
  582. X\Xi{\kwd{rand}[\kwd{(}<expr>\kwd{)}*]}
  583. XReturns a random fractional number between 0 and the value of <expr>.
  584. XIf <expr> is omitted, returns a value between 0 and 1. 
  585. X
  586. X\Xi{\kwd{sin(}\oEXPR \kwd{)}*}
  587. XReturns the sine of <expr> (expressed in radians).
  588. X
  589. X\Xi{\kwd{sqrt(}\oEXPR \kwd{)}*}
  590. XReturn the square root of <expr>.
  591. X
  592. X\Xi{\kwd{srand}[\kwd{(}<expr>\kwd{)}*]}
  593. XSets the random number seed for the rand operator.
  594. X
  595. X\Xi{\kwd{time}}
  596. XReturns the number of seconds since January 1, 1970. Suitable for
  597. Xfeeding to \kwd{gmtime} and \kwd{localtime}. 
  598. X
  599. X\end{enum}
  600. X
  601. X
  602. X\section{Conversion functions} 
  603. X
  604. X\begin{enum}{1cm}
  605. X
  606. X\Xi{\kwd{gmtime(}<expr>\kwd{)}*}
  607. XConverts a time as returned by the \kwd{time} function to a 9-element
  608. Xarray (\$sec, \$min, \$hour, \$mday, \$mon, \$year, \$wday,
  609. X\$yday, \$isdst) with the time analyzed for the Greenwich timezone.
  610. X\$mon has the range 0..11 and \$wday has the range 0..6.
  611. X
  612. X\Xi{\kwd{hex(}\oEXPR\kwd{)}*}
  613. XReturns the decimal value of <expr> interpreted as an hex string.
  614. X
  615. X\Xi{\kwd{localtime(}<expr>\kwd{)}*}
  616. XConverts a time as returned by the \kwd{time} function to a 9-element
  617. Xarray with the time analyzed for the local timezone. 
  618. X
  619. X\Xi{\kwd{oct(}\oEXPR\kwd{)}*}
  620. XReturns the decimal value of <expr> interpreted as an octal string. If
  621. X<expr> starts off with |0x|, interprets it as a hex string instead.
  622. X
  623. X\Xi{\kwd{ord(}\oEXPR\kwd{)}*}
  624. XReturns the ascii value of the first character of <expr>.
  625. X
  626. X\Xi{\kwd{vec(}<expr>\kwd{,}<offset>\kwd{,}<bits>\kwd{)}}
  627. XTreats <expr> as a string of unsigned ints, and yields the bit at
  628. X<offset>. <bits> must be between 1 and 32. May be used as an lvalue.
  629. X
  630. X\end{enum}
  631. X
  632. X
  633. X\section{Structure conversion} 
  634. X
  635. X\begin{enum}{1cm}
  636. X
  637. X\Xi{\kwd{pack(}<template>\kwd{,}<list>\kwd{)}}
  638. XPacks the values into a binary structure using <template>.
  639. X
  640. X\Xi{\kwd{unpack(}<template>\kwd{,}<expr>\kwd{)}}
  641. XUnpacks the structure <expr> into an array, using <template>.
  642. X
  643. X<template> is a sequence of characters as follows:
  644. X
  645. X\begin{tabbing}
  646. X|  |\=|a |\=|/ |\=|A  |\= \kill
  647. X  \> |a| \> / \> |A| \> Ascii string, null / space padded \\
  648. X  \> |b| \> / \> |B| \> Bit string in ascending / descending order \\
  649. X  \> |c| \> / \> |C| \> Native / unsigned char value \\
  650. X  \> |f| \> / \> |d| \> Single / double float in native format \\
  651. X  \> |h| \> / \> |H| \> Hex string, low / high nybble first. \\
  652. X  \> |i| \> / \> |I| \> Signed / unsigned integer value \\
  653. X  \> |l| \> / \> |L| \> Signed / unsigned long value \\
  654. X  \> |n| \> / \> |N| \> Short / long in network (big endian) byte order \\
  655. X  \> |s| \> / \> |S| \> Signed / unsigned short value \\
  656. X  \> |u| \> / \> |p| \> Uuencoded string / Pointer to a string \\
  657. X  \> |v| \> / \> |V| \> Short / long in VAX (little endian) byte order \\
  658. X  \> |x| \> / \> |@| \> Null byte / null fill until position \\
  659. X  \> |X| \>   \>     \> Backup a byte
  660. X\end{tabbing}
  661. X
  662. XEach character may be followed by a decimal number which will be used
  663. Xas a repeat count, an |*| specifies all remaining arguments. \\
  664. XIf the format is preceded with |%|<n>, \kwd{unpack} returns an
  665. X<n>-bit checksum instead. \\
  666. XSpaces may be included in the template for readability purposes.
  667. X
  668. X\end{enum}
  669. X
  670. X
  671. X\section{String functions} 
  672. X
  673. X\begin{enum}{1cm}
  674. X
  675. X\Xi{\kwd{chop(}<list>\dag\kwd{)}}
  676. XChops off the last character on all elements of the list; returns the
  677. Xlast chopped character. The parentheses may be omitted if <list> is a
  678. Xsingle variable.
  679. X
  680. X\Xi{\kwd{crypt(}<plaintext>\kwd{,}<salt>\kwd{)}}
  681. XEncrypts a string.
  682. X
  683. X\Xi{\kwd{eval(}\oEXPR \kwd{)}*}
  684. X<expr> is parsed and executed as if it were a perl program. The value
  685. Xreturned is the value of the last expression evaluated. If there is a
  686. Xsyntax error or runtime error, an undefined string is returned by
  687. X\kwd{eval}, and |$@| is set to the error message.
  688. X
  689. X\Xi{\kwd{eval\{}<expr>\kwd{;...\}}}
  690. XExecutes the code between \{ and \}. Traps runtime errors as described
  691. Xabove.
  692. X
  693. X\Xi{\kwd{index(}<str>\kwd{,}<substr>[\kwd{,}<offset>]\kwd{)}}
  694. XReturns the position of <substr> in <str> at or after <offset>. If the
  695. Xsubstring is not found, returns |$[-1|.
  696. X
  697. X\Xi{\kwd{length(}\oEXPR\kwd{)}*}
  698. XReturns the length in characters of the value of <expr>.
  699. X
  700. X\Xi{\kwd{rindex(}<str>\kwd{,}<substr>[\kwd{,}<offset>]\kwd{)}}
  701. XReturns the position of the last <substr> in <str> at or
  702. Xbefore <offset>.
  703. X
  704. X\Xi{\kwd{substr(}<expr>\kwd{,}<offset>[\kwd{,}<len>]\kwd{)}}
  705. XExtracts a substring out of <expr> and returns it. If <offset>
  706. Xis negative, counts from the end of the string. May be used as an lvalue.
  707. X
  708. X\end{enum}
  709. X
  710. X\makeuppage
  711. X
  712. X\section{Array and list functions} 
  713. X
  714. X\begin{enum}{1cm}
  715. X
  716. X\Xi{\kwd{delete} \$<array>\{<key>\}}
  717. XDeletes the specified value from the specified associative array.
  718. XReturns the deleted value. 
  719. X
  720. X\Xi{\kwd{each(}|\%|<array>\kwd{)}*}
  721. XReturns a 2-element array consisting of the key and value for the next
  722. Xvalue of an associative array. Entries are returned in an apparently
  723. Xrandom order. When the array is entirely read, a null array is
  724. Xreturned. The next call to \kwd{each} after that will start iterating again.
  725. X
  726. X\Xi{\kwd{grep(}<expr>\kwd{,}<list>\kwd{)}}
  727. XEvaluates <expr> for each element of the <list>, locally setting |$_|
  728. Xto refer to the element. Modifying |$_| will modify the corresponding
  729. Xelement from <list>. Returns array of elements from <list> for which
  730. X<expr> returned true. 
  731. X
  732. X\Xi{\kwd{join(}<expr>\kwd{,}<list>\kwd{)}}
  733. XJoins the separate strings of <list> into a single string with fields
  734. Xseparated by the value of <expr>, and returns the string.
  735. X
  736. X\Xi{\kwd{keys(}|\%|<array>\kwd{)}*}
  737. XReturns an array with of all the keys of the named
  738. Xassociative array.
  739. X
  740. X\Xi{\kwd{pop(}|@|<array>\kwd{)}*}
  741. XPops and returns the last value of the array, shortens the array by 1. 
  742. X
  743. X\Xi{\kwd{push(}|@|<array>\kwd{,}<list>\kwd{)}}
  744. XPushes the values of <list> onto the end of <array>. The length of the
  745. Xarray increases by the length of <list>.
  746. X
  747. X\Xi{\kwd{reverse(}<list>\kwd{)}*}
  748. XIn array context: returns the <list> in reverse order. \\
  749. XIn scalar
  750. Xcontext: returns the first element of <list> with bytes reversed. 
  751. X
  752. X\Xi{\kwd{scalar(}|@|<array>\kwd{)}}
  753. XReturns the number of elements in the array.
  754. X
  755. X\Xi{\kwd{scalar(}|\%|<array>\kwd{)}}
  756. XReturns TRUE if the associative array has elements defined.
  757. X
  758. X\Xi{\kwd{shift}[\kwd{(}|@|<array>\kwd{)}*]}
  759. XShifts the first value of the array off and returns it, shortening the
  760. Xarray by 1 and moving everything down. If |@|<array> is omitted, shifts
  761. X|@ARGV| in main and |@_| in subroutines.  
  762. X
  763. X\Xi{\kwd{sort(} [<subroutine> ] <list>\kwd{)}*}
  764. XSorts the <list> and returns the sorted array value. If <subroutine>
  765. Xis specified, gives the name of a subroutine that returns less than
  766. Xzero, zero, or greater than zero, depending on how the elements of the
  767. Xarray, available to the routine as |$a| and |$b|, are to be ordered.
  768. X\\
  769. X<SUBROUTINE> may be the name of a user-defined routine, or a <block>
  770. X(see ``Statements'' and ``Miscellaneous'').
  771. X
  772. X\Xi{\kwd{splice(}|@|<array>\kwd{,}<offset>[\kwd{,}<length>[\kwd{,}<list>]]\kwd{)}}
  773. XRemoves the elements of |@|<array> designated by <offset> and
  774. X<length>, and replaces them with <list> (if specified). \\
  775. XReturns the elements removed.
  776. X
  777. X\Xi{\kwd{split}[\kwd{(}<pattern>[\kwd{,}\oEXPR [\kwd{,}<limit>]]\kwd{)}]}
  778. XSplits a string into an array of strings, and returns it. If <limit>
  779. Xis specified, splits in no more than that many fields. If <pattern> is
  780. Xalso omitted, splits on whitespace. If
  781. Xnot in array context: returns number of fields and splits to |@_|.
  782. XSee also: ``Search and Replace Functions''. 
  783. X
  784. X\Xi{\kwd{unshift(}|@|<array>\kwd{,}<list>\kwd{)}}
  785. XPrepends list to the front of the array, and returns the number of
  786. Xelements in the new array.
  787. X
  788. X\Xi{\kwd{values(}|\%|<array>\kwd{)}*}
  789. XReturns a normal array consisting of all the values of the named
  790. Xassociative array. 
  791. X
  792. X\end{enum}
  793. X
  794. X
  795. X
  796. X\makeupspace{1cm}
  797. X
  798. X\section{File operations} 
  799. X
  800. XFunctions operating on a list of files return the number of files
  801. Xsuccessfully operated upon.
  802. X
  803. X\begin{enum}{1cm}
  804. X
  805. X\Xi{\kwd{chmod(}<list>\kwd{)}*}
  806. XChanges the permissions of a list of files. The first element of the
  807. Xlist must be the numerical mode. 
  808. X
  809. X\Xi{\kwd{chown(}<list>\kwd{)}*}
  810. XChanges the owner and group of a list of files. The first two elements
  811. Xof the list must be the numerical uid and gid. 
  812. X
  813. X\Xi{\kwd{truncate(}<file>\kwd{,}<size>\kwd{)}}
  814. Xtruncates <file> to <size>. <file> may be a filename or a filehandle.
  815. X
  816. X\Xi{\kwd{link(}<oldfile>\kwd{,}<newfile>\kwd{)}}
  817. XCreates a new filename linked to the old filename.
  818. X
  819. X\Xi{\kwd{lstat(}<file>\kwd{)}}
  820. XLike stat, but does not traverse a final symbolic link.
  821. X
  822. X\Xi{\kwd{mkdir(}<dir>\kwd{,}<mode>\kwd{)}}
  823. XCreates a directory with given permissions. Sets |$!| on failure.
  824. X
  825. X\Xi{\kwd{readlink(}\oEXPR\kwd{)}*}
  826. XReturns the value of a symbolic link.
  827. X
  828. X\Xi{\kwd{rename(}<oldname>\kwd{,}<newname>\kwd{)}}
  829. XChanges the name of a file.
  830. X
  831. X\Xi{\kwd{rmdir(}<filename>\dag\kwd{)}*}
  832. XDeletes the directory if it is empty. Sets |$!| on failure.
  833. X
  834. X\Xi{\kwd{stat(}<file>\kwd{)}}
  835. XReturns a 13-element array (\$dev, \$ino, \$mode, \$nlink, \$uid, \$gid,
  836. X\$rdev, \$size, \$atime, \$mtime, \$ctime, \$blksize, \$blocks). <file> can
  837. Xbe a filehandle, an expression evaluating to a filename, or |_| to
  838. Xrefer to the last file test operation. 
  839. X\\
  840. XReturns a null list if the \kwd{stat} fails.
  841. X
  842. X\Xi{\kwd{symlink(}<oldfile>\kwd{,}<newfile>\kwd{)}}
  843. XCreates a new filename symbolically linked to the old filename.
  844. X
  845. X\Xi{\kwd{unlink(}<list>\kwd{)}*}
  846. XDeletes a list of files.
  847. X
  848. X\Xi{\kwd{utime(}<list>\kwd{)}*}
  849. XChanges the access and modification times. The first two elements of
  850. Xthe list must be the numerical access and modification times.
  851. X
  852. X\end{enum}
  853. X
  854. X
  855. X
  856. X\makeuppage
  857. X
  858. X\section{Directory reading routines} 
  859. X
  860. X\begin{enum}{1cm}
  861. X
  862. X\Xi{\kwd{closedir(}<dirhandle>\kwd{)}*}
  863. XCloses a directory opened by opendir.
  864. X
  865. X\Xi{\kwd{opendir(}<dirhandle>\kwd{,}<dirname>\kwd{)}}
  866. XOpens a directory on the handle specified.
  867. X
  868. X\Xi{\kwd{readdir(}<dirhandle>\kwd{)}*}
  869. XReturns the next entry (or an array of entries) in the directory.
  870. X
  871. X\Xi{\kwd{rewinddir(}<dirhandle>\kwd{)}*}
  872. XPositions the directory to the beginning.
  873. X
  874. X\Xi{\kwd{seekdir(}<dirhandle>\kwd{,}<pos>\kwd{)}}
  875. XSets position for readdir on the directory.
  876. X
  877. X\Xi{\kwd{telldir(}<dirhandle>\kwd{)}*}
  878. XReturns the postion in the directory.
  879. X
  880. X\end{enum}
  881. X
  882. X
  883. X\section{Input / Output} 
  884. X
  885. XIn input/output operations, <filehandle> may be a filehandle as opened
  886. Xby the \kwd{open} operator, or a scalar variable which evaluates to
  887. Xthe name of a filehandle to be used.  
  888. X
  889. X\begin{enum}{1cm}
  890. X
  891. X\Xi{\kwd{binmode(}<filehandle>\kwd{)}*}
  892. XArranges for the file opened on <filehandle> to be read in ``binary''
  893. Xmode as opposed to ``text'' mode (MS-DOS only). 
  894. X
  895. X\Xi{\kwd{close(}<filehandle>\kwd{)}*}
  896. XCloses the file or pipe associated with the file handle.
  897. X
  898. X\Xi{\kwd{dbmclose(}|\%|<array>\kwd{)}*}
  899. XBreaks the binding between the array and the dbm file.
  900. X
  901. X\Xi{\kwd{dbmopen(}|\%|<array>\kwd{,}<dbmname>\kwd{, }<mode>\kwd{)}}
  902. XBinds a dbm or ndbm file to the associative array. If the database
  903. Xdoes not exist, it is created with the indicated mode. 
  904. X
  905. X\Xi{\kwd{eof(}<filehandle>\kwd{)}}
  906. XReturns 1 if the next read will return end of file, or if the file is
  907. Xnot open. 
  908. X
  909. X\Xi{\kwd{eof}}
  910. XReturns the eof status for the last file read.
  911. X
  912. X\Xi{\kwd{eof( )}}
  913. XIndicates eof on the pseudo file formed of the files listed on the
  914. Xcommand line. 
  915. X
  916. X\Xi{\kwd{fcntl(}<filehandle>\kwd{,}<function>\kwd{,}|\$|<var>\kwd{)}}
  917. XImplements the {\it fcntl\/}(2) function. This function has non-standard
  918. Xreturn values. See the manual for details. 
  919. X
  920. X\Xi{\kwd{fileno(}<filehandle>\kwd{)}*}
  921. XReturns the file descriptor for a given (open) file.
  922. X
  923. X\Xi{\kwd{flock(}<filehandle>\kwd{,}<operation>\kwd{)}}
  924. XCalls {\it flock\/}(2) on the file. <operation> adds from 1 (shared), 2
  925. X(exclusive), 4 (non-blocking) or 8 (unlock). 
  926. X
  927. X
  928. X\Xi{\kwd{getc}[\kwd{(}<filehandle>\kwd{)}*]}
  929. XYields the next character from the file, or |""| on EOF. If
  930. X<filehandle> is omitted, reads from |STDIN|. 
  931. X
  932. X\Xi{\kwd{ioctl(}<filehandle>\kwd{,}<function>\kwd{,}|\$|<var>\kwd{)}}
  933. Xperforms {\it ioctl}(2) on the file. This function has non-standard
  934. Xreturn values. See the manual for details. 
  935. X
  936. X\Xi{\kwd{open(}<filehandle>[\kwd{,}<filename>]\kwd{)}}
  937. XOpens a file and associates it with <filehandle>. If <filename> is
  938. Xomitted, the scalar variable of the same name as the <filehandle> must
  939. Xcontain the filename.
  940. X
  941. XThe following filename conventions apply when opening a file.
  942. X
  943. X\begin{enum}{2cm}
  944. X\Xi{|"|<file>|"|} open <file> for input. Also |"<|<file>|"|.
  945. X
  946. X\Xi{|">|<file>|"|} open <file> for output, creating it if necessary.
  947. X
  948. X\Xi{|">>|<file>|"|} open <file> in append mode.
  949. X
  950. X\Xi{|"+>|<file>|"|} open <file> with read/write access.
  951. X
  952. X\Xi{|"\||<cmd>|"|} opens a pipe to command <cmd>.
  953. X
  954. X\Xi{|"|<cmd>|\|"|} opens a pipe from command <cmd>.
  955. X\end{enum}
  956. X
  957. X<file> may be |&|<filehnd> in which case the new file handle is
  958. Xconnected to the (previously opened) filehandle <filehnd>.
  959. X
  960. X\kwd{open} 
  961. Xreturns 1 upon success, \kwd{undef} otherwise, except for pipes. The
  962. Xparentheses may be omitted, if only a <filehandle> is specified.
  963. X
  964. X\Xi{\kwd{pipe(}<readhandle>\kwd{,}<writehandle>\kwd{)}}
  965. XReturns a pair of connected pipes.
  966. X
  967. X\Xi{\kwd{print}[\kwd{(}[<filehandle>]<list>\dag\kwd{)}*]}
  968. XPrints a string or a comma-separated list of strings. If <filehandle>
  969. Xis omitted, prints by default to standard output (or to the last
  970. Xselected output channel - see \kwd{select}).  
  971. X
  972. X\Xi{\kwd{printf}[\kwd{(}[<filehandle>] <list>\kwd{)}*]}
  973. XEquivalent to \kwd{print} <filehandle> \kwd {sprintf(}<list>\kwd{)}.
  974. X
  975. X\Xi{\kwd{read(}<filehandle>\kwd{,}|\$|<var>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
  976. XRead <length> binary bytes from the file into the variable at
  977. X<offset>. Returns number of bytes actually read. 
  978. X
  979. X\Xi{\kwd{seek(}<filehandle>\kwd{,}<position>\kwd{,}<whence>\kwd{)}}
  980. XArbitrarily positions the file. Returns 1 upon success, 0 otherwise.
  981. X
  982. X\Xi{\kwd{select}[\kwd{(}<filehandle>\kwd{)}]}
  983. XReturns the currently selected filehandle. 
  984. XSets the current default filehandle for output operations if
  985. X<filehandle> is supplied.
  986. X
  987. X\Xi{\kwd{select(}<rbits>\kwd{,}<wbits>\kwd{,}<nbits>\kwd{,}<timeout>\kwd{)}}
  988. XPerforms a {\it select\/}(2) system call with the same parameters.
  989. X
  990. X\Xi{\kwd{sprintf(}<format>\kwd{,}<list>\kwd{)}}
  991. XReturns a string formatted by (almost all of) the usual printf
  992. Xconventions. 
  993. X
  994. X\Xi{\kwd{sysread(}<filehandle>\kwd{,}|\$|<var>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
  995. XReads <length> bytes into |$|<var> at <offset>.
  996. X
  997. X\Xi{\kwd{syswrite(}<filehandle>\kwd{,}<scalar>\kwd{,}<length>[\kwd{,}<offset>]\kwd{)}}
  998. XWrites <length> bytes from <scalar> at <offset>.
  999. X
  1000. X\Xi{\kwd{tell}[\kwd{(}<filehandle>\kwd{)}]*}
  1001. XReturns the current file position for the file. If <filehandle> is
  1002. Xomitted, assumes the file last read. 
  1003. X
  1004. X\Xi{\kwd{write}[\kwd{(}<filehandle>\kwd{)}]*}
  1005. XWrites a formatted record to the specified file, using the format
  1006. Xassociated with that file. See ``Formats''. 
  1007. X
  1008. X\end{enum}
  1009. X
  1010. X\makeuppage
  1011. X
  1012. X\section{Search and replace functions}
  1013. X
  1014. X\begin{enum}{1cm}
  1015. X
  1016. X\catcode`\~=\other
  1017. X
  1018. X\Xi{[<expr> |=~|] [\kwd{m}]|/|<pattern>|/|[\kwd{g}][\kwd{i}][\kwd{o}]}
  1019. XSearches <expr> (default: |$_|) for a pattern. If you prepend an
  1020. X\kwd{m} you can use almost any pair of characters as delimiters. If
  1021. Xused in array context, an array is returned consisting of the
  1022. Xsubexpressions matched by the parentheses in pattern, i.e.
  1023. X|($1,$2,$3,...)|.
  1024. X\\
  1025. XOptional modifiers: \kwd{g} matches as many times as possible; \kwd{i}
  1026. Xsearches in a case-insensitive manner; \kwd{o} interpolates variables
  1027. Xonly once.
  1028. X\\
  1029. XIf <pattern> is empty, the most recent pattern from a
  1030. Xprevious match or replacement is used.
  1031. X\\
  1032. XWith \kwd{g} the match can be used as an iterator in scalar context.
  1033. X
  1034. X\Xi{|?|<pattern>|?|}
  1035. XThis is just like the |/|<pattern>|/| search, except that it matches
  1036. Xonly once between calls to the reset operator. If <pattern> is empty,
  1037. Xthe most recent pattern from a previous match or replacement is used.
  1038. X
  1039. X\Xi{[|\$|<var> |=~|] \kwd{s}|/|<pattern>|/|<replacement>|/|[\kwd{g}][\kwd{i}][\kwd{e}][\kwd{o}]}
  1040. XSearches a string for a pattern, and if found, replaces that pattern
  1041. Xwith the replacement text and returns the number of substitutions
  1042. Xmade. Otherwise it returns false. 
  1043. X\\
  1044. XOptional modifiers: \kwd{g} replaces all occurrences of the pattern;
  1045. X\kwd{e} interprets the replacement string as an expression; \kwd{i}
  1046. Xand \kwd{o} as with |/|<pattern>|/| matching. Almost any delimiter may
  1047. Xreplace the slashes; if single quotes are used, no interpretation is
  1048. Xdone on the replacement string.
  1049. X\\
  1050. XIf bracketing quotes are used, <pattern> and <replacement> 
  1051. Xmay have their own delimiters, e.g. |s(foo)[bar]|.
  1052. X\\
  1053. XIf <pattern> is empty, the most recent pattern from a previous match or replacement is used.
  1054. X
  1055. X\Xi{\kwd{study}[\kwd{(}|\$|<var>\dag\kwd{)}*]}
  1056. XStudy the contents of |$|<var> in anticipation of doing many pattern
  1057. Xmatches on the contents before it is next modified.
  1058. X
  1059. X\Xi{[|\$|<var> |=~|] \kwd{tr}|/|<searchlist>|/|<replacementlist>|/|[\kwd{c}][\kwd{d}][\kwd{s}]}
  1060. XTranslates all occurrences of the characters found in the search list
  1061. Xwith the corresponding character in the replacement list. It returns
  1062. Xthe number of characters replaced. \kwd{y} may be used instead of \kwd{tr}. 
  1063. X\\
  1064. XOptional modifiers: \kwd{c} complements the <searchlist>; \kwd{d}
  1065. Xdeletes all characters not found in <searchlist>; \kwd{s} squeezes all
  1066. Xsequences of characters that are translated into the same target
  1067. Xcharacter into one occurrence of this character.
  1068. X
  1069. X\end{enum}
  1070. X
  1071. X\makeupspace{1cm}
  1072. X
  1073. X\section{System interaction} 
  1074. X
  1075. X\begin{enum}{1cm}
  1076. X
  1077. X\Xi{\kwd{alarm(}<expr>\kwd{)}*}
  1078. XSchedules a |SIGALRM| to be delivered after <expr> seconds. 
  1079. X
  1080. X\Xi{\kwd{chdir} [\kwd{(}<expr>\kwd{)}*]}
  1081. XChanges the working directory, |$ENV{"HOME"}| if <expr> is omitted.
  1082. X
  1083. X\Xi{\kwd{chroot(}<filename>\dag\kwd{)}*}
  1084. XChanges the root directory for the process and its children.
  1085. X
  1086. X\Xi{\kwd{die}[\kwd{(}<list>\kwd{)}*]}
  1087. XPrints the value of <list> to |STDERR| and exits with the current
  1088. Xvalue of |$!| (errno). If |$!| is 0, exits with the value of |($? >> 8)|.
  1089. XIf |($? >> 8)| is 0, exits with 255. <list> defaults to
  1090. X|"Died."|.
  1091. X
  1092. X\Xi{\kwd{exec(}<list>\kwd{)}*}
  1093. XExecutes the system command in <list>; does not return.
  1094. X
  1095. X\Xi{\kwd{exit(}<expr>\kwd{)}*}
  1096. XExits immediately with the value of |EXPR|.
  1097. X
  1098. X\Xi{\kwd{fork}}
  1099. XDoes a {\it fork\/}(2) system call. Returns the child pid to the parent
  1100. Xprocess and zero to the child process. 
  1101. X
  1102. X\Xi{\kwd{getlogin}}
  1103. XReturns the current login name as known by the system.
  1104. X
  1105. X\Xi{\kwd{getpgrp}[\kwd{(}<pid>\kwd{)}*]}
  1106. XReturns the process group for process <pid> (0, or omitted,  means the
  1107. Xcurrent process). 
  1108. X
  1109. X\Xi{\kwd{getppid}}
  1110. XReturns the process id of the parent process.
  1111. X
  1112. X\Xi{\kwd{getpriority(}<which>\kwd{,}<who>\kwd{)}}
  1113. XReturns the current priority for a process, process group, or user.
  1114. X
  1115. X\Xi{\kwd{kill(}<list>\kwd{)}*}
  1116. XSends a signal to a list of processes. The first element of the list
  1117. Xmust be the signal to send (numeric, or its name as a string). 
  1118. X
  1119. X\Xi{\kwd{setpgrp(}<pid>\kwd{,}<pgrp>\kwd{)}}
  1120. XSets the process group for the <pid> (0 = current process).
  1121. X
  1122. X\Xi{\kwd{setpriority(}<which>\kwd{,}<who>\kwd{,}<prio>\kwd{)}}
  1123. XSets the current priority for a process, process group, or a user.
  1124. X
  1125. X\Xi{\kwd{sleep}[\kwd{(}<expr>\kwd{)}*]}
  1126. XCauses the script to sleep for <expr> seconds, or forever if no
  1127. X<expr>. Returns the number of seconds actually slept. 
  1128. X
  1129. X\Xi{\kwd{syscall(}<list>\kwd{)}*}
  1130. XCalls the system call specified in the first element of the list,
  1131. Xpassing the rest of the list as arguments to the call. 
  1132. X
  1133. X\Xi{\kwd{system(}<list>\kwd{)}*}
  1134. XDoes exactly the same thing as \kwd{exec }<list> except that a fork is
  1135. Xdone first, and the parent process waits for the child process to complete. 
  1136. X
  1137. X\Xi{\kwd{times}}
  1138. XReturns a 4-element array (\$user, \$system, \$cuser, \$csystem) giving
  1139. Xthe user and system times, in seconds, for this process and the
  1140. Xchildren of this process.  
  1141. X
  1142. X\Xi{\kwd{umask}[\kwd{(}<expr>\kwd{)}*]}
  1143. XSets the umask for the process and returns the old one. If <expr> is
  1144. Xomitted, returns current umask value. 
  1145. X
  1146. X\Xi{\kwd{wait}}
  1147. XWaits for a child process to terminate and returns the pid of the
  1148. Xdeceased process (-1 if none). The status is returned in |$?|. 
  1149. X
  1150. X\Xi{\kwd{waitpid(}<pid>\kwd{,}<flags>\kwd{)}}
  1151. XPerforms the same function as the corresponding system call.
  1152. X
  1153. X\Xi{\kwd{warn(}<list>\kwd{)}*}
  1154. XPrints the message on |STDERR| like \kwd{die}, but doesn't exit.
  1155. X
  1156. X\end{enum}
  1157. X
  1158. X\makeuppage
  1159. X
  1160. X\section{Networking} 
  1161. X
  1162. X\begin{enum}{1cm}
  1163. X
  1164. X\Xi{\kwd{accept(}<newsocket>\kwd{,}<genericsocket>\kwd{)}}
  1165. XAccepts a new socket.
  1166. X
  1167. X\Xi{\kwd{bind(}<socket>\kwd{,}<name>\kwd{)}}
  1168. XBinds the <name> to the <socket>.
  1169. X
  1170. X\Xi{\kwd{connect(}<socket>\kwd{,}<name>\kwd{)}}
  1171. XConnects the <name> to the <socket>.
  1172. X
  1173. X\Xi{\kwd{getpeername(}<socket>\kwd{)}}
  1174. XReturns the socket address of the other end of the <socket>.
  1175. X
  1176. X\Xi{\kwd{getsockname(}<socket>\kwd{)}}
  1177. XReturns the name of the socket.
  1178. X
  1179. X\Xi{\kwd{getsockopt(}<socket>\kwd{,}<level>\kwd{,}<optname>\kwd{)}}
  1180. XReturns the socket options.
  1181. X
  1182. X\Xi{\kwd{listen(}<socket>\kwd{,}<queuesize>\kwd{)}}
  1183. XStarts listening on the specified <socket>.
  1184. X
  1185. X\Xi{\kwd{recv(}<socket>\kwd{,}<scalar>\kwd{,}<length>\kwd{,}<flags>\kwd{)}}
  1186. XReceives a message on <socket>.
  1187. X
  1188. X\Xi{\kwd{send(}<socket>\kwd{,}<msg>\kwd{,}<FLAGS[>\kwd{,}<to>]\kwd{)}}
  1189. XSends a message on the <socket>.
  1190. X
  1191. X\Xi{\kwd{setsockopt(}<socket>\kwd{,}<level>\kwd{,}<optname>\kwd{,}<optval>\kwd{)}}
  1192. XSets the requested socket option.
  1193. X
  1194. X\Xi{\kwd{shutdown(}<socket>\kwd{,}<how>\kwd{)}}
  1195. XShuts down a <socket>.
  1196. X
  1197. X\Xi{\kwd{socket(}<socket>\kwd{,}<domain>\kwd{,}<type>\kwd{,}<protocol>\kwd{)}}
  1198. XCreates a <socket> in <domain> with <type> and <protocol>.
  1199. X
  1200. X\Xi{\kwd{socketpair(}<socket1>\kwd{,}<socket2>\kwd{,}<domain>\kwd{,}<type>\kwd{,}<protocol>\kwd{)}}
  1201. XAs socket, but creates a pair of bi-directional sockets.
  1202. X
  1203. X\end{enum}
  1204. X
  1205. X\makeupspace{1cm}
  1206. X
  1207. X\section{SystemV IPC} 
  1208. X
  1209. XThe following functions all perform the same action as the
  1210. Xcorresponding system calls.
  1211. X
  1212. X\kwd{msgctl(}<id>\kwd{,}<cmd>\kwd{,}<args>\kwd{)} \\
  1213. X\kwd{msgget(}<key>\kwd{,}<flags>\kwd{)} \\
  1214. X\kwd{msgsnd(}<id>\kwd{,}<msg>\kwd{,}<flags>\kwd{)} \\
  1215. X\kwd{msgrcv(}<id>\kwd{,}\$<var>\kwd{,}<size>\kwd{,}<type>\kwd{,}<flags>\kwd{)} \\
  1216. X\kwd{semctl(}<id>\kwd{,}<semnum>\kwd{,}<cmd>\kwd{,}<arg>\kwd{)} \\
  1217. X\kwd{semget(}<key>\kwd{,}<nsems>\kwd{,}<size>\kwd{,}<flags>\kwd{)} \\
  1218. X\kwd{semop(}<key>\kwd{,}...\kwd{)} \\
  1219. X\kwd{shmctl(}<id>\kwd{,}<cmd>\kwd{,}<arg>\kwd{)} \\
  1220. X\kwd{shmget(}<key>\kwd{,}<size>\kwd{,}<flags>\kwd{)} \\
  1221. X\kwd{shmread(}<id>\kwd{,}\$<var>\kwd{,}<pos>\kwd{,}<size>\kwd{)} \\
  1222. X\kwd{shmwrite(}<id>\kwd{,}<string>\kwd{,}<pos>\kwd{,}<size>\kwd{)}
  1223. X
  1224. X\makeuppage
  1225. X
  1226. X\section{Miscellaneous} 
  1227. X
  1228. X\begin{enum}{1cm}
  1229. X
  1230. X\Xi{\kwd{caller}[\kwd{(}<expr>\kwd{)}]}
  1231. XReturns an array (\$package,\$file,\$line,...) for a specific subroutine
  1232. Xcall. ``|caller|'' returns this info for the current subroutine,
  1233. X``|caller(1)|'' for the caller of this subroutine etc..  
  1234. X
  1235. X\Xi{\kwd{defined(}<expr>\kwd{)}*}
  1236. XTests whether the lvalue <expr> has a real value.
  1237. X
  1238. X\Xi{\kwd{dump} [<label>]}
  1239. XImmediate core dump. When reincarnated, starts at <label>.
  1240. X
  1241. X\Xi{\kwd{local(}<list>\kwd{)}}
  1242. XCreates a scope for the listed variables local to the enclosing block,
  1243. Xsubroutine or eval. 
  1244. X
  1245. X\Xi{\kwd{package} <name>}
  1246. XDesignates the remainder of the current block as a package.
  1247. X
  1248. X\Xi{\kwd{require(}\oEXPR\kwd{)}*}
  1249. XIncludes the specified file from the perl library. Does not include
  1250. Xmore than once, and yields a fatal error if the file does not include OK. 
  1251. X
  1252. X\Xi{\kwd{reset} [\kwd{(}<expr>\kwd{)}*]}
  1253. XResets |??| searches so that they work again. <expr> is a list of
  1254. Xsingle letters. All variables and arrays beginning with one of those
  1255. Xletters are reset to their pristine state.  Only affects the current
  1256. Xpackage.
  1257. X
  1258. X\Xi{\kwd{scalar(}<expr>\kwd{)}}
  1259. XForces evaluation of <expr> in scalar context.
  1260. X
  1261. X\Xi{\kwd{sub} <name> \{ <expr> |;| ... \}}
  1262. XDesignates <name> as a subroutine. Parameters are passed by reference
  1263. Xas array |@_|. Returns the value of the last expression evaluated. 
  1264. X
  1265. X\Xi{\kwd{undef}[\kwd{(}<lvalue>\kwd{)}*]}
  1266. XUndefines the <lvalue>. Always returns the undefined value.
  1267. X
  1268. X\Xi{\kwd{wantarray}}
  1269. XReturns true if the current context expects an array value.
  1270. X
  1271. X\end{enum}
  1272. X
  1273. X
  1274. X\section{Formats} 
  1275. X
  1276. X\kwd{format} [<name>] |=| \\
  1277. X<formlist> \\
  1278. X|.|
  1279. X
  1280. X<formlist> pictures the lines, and contains the arguments which will
  1281. Xgive values to the fields in the lines. Picture fields are:
  1282. X
  1283. X|  @<<<...  | left adjusted field, repeat the |<| to denote the desired
  1284. Xwidth; \\
  1285. X|  @>>>...  | right adjusted field; \\
  1286. X|  @|\|\|\||...  | centered field; \\
  1287. X|  @#.##... | numeric format with implied decimal point; \\
  1288. X|  @*       | a multi-line field.
  1289. X
  1290. XUse \^ instead of |@| for multi-line block filling.
  1291. X
  1292. XUse |~| at the beginning of a line to suppress unwanted empty lines.
  1293. X
  1294. XUse |~~| at the beginning of a line to have this format line repeated
  1295. Xuntil all fields are exhausted. 
  1296. X
  1297. XUse |$-| to zero to force a page break.
  1298. X
  1299. XSee also |$|\^, |$~|, |$-| and |$=| in section ``Special Variables''.
  1300. X
  1301. X
  1302. X\section{Info from system files} 
  1303. XSee the manual about return values in scalar context.
  1304. X
  1305. X{\large\sl passwd} \\
  1306. XReturns (\$name, \$passwd, \$uid, \$gid, \$quota, \$comment, \$gcos, \$dir, \$shell).
  1307. X
  1308. X\begin{enum}{6cm}
  1309. X
  1310. X\Xi{\kwd{endpwent}}    Ends lookup processing.
  1311. X
  1312. X\Xi{\kwd{getpwent}}    Gets next info.
  1313. X
  1314. X\Xi{\kwd{getpwnam(}<name>\kwd{)}}    Gets info by name. 
  1315. X
  1316. X\Xi{\kwd{getpwuid(}<uid>\kwd{)}}    Gets info by uid.
  1317. X
  1318. X\Xi{\kwd{setpwent}}    Resets lookup processing.
  1319. X
  1320. X\end{enum}
  1321. X
  1322. X{\vskip6pt\large\sl group} \\
  1323. XReturns (\$name, \$passwd, \$gid, \$members).
  1324. X
  1325. X\begin{enum}{6cm}
  1326. X
  1327. X\Xi{\kwd{endgrent}}    Ends lookup processing.
  1328. X
  1329. X\Xi{\kwd{getgrgid(}<gid>\kwd{)}}    Gets info by group id. 
  1330. X
  1331. X\Xi{\kwd{getgrnam(}<name>\kwd{)}}    Gets info by name.
  1332. X
  1333. X\Xi{\kwd{getgrent}}    Gets next info.
  1334. X
  1335. X\Xi{\kwd{setgrent}}    Resets lookup processing.
  1336. X
  1337. X\end{enum}
  1338. X
  1339. X{\vskip6pt\large\sl hosts} \\
  1340. XReturns (\$name, \$aliases, \$addrtype, \$length, @addrs).
  1341. X
  1342. X\begin{enum}{6cm}
  1343. X
  1344. X\Xi{\kwd{endhostent}}    Ends lookup processing.
  1345. X
  1346. X\Xi{\kwd{gethostbyaddr(}<addr>\kwd{,}<addrtype>\kwd{)}}    Gets info by address.
  1347. X
  1348. X\Xi{\kwd{gethostbyname(}<name>\kwd{)}}    Gets info by name.
  1349. X
  1350. X\Xi{\kwd{gethostent}}    Gets next info.
  1351. X
  1352. X\Xi{\kwd{sethostent(}<stayopen>\kwd{)}}    Resets lookup processing.
  1353. X
  1354. X\end{enum}
  1355. X
  1356. X{\vskip6pt\large\sl networks} \\
  1357. XReturns (\$name, \$aliases, \$addrtype, \$net).
  1358. X
  1359. X\begin{enum}{6cm}
  1360. X
  1361. X\Xi{\kwd{endnetent}}    Ends lookup processing.
  1362. X
  1363. X\Xi{\kwd{getnetbyaddr(}<addr>\kwd{,}<type>\kwd{)}}    Gets info by address and type.
  1364. X
  1365. X\Xi{\kwd{getnetbyname(}<name>\kwd{)}}    Gets info by name.
  1366. X
  1367. X\Xi{\kwd{getnetent}}    Gets next info.
  1368. X
  1369. X\Xi{\kwd{setnetent(}<stayopen>\kwd{)}}    Resets lookup processing.
  1370. X
  1371. X\end{enum}
  1372. X
  1373. X{\vskip6pt\large\sl services} \\
  1374. XReturns (\$name, \$aliases, \$port, \$proto).
  1375. X
  1376. X\begin{enum}{6cm}
  1377. X
  1378. X\Xi{\kwd{endservent}}    Ends lookup processing.
  1379. X
  1380. X\Xi{\kwd{getservbyname(}<name>\kwd{, }<proto>\kwd{)}}    Gets info by name. 
  1381. X
  1382. X\Xi{\kwd{getservbyport(}<port>\kwd{, }<proto>\kwd{)}}    Gets info by port.
  1383. X
  1384. X\Xi{\kwd{getservent}}    Gets next info.
  1385. X
  1386. X\Xi{\kwd{setservent(}<stayopen>\kwd{)}}    Resets lookup processing.
  1387. X
  1388. X\end{enum}
  1389. X
  1390. X{\vskip6pt\large\sl protocols} \\
  1391. X
  1392. XReturns (\$name, \$aliases, \$proto).
  1393. X
  1394. X\begin{enum}{6cm}
  1395. X
  1396. X\Xi{\kwd{endprotoent}}    Ends lookup processing.
  1397. X
  1398. X\Xi{\kwd{getprotobyname(}<name>\kwd{)}}    Gets info by name.
  1399. X
  1400. X\Xi{\kwd{getprotobynumber(}<number>\kwd{)}}    Gets info by number.
  1401. X
  1402. X\Xi{\kwd{getprotoent}}    Gets next info.
  1403. X
  1404. X\Xi{\kwd{setprotoent(}<stayopen>\kwd{)}}    Resets lookup processing.
  1405. X
  1406. X\end{enum}
  1407. X
  1408. X
  1409. X\section{Regular expressions} 
  1410. X
  1411. XEach character matches itself, unless it is one of the special
  1412. Xcharacters |+?.*()[]{}|\||\|.
  1413. X
  1414. X\begin{enum}{1cm}
  1415. X
  1416. X\Xj{|.|}
  1417. Xmatches an arbitrary character, but not a newline.
  1418. X
  1419. X\Xj{|(|\ldots|)|}
  1420. Xgroups a series of pattern elements to a single element.
  1421. X
  1422. X\Xj{|+|}
  1423. Xmatches the preceding pattern element one or more times.
  1424. X
  1425. X\Xj{|?|}
  1426. Xmatches zero or one times.
  1427. X
  1428. X\Xj{|*|}
  1429. Xmatches zero or more times.
  1430. X
  1431. X\Xj{\{<n>|,|<m>\}}
  1432. Xdenotes the minimum <n> and maximum <m> match count. |{|<n>|}| means
  1433. Xexactly <n> times; |{|<n>|,}| means at least <n> times. 
  1434. X
  1435. X\Xj{|\char`\[|\ldots|\char`\]|}
  1436. Xdenotes a class of characters to match. |[|\^\ldots|]| negates the class.
  1437. X
  1438. X\Xj{|(|\ldots\|\ldots\|\ldots|)|}
  1439. Xmatches one of the alternatives.
  1440. X
  1441. X\end{enum}
  1442. X
  1443. XNon-alphanumerics can be escaped from their special meaning using a
  1444. X|\|.
  1445. X
  1446. X\begin{enum}{1cm}
  1447. X
  1448. X\Xj{|\char`\\w|}
  1449. Xmatches alphanumeric, including ``|_|'', |\W| matches non-alphanumeric.
  1450. X
  1451. X\Xj{|\char`\\b|}
  1452. Xmatches word boundaries, |\B| matches non-boundaries.
  1453. X
  1454. X\Xj{|\char`\\s|}
  1455. Xmatches whitespace, |\S| matches non-whitespace.
  1456. X
  1457. X\Xj{|\char`\\d|}
  1458. Xmatches numeric, |\D| matches non-numeric.
  1459. X
  1460. X\Xj{|\char`\\n|, |\char`\\r|, |\char`\\f|, |\char`\\t| etc.} 
  1461. Xhave their usual meaning.
  1462. X
  1463. X\Xj{|\char`\\w|, |\char`\\s| and |\char`\\d|}
  1464. X may be used within character classes, |\b| denotes backspace in this context.
  1465. X
  1466. X\Xj{|\char`\\1|\ldots|\char`\\9|}
  1467. Xrefer to matched sub-expressions, grouped with |()|, inside
  1468. Xthe match. 
  1469. X
  1470. X\Xj{|\char`\\10|}
  1471. Xand up can also be used if the pattern
  1472. Xmatches that many sub-expressions. 
  1473. X
  1474. X\end{enum}
  1475. X
  1476. XSee also |$1|\ldots|$9|, |$+|, |$&|, |$`| and |$'| in section ``Special
  1477. XVariables''.
  1478. X
  1479. X
  1480. X
  1481. X\section{Special variables} 
  1482. X
  1483. XThe following variables are global and should be localized in subroutines:
  1484. X
  1485. X\begin{enum}{1cm}
  1486. X
  1487. X\Xi{|\char`\$\char`\_|}
  1488. XThe default input and pattern-searching space.
  1489. X
  1490. X\Xi{|\char`\$\char`\.|}
  1491. XThe current input line number of the last filehandle that was read.
  1492. X
  1493. X\Xi{|\char`\$\char`\/|}
  1494. XThe input record separator, newline by default. May be multi-character.
  1495. X
  1496. X\Xi{|\char`\$\char`\,|}
  1497. XThe output field separator for the print operator.
  1498. X
  1499. X\Xi{|\char`\$\char`\"|}
  1500. XThe separator which joins elements of arrays interpolated in strings.
  1501. X
  1502. X\Xi{|\char`\$\char`\\|}
  1503. XThe output record separator for the print operator.
  1504. X
  1505. X\Xi{|\char`\$\char`\#|}
  1506. XThe output format for printed numbers. Initial value is ``|%.20g|''.
  1507. X
  1508. X\Xi{|\char`\$\char`\*|}
  1509. XSet to 1 to do multiline matching within a string, 0 to assume strings
  1510. Xcontain a single line. Default is 0. 
  1511. X
  1512. X\Xi{|\char`\$\char`\?|}
  1513. XThe status returned by the last |`|<command>|`|, pipe close or
  1514. X\kwd{system} operator. 
  1515. X
  1516. X\Xi{|\char`\$\char`\]|}
  1517. XThe perl version string (as displayed with |perl -v|), or version number.
  1518. X
  1519. X\Xi{|\char`\$\char`\[|}
  1520. XThe index of the first element in an array, and of the first character
  1521. Xin a substring. Default is 0. 
  1522. X
  1523. X\Xi{|\char`\$\char`\;|}
  1524. XThe subscript separator for multi-dimensional array emulation. Default
  1525. Xis |"\034"|. 
  1526. X
  1527. X\Xi{|\char`\$\char`\!|}
  1528. XIf used in a numeric context, yields the current value of errno. If
  1529. Xused in a string context, yields the corresponding error string. 
  1530. X
  1531. X\Xi{|\char`\$\char`\@|}
  1532. XThe perl error message from the last eval or \kwd{do} <expr> command.
  1533. X
  1534. X\Xi{|\char`\$\char`\:|}
  1535. XThe set of characters after which a string may be broken to fill
  1536. Xcontinuation fields (starting with ``|^|'') in a format. 
  1537. X
  1538. X\Xi{|\char`\$\char`\0|}
  1539. XThe name of the file containing the perl script being executed. May be
  1540. Xassigned to. 
  1541. X
  1542. X\Xi{|\char`\$\char`\$|}
  1543. XThe process number of the perl running this script. Altered (in the
  1544. Xchild process) by \kwd{fork}. 
  1545. X
  1546. X\Xi{|\char`\$\char`\<|}
  1547. XThe real uid of this process.
  1548. X
  1549. X\Xi{|\char`\$\char`\>|}
  1550. XThe effective uid of this process. 
  1551. X
  1552. X\Xi{|\char`\$\char`\(|}
  1553. XThe real gid of this process.
  1554. X
  1555. X\Xi{|\char`\$\char`\)|}
  1556. XThe effective gid of this process.
  1557. X
  1558. X\Xi{|\char`\$\char`\^D|}
  1559. XThe debug flags as passed to perl using |-D| .
  1560. X
  1561. X\Xi{|\char`\$\char`\^F|}
  1562. XThe highest system file descriptor, ordinarily 2.
  1563. X
  1564. X\Xi{|\char`\${\char`\^}I|}
  1565. XIn-place edit extension as passed to perl using |-i| .
  1566. X
  1567. X\Xi{|\char`\$\char`\^L|}
  1568. XFormfeed character used in formats.
  1569. X
  1570. X\Xi{|\char`\$\char`\^P|}
  1571. XInternal debugging flag.
  1572. X
  1573. X\Xi{|\char`\$\char`\^T|}
  1574. XThe time (as delivered by \kwd{time}) when the program started. This
  1575. Xvalue is used by the file test operators ``|-M|'', ``|-A|'' and
  1576. X``|-C|''.
  1577. X
  1578. X\Xi{|\char`\$\char`\^W|}
  1579. XThe value if the |-w| option as passed to perl.
  1580. X
  1581. X\Xi{|\char`\$\char`\^X|}
  1582. XThe name by which this perl was invoked.
  1583. X
  1584. X\end{enum}
  1585. X
  1586. XThe following variables are context dependent and need not be
  1587. Xlocalized:
  1588. X
  1589. X\begin{enum}{1cm}
  1590. X
  1591. X\Xi{|\char`\$\char`\%|}
  1592. XThe current page number of the currently selected output channel.
  1593. X
  1594. X\Xi{|\char`\$\char`\=|}
  1595. XThe page length of the current output channel. Default is 60 lines.
  1596. X
  1597. X\Xi{|\char`\$\char`\-|}
  1598. XThe number of lines left on the page.
  1599. X
  1600. X\Xi{|\char`\$\char`\~|}
  1601. XThe name of the current report format.
  1602. X
  1603. X\Xi{|\char`\$\char`\^|}
  1604. XThe name of the current top-of-page format.
  1605. X
  1606. X\Xi{|\char`\$\char`\||}
  1607. XIf set to nonzero, forces a flush after every write or print on the
  1608. Xcurrently selected output channel. Default is 0. 
  1609. X
  1610. X\Xj{|\char`\$ARGV|}
  1611. XThe name of the current file when reading from |<>| .
  1612. X\end{enum}
  1613. X
  1614. XThe following variables are always local to the current block:
  1615. X
  1616. X\begin{enum}{1cm}
  1617. X
  1618. X\Xi{|\char`\$\char`\&|}
  1619. XThe string matched by the last successful pattern match.
  1620. X
  1621. X\Xi{|\char`\$\char`\`|}
  1622. XThe string preceding what was matched by the last successful match.
  1623. X
  1624. X\Xi{|\char`\$\char`\'|}
  1625. XThe string following what was matched by the last successful match. 
  1626. X
  1627. X\Xi{|\char`\$\char`\+|}
  1628. XThe last bracket matched by the last search pattern.
  1629. X
  1630. X\Xi{\$|1|\ldots\$|9|\ldots}
  1631. XContains the subpattern from the corresponding set of parentheses in
  1632. Xthe last pattern successfully matched.
  1633. X|$10|\ldots and up are only available if the
  1634. Xmatch contained that many sub-expressions. 
  1635. X
  1636. X\end{enum}
  1637. X
  1638. X
  1639. X
  1640. X
  1641. X\section{Special arrays} 
  1642. X
  1643. X\begin{enum}{1.5cm}
  1644. X
  1645. X\Xi{|@ARGV|}
  1646. XContains the command line arguments for the script (not including the command name).
  1647. X
  1648. X\Xi{|@INC|}
  1649. XContains the list of places to look for perl scripts to be evaluated
  1650. Xby the \kwd{do} <filename> and \kwd{require} commands. 
  1651. X
  1652. X\Xi{|@\char`\_|}
  1653. XParameter array for subroutines. Also used by \kwd{split} if not in
  1654. Xarray context. 
  1655. X
  1656. X\Xi{|\char`\%ENV|}
  1657. XContains the current environment.
  1658. X
  1659. X\Xi{|\char`\%INC|}
  1660. XList of files that have been \kwd{require}d or \kwd{do}ne.
  1661. X
  1662. X\Xi{|\char`\%SIG|}Used to set signal handlers for various signals.
  1663. X
  1664. X\end{enum}
  1665. X
  1666. X
  1667. X\section{The perl debugger} 
  1668. X
  1669. XThe perl symbolic debugger is invoked with |perl -d|.
  1670. X
  1671. X\begin{enum}{2.5cm}
  1672. X
  1673. X\Xi{|h|}
  1674. XPrints out a help message.
  1675. X
  1676. X\Xi{|T|}
  1677. XStack trace.
  1678. X
  1679. X\Xi{|s|}
  1680. XSingle steps.
  1681. X
  1682. X\Xi{|n|}
  1683. XSingle steps around subroutine call.
  1684. X
  1685. X\Xi{|r|}
  1686. XReturns from the current subroutine.
  1687. X
  1688. X\Xi{|c| [<line>]}
  1689. XContinues (until <line>, or another breakpoint or exit).
  1690. X
  1691. X\Xi{\fbox{<ret>}}
  1692. XRepeats last |s| or |n|.
  1693. X
  1694. X\Xi{|l| [<range>]}
  1695. XLists a range of lines. <range> may be a number, start-end,
  1696. Xstart+amount, or a subroutine name. If omitted, lists next window. 
  1697. X
  1698. X\Xi{|f| <file>}
  1699. XSwitches to <file> and start listing it.
  1700. X
  1701. X\Xi{|-|}
  1702. XLists previous window.
  1703. X
  1704. X\Xi{|w|}
  1705. XLists window around current line.
  1706. X
  1707. X\Xi{|l| <sub>}
  1708. XLists the named <sub>routine.
  1709. X
  1710. X\Xi{|/|<pattern>|/|}
  1711. XForward search for <pattern>.
  1712. X
  1713. X\Xi{|?|<pattern>|?|}
  1714. XBackward search for <pattern>.
  1715. X
  1716. X\Xi{|L|}
  1717. XLists lines that have breakpoints or actions.
  1718. X
  1719. X\Xi{|S|}
  1720. XList the names of all subroutines.
  1721. X
  1722. X\Xi{|t|}
  1723. XToggles trace mode.
  1724. X
  1725. X\Xi{|b| [<line> [<condition>]]}
  1726. XSets breakpoint at <line>, default: current line.
  1727. X
  1728. X\Xi{|b| <subname> [<condition>]}
  1729. XSets breakpoint at the subroutine.
  1730. X
  1731. X\Xi{|S|}
  1732. XLists names of all subroutines.
  1733. X
  1734. X\Xi{|d| [<line>]}
  1735. XDeletes breakpoint at the given line.
  1736. X
  1737. X\Xi{|D|}
  1738. XDeletes all breakpoints.
  1739. X
  1740. X\Xi{|a| <line command>}
  1741. XSets an action for line.
  1742. X
  1743. X\Xi{|A|}
  1744. XDeletes all line actions.
  1745. X
  1746. X\Xi{|\char`\<| <command>}
  1747. XSets an action to be executed before every debugger prompt.
  1748. X
  1749. X\Xi{|\char`\>| <command>}
  1750. XSets an action to be executed before every |s|, |c| or |n| command.
  1751. X
  1752. X\Xi{|V| [<package> [<vars>] ]}
  1753. XLists all variables in a package. Default package is main.
  1754. X
  1755. X\Xi{|X| [<vars>]}
  1756. XLike |V|, but assumes current package.
  1757. X
  1758. X\Xi{|!| [ [-]<number>]}
  1759. XRedo a debugging command. Default is previous command.
  1760. X
  1761. X\Xi{|H| [-<number>]}
  1762. XDisplays the last -<number> commands of more than one letter.
  1763. X
  1764. X\Xi{|q|}
  1765. XQuits. You may also use your \fbox{<eof>} character.
  1766. X
  1767. X\Xi{<command>}
  1768. XExecutes <command> as a perl statement.
  1769. X
  1770. X\Xi{|p| \oEXPR}
  1771. XPrints <expr>.
  1772. X
  1773. X\Xi{|=|< >[<alias value>]}
  1774. XSets alias, or lists current aliases.
  1775. X
  1776. X\end{enum}
  1777. X
  1778. X\makeuppage
  1779. X
  1780. X\section{Environment variables} 
  1781. X
  1782. XPerl uses the following environment variables.
  1783. X
  1784. X\begin{enum}{1.5cm}
  1785. X
  1786. X\Xi{|HOME|}
  1787. XUsed if \kwd{chdir} has no argument.
  1788. X
  1789. X\Xi{|LOGDIR|}
  1790. XUsed if \kwd{chdir} has no argument and |HOME| is not set.
  1791. X
  1792. X\Xi{|PATH|}
  1793. XUsed in executing subprocesses, and in finding the perl script if |-S|
  1794. Xis used.
  1795. X
  1796. X\Xi{|PERLLIB|}
  1797. XA colon-separated list of directories to look for perl library files
  1798. Xbefore looking in the standard library and the current directory.
  1799. X
  1800. X\Xi{|PERLDB|}
  1801. XThe command to get the debugger code. Defaults to 
  1802. X\hbox{|require 'perldb.pl'|}. 
  1803. X
  1804. X\end{enum}
  1805. X
  1806. X\makeupspace{1cm}
  1807. X
  1808. X\unnumbered{Notes}
  1809. X\vfill
  1810. X\makebox[\textwidth]{Perl Reference Guide Revision \refrev \hfill
  1811. X\copyright 1989,1992 Johan Vromans}
  1812. X
  1813. X
  1814. X\end{document}
  1815. END_OF_FILE
  1816.   if test 48498 -ne `wc -c <'refbase.tex'`; then
  1817.     echo shar: \"'refbase.tex'\" unpacked with wrong size!
  1818.   fi
  1819.   # end of 'refbase.tex'
  1820. fi
  1821. echo shar: End of archive 2 \(of 4\).
  1822. cp /dev/null ark2isdone
  1823. MISSING=""
  1824. for I in 1 2 3 4 ; do
  1825.     if test ! -f ark${I}isdone ; then
  1826.     MISSING="${MISSING} ${I}"
  1827.     fi
  1828. done
  1829. if test "${MISSING}" = "" ; then
  1830.     echo You have unpacked all 4 archives.
  1831.     rm -f ark[1-9]isdone
  1832. else
  1833.     echo You still must unpack the following archives:
  1834.     echo "        " ${MISSING}
  1835. fi
  1836. exit 0
  1837. exit 0 # Just in case...
  1838.