From: jv@mh.nl (Johan Vromans) Newsgroups: comp.lang.perl,alt.sources Subject: TeX version of the Perl Reference Guide - part 2 of 2 Message-ID: Date: 13 Jun 90 16:40:35 GMT X-Checksum-Snefru: c6f43ab6 93f2ec62 57dadb6f 90ef96b6 NOTE: This TeX document has been created by Raymond Chen . You should contact him for details and remarks. I'm only passing it through. Submitted-by: Raymond Chen Archive-name: perlref.tex/part02 ---- Cut Here and unpack ---- #!/bin/sh # this is xxx.02 (part 2 of perlref.tex) # do not concatenate these parts, unpack them in order with /bin/sh # file perlref.tex continued if touch 2>&1 | fgrep '[-amc]' > /dev/null then TOUCH=touch else TOUCH=true if test ! -r shar3_seq_.tmp; then echo "Please unpack part 1 first!" exit 1 (read Scheck if test "$Scheck" != 2; then echo "Please unpack part $Scheck next!" exit 1 else exit 0 ) < shar3_seq_.tmp || exit 1 echo "x - Continuing file perlref.tex" sed 's/^X//' << 'SHAR_EOF' >> perlref.tex && Xto the last selected output channel---see select(\dots)). Xprintf[([] )*] XEquivalent to ``print sprintf()''. Xread(,|$|,) XRead binary bytes from the file into the variable. XReturns number of bytes actually read. Xseek(,,) XRandomly positions the file. Returns 1 upon success, 0 otherwise. Xselect()* XSets the current default filehandle for output operations. Returns Xthe previously selected filehandle. Xsprintf(,) XReturns a string formatted by (almost all of) the usual printf Xconventions. Xtell[()]* XReturns the current file position for the file. If is Xomitted, assumes the file last read. Xwrite[()]* XWrites a formatted record to the specified file, using the format Xassociated with that file. See Formats. X\endtable X\beginsection 16. Search and replace functions X\table 1.2in X[ |=~|] [m]//[i][o] XSearches a string for a pattern. If no string is specified via the |=~| Xor |!~| operator, the |$_| string is searched. If you prepend an ``m'' you Xcan use any pair of characters as delimiters. If the final delimiter is Xfollowed by the optional letter ``i'', the matching is done in a Xcase-insensitive manner. If you append ``o'', variables are interpolated Xonly once. If used in a context that requires an array value, a Xpattern match returns an array consisting of the subexpressions Xmatched by the parentheses in pattern, i.e. |($1, $2, $3|\dots|)|. X?? XThis is just like the /pattern/ search, except that it matches only Xonce between calls to the reset operator. X[|$| |=~|] s//REPLACEMENT/[g][i][e][o] XSearches a string for a pattern, and if found, replaces that pattern Xwith the replacement text and returns the number of substitutions Xmade. Otherwise it returns false (0). Optional modifiers: ``g'' Xindicates that all occurrences of the pattern are to be replaced; ``e'' Xindicates that the replacement string is to be interpreted as an Xexpression, ``i'' and ``o'' as with // matching. Any Xdelimiter may replace the slashes; if single quotes are used, no Xinterpretation is done on the replacement string. Xstudy[(|$|\*)*] XStudy the contents of |$| in anticipation of doing many pattern Xmatches on the contents before it is next modified. X[|$| |=~|] tr/// XTranslates all occurrences of the characters found in the search list Xwith the corresponding character in the replacement list. It returns Xthe number of characters replaced. ``y'' may be used instead of ``tr''. X\endtable X\beginsection 17. System interaction X\table1.2in Xchdir [()*] XChanges the working directory, |$HOME| if is omitted. Xchroot(\*)* XChanges the root for the following commands. Xdie()* XPrints the value of to |STDERR| and exits with the current Xvalue of |$!| (errno). If |$!| is 0, exits with the value of |($? >> 8)| X(|`command`| status). If |($? >> 8)| is 0, exits with 255. Xexec()* XExecutes the system command in . Xexit()* XExits immediately with the value of . Xfork XDoes a fork() call. Returns the child pid to the parent process and Xzero to the child process. Xgetlogin XReturns the current login name from |/etc/utmp|. Xgetpgrp[()*] XReturns the process group for process (0, or omitted, means Xthe current process). Xgetppid XReturns the process id of the parent process. Xgetpriority(,) XReturns the current priority for a process, process group, or user. Xkill()* XSends a signal to a list of processes. The first element of the list Xmust be the signal to send (numeric, or its name as a string). Xsetpgrp(,) XSets the process group for the (0 = current process). Xsetpriority(,,) XSets the current priority for a process, process group or a user. Xsleep[()*] XCauses the script to sleep for seconds, or forever if no X. Returns the number of seconds actually slept. Xsyscall()* XCalls the system call specified in the first element of the list, Xpassing the rest of the list as arguments to the call. Xsystem()* XDoes exactly the same thing as ``exec '' except that a fork is Xdone first, and the parent process waits for the child process to Xcomplete. Xtimes XReturns a 4-element array |($user, $system, $cuser, $csystem)| Xgiving the user and system times, in seconds, for this process and Xthe children of this process. Xumask[()*] XSets the umask for the process and returns the old one. If is Xomitted, returns current umask value. Xwait XWaits for a child process to terminate and returns the pid of the Xdeceased process ($-1$ if none). The status is returned in |$?|. Xwarn()* XPrints the message on |STDERR| like die(\dots), but doesn't exit. X\endtable X\beginsection 18. Networking X\table1.2in Xaccept(,) XAccepts a new socket. Xbind(,) XBinds the to the . Xconnect(, ) XConnects the to the . Xgetpeername() XReturns the socket address of the other end of the . Xgetsockname() XReturns the name of the socket. Xgetsockopt(,,) XReturns the socket options. Xlisten(,) XStarts listening on the specified . Xrecv(,,,) XReceives a message on . Xsend(,,[,]) XSends a message on the . Xsetsockopt(,,,) XSets the requested socket option. Xshutdown(,) XShuts down a . Xsocket(,,,) XCreates a in with and . Xsocketpair(,,,,) XAs socket, but creates a pair of bi-directional sockets. X\endtable X\beginsection 19. Miscellaneous X\table1.2in Xdefined()* XTests whether the lvalue has a real value. Xdump [