home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1453 (.txt) < prev    next >
LaTeX Document  |  1990-12-28  |  18KB

  1. From: jv@mh.nl (Johan Vromans)
  2. Newsgroups: comp.lang.perl,alt.sources
  3. Subject: TeX version of the Perl Reference Guide - part 2 of 2
  4. Message-ID: <JV.90Jun13104035@squirrel.mh.nl>
  5. Date: 13 Jun 90 16:40:35 GMT
  6. X-Checksum-Snefru: c6f43ab6 93f2ec62 57dadb6f 90ef96b6
  7. NOTE:    This TeX document has been created by Raymond Chen
  8.     <raymond@math.berkeley.edu>. You should contact him for details
  9.     and remarks. I'm only passing it through.
  10. Submitted-by: Raymond Chen <raymond@math.berkeley.edu>
  11. Archive-name: perlref.tex/part02
  12. ---- Cut Here and unpack ----
  13. #!/bin/sh
  14. # this is xxx.02 (part 2 of perlref.tex)
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file perlref.tex continued
  17. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  18.  then TOUCH=touch
  19.  else TOUCH=true
  20. if test ! -r shar3_seq_.tmp; then
  21.     echo "Please unpack part 1 first!"
  22.     exit 1
  23. (read Scheck
  24.  if test "$Scheck" != 2; then
  25.     echo "Please unpack part $Scheck next!"
  26.     exit 1
  27.  else
  28.     exit 0
  29. ) < shar3_seq_.tmp || exit 1
  30. echo "x - Continuing file perlref.tex"
  31. sed 's/^X//' << 'SHAR_EOF' >> perlref.tex &&
  32. Xto the last selected output channel---see select(\dots)).
  33. Xprintf[([<FILEHANDLE>] <LIST>)*]
  34. XEquivalent to ``print <FILEHANDLE> sprintf(<LIST>)''.
  35. Xread(<FILEHANDLE>,|$|<VAR>,<LENGTH>)
  36. XRead <LENGTH> binary bytes from the file into the variable.
  37. XReturns number of bytes actually read.
  38. Xseek(<FILEHANDLE>,<POSITION>,<WHENCE>)
  39. XRandomly positions the file. Returns 1 upon success, 0 otherwise.
  40. Xselect(<FILEHANDLE>)*
  41. XSets the current default filehandle for output operations. Returns
  42. Xthe previously selected filehandle.
  43. Xsprintf(<FORMAT>,<LIST>)
  44. XReturns a string formatted by (almost all of) the usual printf
  45. Xconventions.
  46. Xtell[(<FILEHANDLE>)]*
  47. XReturns the current file position for the file. If <FILEHANDLE> is
  48. Xomitted, assumes the file last read.
  49. Xwrite[(<FILEHANDLE>)]*
  50. XWrites a formatted record to the specified file, using the format
  51. Xassociated with that file. See Formats.
  52. X\endtable
  53. X\beginsection 16. Search and replace functions
  54. X\table 1.2in
  55. X[<EXPR> |=~|] [m]/<PATTERN>/[i][o]
  56. XSearches a string for a pattern. If no string is specified via the |=~|
  57. Xor |!~| operator, the |$_| string is searched. If you prepend an ``m'' you
  58. Xcan use any pair of characters as delimiters. If the final delimiter is
  59. Xfollowed by the optional letter ``i'', the matching is done in a
  60. Xcase-insensitive manner. If you append ``o'', variables are interpolated
  61. Xonly once. If used in a context that requires an array value, a
  62. Xpattern match returns an array consisting of the subexpressions
  63. Xmatched by the parentheses in pattern, i.e. |($1, $2, $3|\dots|)|.
  64. X?<PATTERN>?
  65. XThis is just like the /pattern/ search, except that it matches only
  66. Xonce between calls to the reset operator.
  67. X[|$|<VAR> |=~|] s/<PATTERN>/REPLACEMENT/[g][i][e][o]
  68. XSearches a string for a pattern, and if found, replaces that pattern
  69. Xwith the replacement text and returns the number of substitutions
  70. Xmade. Otherwise it returns false (0). Optional modifiers: ``g''
  71. Xindicates that all occurrences of the pattern are to be replaced; ``e''
  72. Xindicates that the replacement string is to be interpreted as an
  73. Xexpression, ``i'' and ``o'' as with /<PATTERN>/ matching. Any
  74. Xdelimiter may replace the slashes; if single quotes are used, no
  75. Xinterpretation is done on the replacement string.
  76. Xstudy[(|$|<VAR>\*)*]
  77. XStudy the contents of |$|<VAR> in anticipation of doing many pattern
  78. Xmatches on the contents before it is next modified.
  79. X[|$|<VAR> |=~|] tr/<SEARCHLIST>/<REPLACEMENTLIST>/
  80. XTranslates all occurrences of the characters found in the search list
  81. Xwith the corresponding character in the replacement list. It returns
  82. Xthe number of characters replaced. ``y'' may be used instead of ``tr''.
  83. X\endtable
  84. X\beginsection 17. System interaction
  85. X\table1.2in
  86. Xchdir [(<EXPR>)*]
  87. XChanges the working directory, |$HOME| if <EXPR> is omitted.
  88. Xchroot(<FILENAME>\*)*
  89. XChanges the root for the following commands.
  90. Xdie(<LIST>)*
  91. XPrints the value of <LIST> to |STDERR| and exits with the current
  92. Xvalue of |$!| (errno). If |$!| is 0, exits with the value of |($? >> 8)|
  93. X(|`command`| status). If |($? >> 8)| is 0, exits with 255.
  94. Xexec(<LIST>)*
  95. XExecutes the system command in <LIST>.
  96. Xexit(<EXPR>)*
  97. XExits immediately with the value of <EXPR>.
  98. Xfork
  99. XDoes a fork() call. Returns the child pid to the parent process and
  100. Xzero to the child process.
  101. Xgetlogin
  102. XReturns the current login name from |/etc/utmp|.
  103. Xgetpgrp[(<PID>)*]
  104. XReturns the process group for process <PID> (0, or omitted, means
  105. Xthe current process).
  106. Xgetppid
  107. XReturns the process id of the parent process.
  108. Xgetpriority(<WHICH>,<WHO>)
  109. XReturns the current priority for a process, process group, or user.
  110. Xkill(<LIST>)*
  111. XSends a signal to a list of processes. The first element of the list
  112. Xmust be the signal to send (numeric, or its name as a string).
  113. Xsetpgrp(<PID>,<PGRP>)
  114. XSets the process group for the <PID> (0 = current process).
  115. Xsetpriority(<WHICH>,<WHO>,<PRIO>)
  116. XSets the current priority for a process, process group or a user.
  117. Xsleep[(<EXPR>)*]
  118. XCauses the script to sleep for <EXPR> seconds, or forever if no
  119. X<EXPR>. Returns the number of seconds actually slept.
  120. Xsyscall(<LIST>)*
  121. XCalls the system call specified in the first element of the list,
  122. Xpassing the rest of the list as arguments to the call.
  123. Xsystem(<LIST>)*
  124. XDoes exactly the same thing as ``exec <LIST>'' except that a fork is
  125. Xdone first, and the parent process waits for the child process to
  126. Xcomplete.
  127. Xtimes
  128. XReturns a 4-element array |($user, $system, $cuser, $csystem)|
  129. Xgiving the user and system times, in seconds, for this process and
  130. Xthe children of this process.
  131. Xumask[(<EXPR>)*]
  132. XSets the umask for the process and returns the old one. If <EXPR> is
  133. Xomitted, returns current umask value.
  134. Xwait
  135. XWaits for a child process to terminate and returns the pid of the
  136. Xdeceased process ($-1$ if none). The status is returned in |$?|.
  137. Xwarn(<LIST>)*
  138. XPrints the message on |STDERR| like die(\dots), but doesn't exit.
  139. X\endtable
  140. X\beginsection 18. Networking
  141. X\table1.2in
  142. Xaccept(<NEWSOCKET>,<GENERICSOCKET>)
  143. XAccepts a new socket.
  144. Xbind(<SOCKET>,<NAME>)
  145. XBinds the <NAME> to the <SOCKET>.
  146. Xconnect(<SOCKET>, <NAME>)
  147. XConnects the <NAME> to the <SOCKET>.
  148. Xgetpeername(<SOCKET>)
  149. XReturns the socket address of the other end of the <SOCKET>.
  150. Xgetsockname(<SOCKET>)
  151. XReturns the name of the socket.
  152. Xgetsockopt(<SOCKET>,<LEVEL>,<OPTNAME>)
  153. XReturns the socket options.
  154. Xlisten(<SOCKET>,<QUEUESIZE>)
  155. XStarts listening on the specified <SOCKET>.
  156. Xrecv(<SOCKET>,<SCALAR>,<LENGTH>,<FLAGS>)
  157. XReceives a message on <SOCKET>.
  158. Xsend(<SOCKET>,<MSG>,<FLAGS>[,<TO>])
  159. XSends a message on the <SOCKET>.
  160. Xsetsockopt(<SOCKET>,<LEVEL>,<OPTNAME>,<OPTVAL>)
  161. XSets the requested socket option.
  162. Xshutdown(<SOCKET>,<HOW>)
  163. XShuts down a <SOCKET>.
  164. Xsocket(<SOCKET>,<DOMAIN>,<TYPE>,<PROTOCOL>)
  165. XCreates a <SOCKET> in <DOMAIN> with <TYPE> and <PROTOCOL>.
  166. Xsocketpair(<SOCKET1>,<SOCKET2>,<DOMAIN>,<TYPE>,<PROTOCOL>)
  167. XAs socket, but creates a pair of bi-directional sockets.
  168. X\endtable
  169. X\beginsection 19. Miscellaneous
  170. X\table1.2in
  171. Xdefined(<EXPR>)*
  172. XTests whether the lvalue <EXPR> has a real value.
  173. Xdump [<LABEL>]
  174. XImmediate core dump. When reincarnated, starts at <LABEL>.
  175. Xlocal(<LIST>)
  176. XDeclares the listed variables to be local to the enclosing block,
  177. Xsubroutine or eval.
  178. Xpackage <NAME>
  179. XDesignates the remainder of the current block as a package, having
  180. Xa separate namespace.
  181. X%%rjc%% Changed "not omitted" to "supplied"
  182. Xreset [(<EXPR>)*]
  183. XResets |??| searches so that they work again. If <EXPR> is supplied,
  184. Xit is interpreted as a list of single characters (hyphens allowed for
  185. Xranges). All variables and arrays beginning with one of those
  186. Xletters are reset to their pristine state.  Only affects the current
  187. Xpackage.
  188. Xsub <NAME> $\{$ <EXPR>; \dots\ $\}$
  189. XDesignates <NAME> as a subroutine. Parameters are passed as array
  190. X|@_|. Returns the value of the last expression evaluated.
  191. Xundef[(<LVALUE>)*]
  192. XUndefines the <LVALUE>. Always returns the undefined value.
  193. Xwantarray
  194. XReturns true if the current context expects an array value.
  195. X\endtable
  196. X\beginsection 20. Info from system files
  197. X|/etc/passwd|.
  198. XInfo is |($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir,
  199. X$shell)|.
  200. X\medskip
  201. X\table2.4in
  202. Xendpwent
  203. XEnds lookup processing.
  204. Xgetpwent
  205. XGets next info.
  206. Xgetpwnam(<NAME>)
  207. XGets info by name.
  208. Xgetpwuid(<UID>)
  209. XGets info by uid.
  210. Xsetpwent
  211. XResets lookup processing.
  212. X\endtable
  213. X\text \medskip
  214. X|/etc/group|.
  215. XInfo is a 4-item array: |($name, $passwd, $gid, $members)|.
  216. X\medskip
  217. X\table2.4in
  218. Xendgrent
  219. XEnds lookup processing.
  220. Xgetgrgid(<GID>)
  221. XGets info by group id.
  222. Xgetgrnam(<NAME>)
  223. XGets info by name.
  224. Xgetgrent
  225. XGets next info.
  226. Xsetgrent
  227. XResets lookup processing.
  228. X\endtable
  229. X\text \medskip
  230. X|/etc/hosts|.
  231. XInfo is |($name, $aliases, $addrtype, $length, @addrs)|.
  232. X\medskip
  233. X\table2.4in
  234. Xendhostent
  235. XEnds lookup processing.
  236. Xgethostbyname(<NAME>)
  237. XGets info by name.
  238. Xgethostent
  239. XGets next info.
  240. Xsethostent(<STAYOPEN>)
  241. XResets lookup processing.
  242. X\endtable
  243. X\text\medskip
  244. X|/etc/networks|.
  245. XInfo is |($name, $aliases, $addrtype, $net)|.
  246. X\medskip
  247. X\table2.4in
  248. Xendnetent
  249. XEnds lookup processing.
  250. Xgetnetbyaddr(<ADDR>,<TYPE>)
  251. XGets info by address and type.
  252. Xgetnetbyname(<NAME>)
  253. XGets info by name.
  254. Xgetnetent
  255. XGets next info.
  256. Xsetnetent(<STAYOPEN>)
  257. XResets lookup processing.
  258. X\endtable
  259. X\text\medskip
  260. X|/etc/services|.
  261. XInfo is |($name, $aliases, $port, $proto)|.
  262. X\medskip
  263. X\table2.4in
  264. Xendservent
  265. XEnds lookup processing.
  266. Xgetservbyname(<NAME>, <PROTO>)
  267. XGets info by name.
  268. Xgetservbyport(<PORT>, <PROTO>)
  269. XGets info by port.
  270. Xgetservent
  271. XGets next info.
  272. Xsetservent(<STAYOPEN>)
  273. XResets lookup processing.
  274. X\endtable
  275. X\text\medskip
  276. X|/etc/protocols|.
  277. XInfo is |($name, $aliases, $proto)|.
  278. X\medskip
  279. X\table2.4in
  280. Xendprotoent
  281. XEnds lookup processing.
  282. Xgetprotobyname(<NAME>)
  283. XGets info by name.
  284. Xgetprotobynumber(<NUMBER>)
  285. XGets info by number.
  286. Xgetprotoent
  287. XGets next info.
  288. Xsetprotoent(<STAYOPEN>)
  289. XResets lookup processing.
  290. X\endtable
  291. X\beginsection 21. Regular expressions
  292. X\text
  293. XStandard UNIX regular expressions, with the following additions:
  294. X\medskip
  295. X\table1.2in
  296. X|(| |)| \| |{| |}|
  297. Xdo not have to be escaped with a |\|.
  298. Xmatches the preceding pattern element one or more times.
  299. Xmatches zero or one times.
  300. X%%rjc%% syntax elaborated
  301. X|{|$n$ [|,| [$m$]] |}|
  302. Xdenote the minimum ($n$)
  303. Xand maximum ($m$) match count.  If |,| is omitted, uses $m=n$.
  304. XIf $m$ is omitted but |,| is present, uses $m=\infty$.
  305. X|\w|
  306. Xmatches alphanumeric, including ``|_|'', |\W| matches non-alphanumeric.
  307. X|\b|
  308. Xmatches word boundaries, |\B| matches non-boundaries.
  309. X|\s|
  310. Xmatches whitespace, |\S| matches non-whitespace.
  311. X|\d|
  312. Xmatches numeric, |\D| matches non-numeric.
  313. X\endtable
  314. X\text\medskip
  315. X|\n|, |\r|, |\f|, |\t| and |\|<NNN> have their usual meaning.
  316. X|\w|, |\s| and |\d| may be used within character classes, |\b|
  317. Xdenotes backspace in this context.
  318. X|\1| \dots\ |\9| refer to matched sub-expressions inside the match.
  319. X|$1| \dots\ |$9| can be used to refer to matched sub-expressions outside the
  320. Xmatching.
  321. X\medskip
  322. X\table1.2in
  323. X|$+|
  324. Xreturns whatever the last bracket match matched.
  325. X|$&|
  326. Xreturns the entire matched string.
  327. X|$`|
  328. Xreturns everything before the matched string.
  329. X|$'|
  330. Xreturns everything after the matched string.
  331. X\endtable
  332. X\beginsection 22. Formats
  333. X\text
  334. Xformat [<NAME>] = \hfil\break
  335. X<FORMLIST>        \hfil\break
  336. X<FORMLIST> pictures the lines, and contains the arguments which will
  337. Xgive values to the fields in the lines. Picture fields are:
  338. X\table1in
  339. X|@<<<|\dots
  340. Xleft adjusted field, the ``|<|'' is repeated to denote the
  341. Xlength of the field;
  342. X|@>>>|\dots
  343. Xright adjusted field;
  344. X|@|\|\|\|\dots
  345. Xcentered field;
  346. X|@*|
  347. Xa multi-line field.
  348. X\endtable
  349. X\text\medskip
  350. XUse ``|^|'' instead of ``|@|'' for multi-line block filling.
  351. XUse ``|~|'' at the beginning of a line to suppress unwanted empty lines.
  352. XUse ``|~~|'' at the beginning of a line to have this format line repeated
  353. Xuntil all fields are exhausted.
  354. XSet |$-| to zero to force a page break.
  355. X\beginsection 23. Special variables
  356. X\text
  357. XThe following variables are global and should be localized in subroutines:
  358. X\medskip
  359. X\table.25in
  360. X|$_|
  361. XThe default input and pattern-searching space.
  362. X|$.|
  363. XThe current input line number of the last filehandle that was read.
  364. X|$/|
  365. XThe input record separator, newline by default.
  366. X|$,|
  367. XThe output field separator for the print operator.
  368. X|$"|
  369. XThe separator which joins elements of arrays interpolated in
  370. X strings.
  371. X|$\|
  372. XThe output record separator for the print operator.
  373. X|$#|
  374. XThe output format for printed numbers. Initial value is ``|%.20g|''.
  375. X|$*|
  376. XSet to 1 to do multiline matching within a string, 0 to assume
  377. Xstrings contain a single line. Default is 0.
  378. X|$?|
  379. XThe status returned by the last backtick (|`|\thinspace|`|) command,
  380. Xpipe close or system operator.
  381. X|$]|
  382. XThe perl version string as displayed with ``|perl -v|''.
  383. X|$[|
  384. XThe index of the first element in an array, and of the first character
  385. Xin a substring. Default is 0.
  386. X|$;|
  387. XThe subscript separator for multi-dimensional array emulation.
  388. XDefault is |"\034"|.
  389. X|$!|
  390. XIf used in a numeric context, yields the current value of errno. If
  391. Xused in a string context, yields the corresponding error string.
  392. X|$@|
  393. XThe perl error message from the last eval or ``do <EXPR>'' command.
  394. X|$:|
  395. XThe set of characters after which a string may be broken to fill
  396. Xcontinuation fields (starting with ``|^|'') in a format.
  397. X|$0|
  398. XThe name of the file containing the perl script being executed.
  399. X|$$|
  400. XThe process number of the perl running this script. Altered (in the
  401. Xchild process) by fork().
  402. X|$<|
  403. XThe real uid of this process.
  404. X|$>|
  405. XThe effective uid of this process.
  406. X|$(|
  407. XThe real gid of this process.
  408. X|$)|
  409. XThe effective gid of this process.
  410. X\endtable
  411. X\text \medskip
  412. XThe following variables are context dependent and need not be localized:
  413. X\medskip
  414. X\table.25in
  415. X|$%|
  416. XThe current page number of the currently selected output channel.
  417. X|$=|
  418. XThe page length of the current output channel. Default is 60 lines.
  419. X|$-|
  420. XThe number of lines left on the page.
  421. X|$~|
  422. XThe name of the current report format.
  423. X|$^|
  424. XThe name of the current top-of-page format.
  425. X|$|\|
  426. XIf set to nonzero, forces a flush after every write or print on the
  427. Xcurrently selected output channel. Default is 0.
  428. X\medskip
  429. X\hbox{The following variables are always local to the current block:}
  430. X\medskip
  431. X|$&|
  432. XThe string matched by the last pattern match.
  433. X|$`|
  434. XThe string preceding what was matched by the last pattern match.
  435. X|$'|
  436. XThe string following what was matched by the last pattern match.
  437. X|$+|
  438. XThe last bracket matched by the last search pattern.
  439. X|$1| \dots\ |$9|
  440. XContains the subpattern from the corresponding set of parentheses
  441. Xin the last pattern matched.
  442. X\endtable
  443. X\beginsection 24. Special arrays
  444. X\table.5in
  445. X|@ARGV|
  446. XContains the command line arguments for the script (not
  447. Xincluding the command name). See |$0| for the command
  448. Xname.
  449. X|@INC|
  450. XContains the list of places to look for perl scripts to be
  451. Xevaluated by the ``do <EXPR>'' command.
  452. X|@_|
  453. XParameter array for subroutines. Also used by split if not in
  454. Xarray context.
  455. X|%ENV|
  456. XContains the current environment.
  457. X|%SIG|
  458. XUsed to set signal handlers for various signals.
  459. X\endtable
  460. X\beginsection 25. The perl debugger (invoked with {\tt perl -d})
  461. X\table1.5in
  462. XPrints out a help message.
  463. XSingle steps.
  464. XContinues (until breakpoint or exit).
  465. X\cstok{RET}
  466. XRepeats last ``|s|'' or ``|n|''.
  467. XSingle steps around subroutine call.
  468. X|l| [<RANGE>]
  469. Xlists a range of lines. <RANGE> may be a number, start$-$end,
  470. Xstart$+$amount, or a subroutine name. If omitted, continues last ``|l|''.
  471. XLists lines that have breakpoints or actions.
  472. XToggles trace mode.
  473. X|b| [<LINE>]
  474. XSets breakpoint at (current) line.
  475. X|b| <SUBNAME>
  476. XSets breakpoint at the subroutine.
  477. XLists names of all subroutines.
  478. X|d| <LINE>
  479. XDeletes breakpoint at the given line.
  480. XDeletes all breakpoints.
  481. XDeletes all line actions.
  482. X|V| [<PACKAGE>]
  483. XLists all variables in a package. Default package is main.
  484. X|a| <LINE> <COMMAND>
  485. XSets an action for line.
  486. X|<| <COMMAND>
  487. XSets an action to be executed before every debugger prompt.
  488. X|>| <COMMAND>
  489. XSets an action to be executed before every ``|s|'', ``|c|'' or ``|n|''
  490. Xcommand.
  491. X|!| [ [|-|]<NUMBER>]
  492. XRedo a debugging command. Default is previous command.
  493. X|H| [|-|<NUMBER>]
  494. XDisplays the last |-|number commands of more than one letter.
  495. XQuits. You may also use your \cstok{EOF} character.
  496. X<COMMAND>
  497. XExecutes command as a perl statement.
  498. X|p| <EXPR>\*
  499. XPrints <EXPR>.
  500. X\endtable
  501. X\end
  502. SHAR_EOF
  503. echo "File perlref.tex is complete" &&
  504. $TOUCH -am 0402093490 perlref.tex &&
  505. chmod 0644 perlref.tex ||
  506. echo "restore of perlref.tex failed"
  507. set `wc -c perlref.tex`;Wc_c=$1
  508. if test "$Wc_c" != "37522"; then
  509.     echo original size 37522, current size $Wc_c
  510. rm -f shar3_seq_.tmp
  511. echo "You have unpacked the last part"
  512. exit 0
  513. Johan Vromans                       jv@mh.nl via internet backbones
  514. Multihouse Automatisering bv               uucp: ..!{uunet,hp4nl}!mh.nl!jv
  515. Doesburgweg 7, 2803 PL Gouda, The Netherlands  phone/fax: +31 1820 62944/62500
  516. ------------------------ "Arms are made for hugging" -------------------------
  517.