Use of uninitialized value in concatenation (.) or string at /usr/local/perl/5.14.2/lib/5.14.2/Pod/Perldoc/ToMan.pm line 50. DEBUG __nroffer is DEBUG Looking for /usr/local/perl/5.14.2/bin/groff DEBUG Looking for /home/tom/bin/groff DEBUG Looking for /usr/local/sbin/groff DEBUG Looking for /usr/local/bin/groff DEBUG Looking for /usr/sbin/groff DEBUG Looking for /usr/bin/groff DEBUG Found /usr/bin/groff DEBUG Looking for /sbin/groff DEBUG Looking for /bin/groff DEBUG Looking for /usr/games/groff DEBUG Looking for /usr/local/perl/5.14.2/bin/nroff DEBUG Looking for /home/tom/bin/nroff DEBUG Looking for /usr/local/sbin/nroff DEBUG Looking for /usr/local/bin/nroff DEBUG Looking for /usr/sbin/nroff DEBUG Looking for /usr/bin/nroff DEBUG Found /usr/bin/nroff DEBUG Looking for /sbin/nroff DEBUG Looking for /bin/nroff DEBUG Looking for /usr/games/nroff DEBUG Using /usr/bin/groff DEBUG Pod::Man switches are [utf8 1] DEBUG Parsing /usr/local/perl/5.14.2/lib/5.14.2/pod/perlfunc.pod DEBUG Done parsing /usr/local/perl/5.14.2/lib/5.14.2/pod/perlfunc.pod DEBUG Writing podman.out.1574.txt with Pod::Man output DEBUG Filtering through /usr/bin/groff 'opt_o_with: Noting "text" as desired output format... 'opt_o_with: Noting "man" as desired output format... 'GetOptsOO::getopts: Starting switch processing. Scanning arguments [perlfunc] 'GetOptsOO::getopts: Ending switch processing. Args are [perlfunc] with 0 errors. 'process: /usr/local/perl/5.14.2/bin/perldoc => Pod::Perldoc v3.15_13 'process: 'find_good_formatter_class: Formatter class Pod::Perldoc::ToMan version 3.15_13 successfully loaded! 'find_good_formatter_class: Will format with the class Pod::Perldoc::ToMan 'grand_search_init: Searching for perlfunc 'searchfor: Looking for perlfunc in /usr/local/perl/5.14.2/bin /usr/local/perl/5.14.2/lib/site_perl/5.14.2/i686-linux /usr/local/perl/5.14.2/lib/site_perl/5.14.2 /usr/local/perl/5.14.2/lib/5.14.2/i686-linux /usr/local/perl/5.14.2/lib/5.14.2 . /usr/local/perl/5.14.2/bin /home/tom/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games 'grand_search_init: Found as /usr/local/perl/5.14.2/lib/5.14.2/pod/perlfunc.pod DEBUG Found groff 1.20.1 DEBUG render is /usr/bin/groff DEBUG render options are -man DEBUG Writing to pipe to groff DEBUG Writing chunk 94.062744140625 DEBUG Checking read DEBUG Writing chunk 95.062744140625 DEBUG Checking read DEBUG Writing chunk 96.062744140625 DEBUG Checking read DEBUG Writing chunk 97.062744140625 DEBUG Checking read DEBUG Writing chunk 98.062744140625 DEBUG Checking read DEBUG Writing chunk 99.062744140625 DEBUG Checking read DEBUG Writing chunk 100.062744140625 DEBUG Checking read DEBUG Writing chunk 101.062744140625 DEBUG Checking read DEBUG Writing chunk 102.062744140625 DEBUG Checking read DEBUG Writing chunk 103.062744140625 DEBUG Checking read DEBUG Writing chunk 104.062744140625 DEBUG Checking read DEBUG Writing chunk 105.062744140625 DEBUG Checking read DEBUG Writing chunk 106.062744140625 DEBUG Checking read DEBUG Writing chunk 107.062744140625 DEBUG Checking read DEBUG Writing chunk 108.062744140625 DEBUG Checking read DEBUG Writing chunk 109.062744140625 DEBUG Checking read DEBUG Writing chunk 110.062744140625 DEBUG Checking read DEBUG Writing chunk 111.062744140625 DEBUG Checking read DEBUG Writing chunk 112.062744140625 DEBUG Checking read DEBUG Writing chunk 113.062744140625 DEBUG Checking read DEBUG Writing chunk 114.062744140625 DEBUG Checking read DEBUG Writing chunk 115.062744140625 DEBUG Checking read DEBUG Writing chunk 116.062744140625 DEBUG Checking read DEBUG Writing chunk 117.062744140625 DEBUG Checking read DEBUG Writing chunk 118.062744140625 DEBUG Checking read DEBUG Writing chunk 119.062744140625 DEBUG Checking read DEBUG Writing chunk 120.062744140625 DEBUG Checking read DEBUG Writing chunk 121.062744140625 DEBUG Checking read DEBUG Writing chunk 122.062744140625 DEBUG Checking read DEBUG Writing chunk 123.062744140625 DEBUG Checking read DEBUG Writing chunk 124.062744140625 DEBUG Checking read DEBUG Writing chunk 125.062744140625 DEBUG Checking read DEBUG Writing chunk 126.062744140625 DEBUG Checking read DEBUG Writing chunk 127.062744140625 DEBUG Checking read DEBUG Writing chunk 128.062744140625 DEBUG Checking read DEBUG Writing chunk 129.062744140625 DEBUG Checking read DEBUG Writing chunk 130.062744140625 DEBUG Checking read DEBUG Writing chunk 131.062744140625 DEBUG Checking read DEBUG Writing chunk 132.062744140625 DEBUG Checking read DEBUG Writing chunk 133.062744140625 DEBUG Checking read DEBUG Writing chunk 134.062744140625 DEBUG Checking read DEBUG Writing chunk 135.062744140625 DEBUG Checking read DEBUG Writing chunk 136.062744140625 DEBUG Checking read DEBUG Writing chunk 137.062744140625 DEBUG Checking read DEBUG Writing chunk 138.062744140625 DEBUG Checking read DEBUG Writing chunk 139.062744140625 DEBUG Checking read DEBUG Writing chunk 140.062744140625 DEBUG Checking read DEBUG Writing chunk 141.062744140625 DEBUG Checking read DEBUG Writing chunk 142.062744140625 DEBUG Checking read DEBUG Writing chunk 143.062744140625 DEBUG Checking read DEBUG Writing chunk 144.062744140625 DEBUG Checking read DEBUG Writing chunk 145.062744140625 DEBUG Checking read DEBUG Writing chunk 146.062744140625 DEBUG Checking read DEBUG Writing chunk 147.062744140625 DEBUG Checking read DEBUG Writing chunk 148.062744140625 DEBUG Checking read DEBUG Writing chunk 149.062744140625 DEBUG Checking read DEBUG Writing chunk 150.062744140625 DEBUG Checking read DEBUG Writing chunk 151.062744140625 DEBUG Checking read DEBUG Writing chunk 152.062744140625 DEBUG Checking read DEBUG Writing chunk 153.062744140625 DEBUG Checking read DEBUG Writing chunk 154.062744140625 DEBUG Checking read DEBUG Writing chunk 155.062744140625 DEBUG Checking read DEBUG Writing chunk 156.062744140625 DEBUG Checking read DEBUG Writing chunk 157.062744140625 DEBUG Checking read DEBUG Writing chunk 158.062744140625 DEBUG Checking read DEBUG Writing chunk 159.062744140625 DEBUG Checking read DEBUG Writing chunk 160.062744140625 DEBUG Checking read DEBUG Writing chunk 161.062744140625 DEBUG Checking read DEBUG Writing chunk 162.062744140625 DEBUG Checking read DEBUG Writing chunk 163.062744140625 DEBUG Checking read DEBUG Writing chunk 164.062744140625 DEBUG Checking read DEBUG Writing chunk 165.062744140625 DEBUG Checking read DEBUG Writing chunk 166.062744140625 DEBUG Checking read DEBUG Writing chunk 167.062744140625 DEBUG Checking read DEBUG Writing chunk 168.062744140625 DEBUG Checking read DEBUG Writing chunk 169.062744140625 DEBUG Checking read DEBUG Writing chunk 170.062744140625 DEBUG Checking read DEBUG Writing chunk 171.062744140625 DEBUG Checking read DEBUG Writing chunk 172.062744140625 DEBUG Checking read DEBUG Writing chunk 173.062744140625 DEBUG Checking read DEBUG Writing chunk 174.062744140625 DEBUG Checking read DEBUG Writing chunk 175.062744140625 DEBUG Checking read DEBUG Writing chunk 176.062744140625 DEBUG Checking read DEBUG Writing chunk 177.062744140625 DEBUG Checking read DEBUG Writing chunk 178.062744140625 DEBUG Checking read DEBUG Writing chunk 179.062744140625 DEBUG Checking read DEBUG Writing chunk 180.062744140625 DEBUG Checking read DEBUG Writing chunk 181.062744140625 DEBUG Checking read DEBUG Writing chunk 182.062744140625 DEBUG Checking read DEBUG Writing chunk 183.062744140625 DEBUG Checking read DEBUG Writing chunk 184.062744140625 DEBUG Checking read DEBUG Writing chunk 185.062744140625 DEBUG Checking read DEBUG Writing chunk 186.062744140625 DEBUG Checking read DEBUG Writing chunk 187.062744140625 DEBUG Checking read DEBUG Writing chunk 188.062744140625 DEBUG Checking read DEBUG Done writing DEBUG Done reading. Output is 591372 bytes DEBUG Output: ---- %!PS-Adobe-3.0 %%Creator: groff version 1.20.1 %%CreationDate: Wed Dec 14 12:40:06 2011 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic %%+ font Courier %%+ font Courier-Oblique %%+ font Courier-Bold %%DocumentSuppliedResources: procset grops 1.20 1 %%Pages: 105 %%PageOrder: Ascend %%DocumentMedia: Default 612 792 0 () () %%Orientation: Portrait %%EndComments %%BeginDefaults %%PageMedia: Default %%EndDefaults %%BeginProlog %%BeginResource: procset grops 1.20 1 %!PS-Adobe-3.0 Resource-ProcSet /setpacking where{ pop currentpacking true setpacking }if /grops 120 dict dup begin /SC 32 def /A/show load def /B{0 SC 3 -1 roll widthshow}bind def /C{0 exch ashow}bind def /D{0 exch 0 SC 5 2 roll awidthshow}bind def /E{0 rmoveto show}bind def /F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def /G{0 rmoveto 0 exch ashow}bind def /H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /I{0 exch rmoveto show}bind def /J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def /K{0 exch rmoveto 0 exch ashow}bind def /L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /M{rmoveto show}bind def /N{rmoveto 0 SC 3 -1 roll widthshow}bind def /O{rmoveto 0 exch ashow}bind def /P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /Q{moveto show}bind def /R{moveto 0 SC 3 -1 roll widthshow}bind def /S{moveto 0 exch ashow}bind def /T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def /SF{ findfont exch [exch dup 0 exch 0 exch neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /MF{ findfont [5 2 roll 0 3 1 roll neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /level0 0 def /RES 0 def /PL 0 def /LS 0 def /MANUAL{ statusdict begin/manualfeed true store end }bind def /PLG{ gsave newpath clippath pathbbox grestore exch pop add exch pop }bind def /BP{ /level0 save def 1 setlinecap 1 setlinejoin DEFS/BPhook known{DEFS begin BPhook end}if 72 RES div dup scale LS{ 90 rotate }{ 0 PL translate }ifelse 1 -1 scale }bind def /EP{ level0 restore showpage }def /DA{ newpath arcn stroke }bind def /SN{ transform .25 sub exch .25 sub exch round .25 add exch round .25 add exch itransform }bind def /DL{ SN moveto SN lineto stroke }bind def /DC{ newpath 0 360 arc closepath }bind def /TM matrix def /DE{ TM currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath TM setmatrix }bind def /RC/rcurveto load def /RL/rlineto load def /ST/stroke load def /MT/moveto load def /CL/closepath load def /Fr{ setrgbcolor fill }bind def /setcmykcolor where{ pop /Fk{ setcmykcolor fill }bind def }if /Fg{ setgray fill }bind def /FL/fill load def /LW/setlinewidth load def /Cr/setrgbcolor load def /setcmykcolor where{ pop /Ck/setcmykcolor load def }if /Cg/setgray load def /RE{ findfont dup maxlength 1 index/FontName known not{1 add}if dict begin { 1 index/FID ne 2 index/UniqueID ne and {def}{pop pop}ifelse }forall /Encoding exch def dup/FontName exch def currentdict end definefont pop }bind def /DEFS 0 def /EBEGIN{ moveto DEFS begin }bind def /EEND/end load def /CNT 0 def /level1 0 def /PBEGIN{ /level1 save def translate div 3 1 roll div exch scale neg exch neg exch translate 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit []0 setdash /setstrokeadjust where{ pop false setstrokeadjust }if /setoverprint where{ pop false setoverprint }if newpath /CNT countdictstack def userdict begin /showpage{}def /setpagedevice{}def mark }bind def /PEND{ cleartomark countdictstack CNT sub{end}repeat level1 restore }bind def end def /setpacking where{ pop setpacking }if %%EndResource %%EndProlog %%BeginSetup %%BeginFeature: *PageSize Default << /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice %%EndFeature %%IncludeResource: font Times-Roman %%IncludeResource: font Times-Bold %%IncludeResource: font Times-Italic %%IncludeResource: font Courier %%IncludeResource: font Courier-Oblique %%IncludeResource: font Courier-Bold grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron /scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent /ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen /period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O /P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex /underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y /z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft /guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl /endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen /brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft /logicalnot/minus/registered/macron/degree/plusminus/twosuperior /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior /ordmasculine/guilsinglright/onequarter/onehalf/threequarters /questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn /germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash /ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def /Courier-Bold@0 ENC0/Courier-Bold RE/Courier-Oblique@0 ENC0 /Courier-Oblique RE/Courier@0 ENC0/Courier RE/Times-Italic@0 ENC0 /Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE/Times-Roman@0 ENC0 /Times-Roman RE %%EndSetup %%Page: 1 1 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10.95 /Times-Bold@0 SF -.219(NA)72 84 S(ME).219 E F0(perlfunc \255 Perl b)108 96 Q(uiltin functions)-.2 E F1(DESCRIPTION)72 112.8 Q F0 .591 (The functions in this section can serv)108 124.8 R 3.091(ea)-.15 G 3.091(st)-3.091 G .591(erms in an e)-3.091 F 3.09(xpression. The)-.15 F 3.09(yf)-.15 G .59(all into tw)-3.19 F 3.09(om)-.1 G .59(ajor cate)-3.09 F .59(gories: list)-.15 F 2.4(operators and named unary operators.)108 136.8 R 2.401(These dif)7.401 F 2.401 (fer in their precedence relationship with a follo)-.25 F(wing)-.25 E 3.659(comma. \(See)108 148.8 R 1.159(the precedence table in perlop.\)) 3.659 F 1.159(List operators tak)6.159 F 3.659(em)-.1 G 1.158 (ore than one ar)-3.659 F 1.158(gument, while unary)-.18 F 1.521 (operators can ne)108 160.8 R -.15(ve)-.25 G 4.022(rt).15 G(ak)-4.022 E 4.022(em)-.1 G 1.522(ore than one ar)-4.022 F 4.022(gument. Thus,)-.18 F 4.022(ac)4.022 G 1.522(omma terminates the ar)-4.022 F 1.522 (gument of a unary)-.18 F(operator)108 172.8 Q 2.999(,b)-.4 G .499 (ut merely separates the ar)-3.199 F .499(guments of a list operator) -.18 F 5.499(.A)-.55 G .498(unary operator generally pro)-2.501 F .498 (vides scalar)-.15 F(conte)108 184.8 Q .36(xt to its ar)-.15 F .36 (gument, while a list operator may pro)-.18 F .36 (vide either scalar or list conte)-.15 F .36(xts for its ar)-.15 F 2.86 (guments. If)-.18 F .474(it does both, scalar ar)108 196.8 R .474 (guments come \214rst and list ar)-.18 F .474(gument follo)-.18 F 1.774 -.65(w, a)-.25 H .474(nd there can only e).65 F -.15(ve)-.25 G 2.973(rb) .15 G 2.973(eo)-2.973 G .473(ne such list)-2.973 F(ar)108 208.8 Q 2.512 (gument. F)-.18 F .012(or instance,)-.15 F/F2 10/Times-Italic@0 SF (splice\(\))2.513 E F0 .013(has three scalar ar)2.513 F .013 (guments follo)-.18 F .013(wed by a list, whereas)-.25 F F2 -.1(ge)2.513 G(thostbyname\(\)).1 E F0(has)2.513 E(four scalar ar)108 220.8 Q (guments.)-.18 E .462(In the syntax descriptions that follo)108 237.6 R 1.761 -.65(w, l)-.25 H .461(ist operators that e).65 F .461 (xpect a list \(and pro)-.15 F .461(vide list conte)-.15 F .461 (xt for elements)-.15 F 1.433(of the list\) are sho)108 249.6 R 1.433 (wn with)-.25 F/F3 9/Times-Roman@0 SF(LIST)3.934 E F0 1.434(as an ar) 3.934 F 3.934(gument. Such)-.18 F 3.934(al)3.934 G 1.434 (ist may consist of an)-3.934 F 3.934(yc)-.15 G 1.434 (ombination of scalar)-3.934 F(ar)108 261.6 Q 1.739(guments or list v) -.18 F 1.739(alues; the list v)-.25 F 1.739 (alues will be included in the list as if each indi)-.25 F 1.738 (vidual element were)-.25 F 2.323(interpolated at that point in the lis\ t, forming a longer single-dimensional list v)108 273.6 R 4.824 (alue. Commas)-.25 F(should)4.824 E(separate literal elements of the)108 285.6 Q F3(LIST)2.5 E F0(.)A(An)108 302.4 Q 3.031(yf)-.15 G .531 (unction in the list belo)-3.031 F 3.031(wm)-.25 G .53 (ay be used either with or without parentheses around its ar)-3.031 F 3.03(guments. \(The)-.18 F 1.07 (syntax descriptions omit the parentheses.\))108 314.4 R 1.071 (If you use parentheses, the simple b)6.071 F 1.071 (ut occasionally surprising)-.2 F .254(rule is this: It)108 326.4 R F2 (looks)2.754 E F0(lik)2.754 E 2.754(eaf)-.1 G .254 (unction, therefore it)-2.754 F F2(is)2.754 E F0 2.754(af)2.754 G .254 (unction, and precedence doesn')-2.754 F 2.754(tm)-.18 G(atter)-2.754 E 5.253(.O)-.55 G .253(therwise it')-5.253 F(s)-.55 E 3.63(al)108 338.4 S 1.13(ist operator or unary operator)-3.63 F 3.631(,a)-.4 G 1.131 (nd precedence does matter)-3.631 F 6.131(.W)-.55 G 1.131 (hitespace between the function and left)-6.131 F(parenthesis doesn')108 350.4 Q 2.5(tc)-.18 G(ount, so sometimes you need to be careful:)-2.5 E /F4 10/Courier@0 SF(print 1+2+4;)132 367.2 Q 6(#P)36 G(rints 7.)-6 E (print\(1+2\) + 4;)132 379.2 Q 6(#P)18 G(rints 3.)-6 E(print \(1+2\)+4;) 132 391.2 Q 6(#A)24 G(lso prints 3!)-6 E(print +\(1+2\)+4;)132 403.2 Q 6 (#P)18 G(rints 7.)-6 E(print \(\(1+2\)+4\);)132 415.2 Q 6(#P)12 G (rints 7.)-6 E F0(If you run Perl with the)108 432 Q/F5 10/Times-Bold@0 SF2.5 E F0(switch it can w)2.5 E(arn you about this.)-.1 E -.15 (Fo)5 G 2.5(re).15 G(xample, the third line abo)-2.65 E .3 -.15(ve p) -.15 H(roduces:).15 E F4 (print \(...\) interpreted as function at \255 line 1.)132 448.8 Q (Useless use of integer addition in void context at \255 line 1.)132 460.8 Q F0 3.739(Af)108 477.6 S 1.739 -.25(ew f)-3.739 H 1.239 (unctions tak).25 F 3.739(en)-.1 G 3.739(oa)-3.739 G -.18(rg)-3.739 G 1.239(uments at all, and therefore w).18 F 1.239 (ork as neither unary nor list operators.)-.1 F(These)6.238 E .011 (include such functions as)108 489.6 R F4(time)2.511 E F0(and)2.511 E F4 (endpwent)2.511 E F0 5.012(.F)C .012(or e)-5.162 F(xample,)-.15 E F4 (time+86_400)2.512 E F0(al)2.512 E -.1(wa)-.1 G .012(ys means).1 F F4 .012(time\(\) +)2.512 F(86_400)108 501.6 Q F0(.)A -.15(Fo)108 518.4 S 2.892(rf).15 G .391 (unctions that can be used in either a scalar or list conte)-2.892 F .391(xt, nonaborti)-.15 F .691 -.15(ve f)-.25 H .391 (ailure is generally indicated in).05 F(scalar conte)108 530.4 Q (xt by returning the unde\214ned v)-.15 E(alue, and in list conte)-.25 E (xt by returning the empty list.)-.15 E .662(Remember the follo)108 547.2 R .662(wing important rule: There is)-.25 F F5 .662(no rule)3.162 F F0 .662(that relates the beha)3.162 F .663(vior of an e)-.2 F .663 (xpression in list)-.15 F(conte)108 559.2 Q 1.814(xt to its beha)-.15 F 1.814(vior in scalar conte)-.2 F 1.814(xt, or vice v)-.15 F 4.313 (ersa. It)-.15 F 1.813(might do tw)4.313 F 4.313(ot)-.1 G 1.813 (otally dif)-4.313 F 1.813(ferent things.)-.25 F(Each)6.813 E 1.116 (operator and function decides which sort of v)108 571.2 R 1.116(alue w) -.25 F 1.116(ould be most appropriate to return in scalar conte)-.1 F (xt.)-.15 E .63(Some operators return the length of the list that w)108 583.2 R .63(ould ha)-.1 F .93 -.15(ve b)-.2 H .63 (een returned in list conte).15 F 3.13(xt. Some)-.15 F(operators)3.13 E .909(return the \214rst v)108 595.2 R .909(alue in the list.)-.25 F .909 (Some operators return the last v)5.909 F .909(alue in the list.)-.25 F .909(Some operators return a)5.909 F(count of successful operations.)108 607.2 Q(In general, the)5 E 2.5(yd)-.15 G 2.5(ow)-2.5 G(hat you w)-2.5 E (ant, unless you w)-.1 E(ant consistenc)-.1 E -.65(y.)-.15 G 3.768(An) 108 624 S 1.268(amed array in scalar conte)-3.768 F 1.268 (xt is quite dif)-.15 F 1.268(ferent from what w)-.25 F 1.268 (ould at \214rst glance appear to be a list in)-.1 F .248(scalar conte) 108 636 R 2.748(xt. Y)-.15 F .248(ou can')-1.1 F 2.748(tg)-.18 G .248 (et a list lik)-2.748 F(e)-.1 E F4(\(1,2,3\))2.748 E F0 .248 (into being in scalar conte)2.748 F .249(xt, because the compiler kno) -.15 F(ws)-.25 E .996(the conte)108 648 R .996(xt at compile time.)-.15 F .996(It w)5.996 F .995(ould generate the scalar comma operator there,\ not the list construction)-.1 F -.15(ve)108 660 S(rsion of the comma.) .15 E(That means it w)5 E(as ne)-.1 E -.15(ve)-.25 G 2.5(ral).15 G (ist to start with.)-2.5 E 1.107 (In general, functions in Perl that serv)108 676.8 R 3.608(ea)-.15 G 3.608(sw)-3.608 G 1.108(rappers for system calls \(`)-3.608 F (`syscalls')-.74 E 1.108('\) of the same name \(lik)-.74 F(e)-.1 E F2 -.15(ch)108 688.8 S(own).15 E F0(\(2\),)1.666 E F2(fork)3.802 E F0 (\(2\),)1.666 E F2(closedir)3.802 E F0 1.302 (\(2\), etc.\) return true when the)1.666 F 3.802(ys)-.15 G 1.301 (ucceed and)-3.802 F F4(undef)3.801 E F0 1.301(otherwise, as is usually) 3.801 F .991(mentioned in the descriptions belo)108 700.8 R 4.791 -.65 (w. T)-.25 H .991(his is dif).65 F .991(ferent from the C interf)-.25 F .991(aces, which return)-.1 F F43.492 E F0 .992(on f)3.492 F (ailure.)-.1 E 1.561(Exceptions to this rule include)108 712.8 R F4 (wait)4.061 E F0(,)A F4(waitpid)4.061 E F0 4.061(,a)C(nd)-4.061 E F4 (syscall)4.061 E F0 6.561(.S)C 1.56(ystem calls also set the special) -6.561 F F4($!)4.06 E F0 -.25(va)108 724.8 S(riable on f).25 E 2.5 (ailure. Other)-.1 F(functions do not, e)2.5 E(xcept accidentally)-.15 E (.)-.65 E(perl v5.14.2)72 768 Q 203.17(2011-10-01 1)162.62 F 0 Cg EP %%Page: 2 2 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .817 (Extension modules can also hook into the Perl parser to de\214ne ne)108 84 R 3.318(wk)-.25 G .818(inds of k)-3.318 F -.15(ey)-.1 G -.1(wo).15 G .818(rd-headed e).1 F(xpression.)-.15 E .436(These may look lik)108 96 R 2.936(ef)-.1 G .436(unctions, b)-2.936 F .435 (ut may also look completely dif)-.2 F 2.935(ferent. The)-.25 F .435 (syntax follo)2.935 F .435(wing the k)-.25 F -.15(ey)-.1 G -.1(wo).15 G (rd).1 E .815(is de\214ned entirely by the e)108 108 R 3.315 (xtension. If)-.15 F .815(you are an implementor)3.315 F 3.316(,s)-.4 G .816(ee `)-3.316 F(`PL_k)-.74 E -.15(ey)-.1 G -.1(wo).15 G(rd_plugin').1 E 3.316('i)-.74 G 3.316(np)-3.316 G .816(erlapi for)-3.316 F .612 (the mechanism.)108 120 R .611 (If you are using such a module, see the module')5.612 F 3.111(sd)-.55 G .611(ocumentation for details of the syntax)-3.111 F(that it de\214nes.) 108 132 Q/F1 10/Times-Bold@0 SF -.2(Pe)87 148.8 S (rl Functions by Category).2 E F0 2.625(Here are Perl')108 160.8 R 5.125 (sf)-.55 G 2.626(unctions \(including things that look lik)-5.125 F 5.126(ef)-.1 G 2.626(unctions, lik)-5.126 F 5.126(es)-.1 G 2.626(ome k) -5.126 F -.15(ey)-.1 G -.1(wo).15 G 2.626(rds and named).1 F (operators\) arranged by cate)108 172.8 Q(gory)-.15 E 5(.S)-.65 G (ome functions appear in more than one place.)-5 E (Functions for SCALARs or strings)108 189.6 Q/F2 10/Courier@0 SF(chomp) 128 201.6 Q F0(,)A F2(chop)2.693 E F0(,)A F2(chr)2.693 E F0(,)A F2 (crypt)2.693 E F0(,)A F2(hex)2.693 E F0(,)A F2(index)2.692 E F0(,)A F2 (lc)2.692 E F0(,)A F2(lcfirst)2.692 E F0(,)A F2(length)2.692 E F0(,)A F2 (oct)2.692 E F0(,)A F2(ord)2.692 E F0(,)A F2(pack)2.692 E F0(,)A F2(q//) 2.692 E F0(,)A F2(qq//)2.692 E F0(,)A F2(reverse)128 213.6 Q F0(,)A F2 (rindex)2.5 E F0(,)A F2(sprintf)2.5 E F0(,)A F2(substr)2.5 E F0(,)A F2 (tr///)2.5 E F0(,)A F2(uc)2.5 E F0(,)A F2(ucfirst)2.5 E F0(,)A F2(y///) 2.5 E F0(Re)108 230.4 Q(gular e)-.15 E(xpressions and pattern matching) -.15 E F2(m//)128 242.4 Q F0(,)A F2(pos)2.5 E F0(,)A F2(quotemeta)2.5 E F0(,)A F2(s///)2.5 E F0(,)A F2(split)2.5 E F0(,)A F2(study)2.5 E F0(,)A F2(qr//)2.5 E F0(Numeric functions)108 259.2 Q F2(abs)128 271.2 Q F0(,)A F2(atan2)2.5 E F0(,)A F2(cos)2.5 E F0(,)A F2(exp)2.5 E F0(,)A F2(hex)2.5 E F0(,)A F2(int)2.5 E F0(,)A F2(log)2.5 E F0(,)A F2(oct)2.5 E F0(,)A F2 (rand)2.5 E F0(,)A F2(sin)2.5 E F0(,)A F2(sqrt)2.5 E F0(,)A F2(srand)2.5 E F0(Functions for real)108 288 Q F2(@ARRAYs)2.5 E(each)128 300 Q F0(,)A F2(keys)2.5 E F0(,)A F2(pop)2.5 E F0(,)A F2(push)2.5 E F0(,)A F2(shift) 2.5 E F0(,)A F2(splice)2.5 E F0(,)A F2(unshift)2.5 E F0(,)A F2(values) 2.5 E F0(Functions for list data)108 316.8 Q F2(grep)128 328.8 Q F0(,)A F2(join)2.5 E F0(,)A F2(map)2.5 E F0(,)A F2(qw//)2.5 E F0(,)A F2 (reverse)2.5 E F0(,)A F2(sort)2.5 E F0(,)A F2(unpack)2.5 E F0 (Functions for real)108 345.6 Q F2(%HASHes)2.5 E(delete)128 357.6 Q F0 (,)A F2(each)2.5 E F0(,)A F2(exists)2.5 E F0(,)A F2(keys)2.5 E F0(,)A F2 (values)2.5 E F0(Input and output functions)108 374.4 Q F2(binmode)128 386.4 Q F0(,)A F2(close)4.333 E F0(,)A F2(closedir)4.333 E F0(,)A F2 (dbmclose)4.333 E F0(,)A F2(dbmopen)4.333 E F0(,)A F2(die)4.333 E F0(,)A F2(eof)4.333 E F0(,)A F2(fileno)4.334 E F0(,)A F2(flock)4.334 E F0(,)A F2(format)4.334 E F0(,)A F2(getc)128 398.4 Q F0(,)A F2(print)6.334 E F0 (,)A F2(printf)6.334 E F0(,)A F2(read)6.334 E F0(,)A F2(readdir)6.333 E F0(,)A F2(rewinddir)6.333 E F0(,)A F2(say)6.333 E F0(,)A F2(seek)6.333 E F0(,)A F2(seekdir)6.333 E F0(,)A F2(select)6.333 E F0(,)A F2(syscall)128 410.4 Q F0(,)A F2(sysread)2.5 E F0(,)A F2(sysseek)2.5 E F0(,)A F2 (syswrite)2.5 E F0(,)A F2(tell)2.5 E F0(,)A F2(telldir)2.5 E F0(,)A F2 (truncate)2.5 E F0(,)A F2(warn)2.5 E F0(,)A F2(write)2.5 E F0 (Functions for \214x)108 427.2 Q(ed-length data or records)-.15 E F2 (pack)128 439.2 Q F0(,)A F2(read)2.5 E F0(,)A F2(syscall)2.5 E F0(,)A F2 (sysread)2.5 E F0(,)A F2(syswrite)2.5 E F0(,)A F2(unpack)2.5 E F0(,)A F2 (vec)2.5 E F0(Functions for \214lehandles, \214les, or directories)108 456 Q F2128 468 Q/F3 10/Courier-Oblique@0 SF(X)A F0(,)A F2(chdir) 4.727 E F0(,)A F2(chmod)4.727 E F0(,)A F2(chown)4.727 E F0(,)A F2 (chroot)4.727 E F0(,)A F2(fcntl)4.727 E F0(,)A F2(glob)4.727 E F0(,)A F2 (ioctl)4.727 E F0(,)A F2(link)4.727 E F0(,)A F2(lstat)4.728 E F0(,)A F2 (mkdir)4.728 E F0(,)A F2(open)4.728 E F0(,)A F2(opendir)128 480 Q F0(,)A F2(readlink)2.5 E F0(,)A F2(rename)2.5 E F0(,)A F2(rmdir)2.5 E F0(,)A F2 (stat)2.5 E F0(,)A F2(symlink)2.5 E F0(,)A F2(sysopen)2.5 E F0(,)A F2 (umask)2.5 E F0(,)A F2(unlink)2.5 E F0(,)A F2(utime)2.5 E F0 -2.15 -.25 (Ke y)108 496.8 T -.1(wo).25 G(rds related to the control \215o).1 E 2.5 (wo)-.25 G 2.5(fy)-2.5 G(our Perl program)-2.5 E F2(caller)128 508.8 Q F0(,)A F2(continue)3.625 E F0(,)A F2(die)3.625 E F0(,)A F2(do)3.625 E F0 (,)A F2(dump)3.625 E F0(,)A F2(eval)3.625 E F0(,)A F2(exit)3.625 E F0(,) A F2(goto)3.625 E F0(,)A F2(last)3.625 E F0(,)A F2(next)3.625 E F0(,)A F2(redo)3.625 E F0(,)A F2(return)3.625 E F0(,)A F2(sub)3.625 E F0(,)A F2 (wantarray)128 520.8 Q F0 -2.15 -.25(Ke y)108 537.6 T -.1(wo).25 G (rds related to the switch feature).1 E F2(break)128 549.6 Q F0(,)A F2 (continue)2.5 E F0(,)A F2(default, given)2.5 E F0(,)A F2(when)2.5 E F0 .629(These are a)128 567.6 R -.25(va)-.2 G .629 (ilable only if you enable the).25 F F2("switch")3.129 E F0 3.129 (feature. See)3.129 F .63(feature and `)3.13 F .63(`Switch statements') -.74 F(')-.74 E(in perlsyn.)128 579.6 Q(Alternately)5 E 2.5(,i)-.65 G (nclude a)-2.5 E F2(use v5.10)2.5 E F0(or later to the current scope.) 2.5 E -2.15 -.25(Ke y)108 596.4 T -.1(wo).25 G(rds related to scoping).1 E F2(caller)128 608.4 Q F0(,)A F2(import)2.5 E F0(,)A F2(local)2.5 E F0 (,)A F2(my)2.5 E F0(,)A F2(our)2.5 E F0(,)A F2(package)2.5 E F0(,)A F2 (state)2.5 E F0(,)A F2(use)2.5 E(state)128 626.4 Q F0 .675(is a)3.175 F -.25(va)-.2 G .675(ilable only if the).25 F F2("state")3.175 E F0 .675 (feature is enabled. See feature.)3.175 F(Alternately)5.674 E 3.174(,i) -.65 G .674(nclude a)-3.174 F F2(use)3.174 E(v5.10)128 638.4 Q F0 (or later to the current scope.)2.5 E(Miscellaneous functions)108 655.2 Q F2(defined)128 667.2 Q F0(,)A F2(dump)6.05 E F0(,)A F2(eval)6.05 E F0 (,)A F2(formline)6.05 E F0(,)A F2(local)6.05 E F0(,)A F2(my)6.05 E F0(,) A F2(our)6.05 E F0(,)A F2(reset)6.05 E F0(,)A F2(scalar)6.05 E F0(,)A F2 (state)6.05 E F0(,)A F2(undef)6.05 E F0(,)A F2(wantarray)128 679.2 Q F0 (Functions for processes and process groups)108 696 Q F2(alarm)128 708 Q F0(,)A F2(exec)5 E F0(,)A F2(fork)5 E F0(,)A F2(getpgrp)5 E F0(,)A F2 (getppid)5 E F0(,)A F2(getpriority)5 E F0(,)A F2(kill)5 E F0(,)A F2 (pipe)5 E F0(,)A F2(qx//)5 E F0(,)A F2(setpgrp)5 E F0(,)A F2 (setpriority)128 720 Q F0(,)A F2(sleep)2.5 E F0(,)A F2(system)2.5 E F0 (,)A F2(times)2.5 E F0(,)A F2(wait)2.5 E F0(,)A F2(waitpid)2.5 E F0 (perl v5.14.2)72 768 Q 203.17(2011-10-01 2)162.62 F 0 Cg EP %%Page: 3 3 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E -2.15 -.25(Ke y) 108 84 T -.1(wo).25 G(rds related to Perl modules).1 E/F1 10/Courier@0 SF(do)128 96 Q F0(,)A F1(import)2.5 E F0(,)A F1(no)2.5 E F0(,)A F1 (package)2.5 E F0(,)A F1(require)2.5 E F0(,)A F1(use)2.5 E F0 -2.15 -.25 (Ke y)108 112.8 T -.1(wo).25 G (rds related to classes and object-orientation).1 E F1(bless)128 124.8 Q F0(,)A F1(dbmclose)2.5 E F0(,)A F1(dbmopen)2.5 E F0(,)A F1(package)2.5 E F0(,)A F1(ref)2.5 E F0(,)A F1(tie)2.5 E F0(,)A F1(tied)2.5 E F0(,)A F1 (untie)2.5 E F0(,)A F1(use)2.5 E F0(Lo)108 141.6 Q(w-le)-.25 E -.15(ve) -.25 G 2.5(ls).15 G(ock)-2.5 E(et functions)-.1 E F1(accept)128 153.6 Q F0(,)A F1(bind)5.428 E F0(,)A F1(connect)5.428 E F0(,)A F1(getpeername) 5.428 E F0(,)A F1(getsockname)5.429 E F0(,)A F1(getsockopt)5.429 E F0(,) A F1(listen)5.429 E F0(,)A F1(recv)5.429 E F0(,)A F1(send)128 165.6 Q F0 (,)A F1(setsockopt)2.5 E F0(,)A F1(shutdown)2.5 E F0(,)A F1(socket)2.5 E F0(,)A F1(socketpair)2.5 E F0 (System V interprocess communication functions)108 182.4 Q F1(msgctl)128 194.4 Q F0(,)A F1(msgget)3 E F0(,)A F1(msgrcv)3 E F0(,)A F1(msgsnd)3 E F0(,)A F1(semctl)3 E F0(,)A F1(semget)3 E F0(,)A F1(semop)3 E F0(,)A F1 (shmctl)3 E F0(,)A F1(shmget)3 E F0(,)A F1(shmread)3 E F0(,)A F1 (shmwrite)128 206.4 Q F0(Fetching user and group info)108 223.2 Q F1 (endgrent)128 235.2 Q F0(,)A F1(endhostent)6.75 E F0(,)A F1(endnetent) 6.75 E F0(,)A F1(endpwent)6.75 E F0(,)A F1(getgrent)6.75 E F0(,)A F1 (getgrgid)6.75 E F0(,)A F1(getgrnam)6.75 E F0(,)A F1(getlogin)128 247.2 Q F0(,)A F1(getpwent)2.5 E F0(,)A F1(getpwnam)2.5 E F0(,)A F1(getpwuid) 2.5 E F0(,)A F1(setgrent)2.5 E F0(,)A F1(setpwent)2.5 E F0 (Fetching netw)108 264 Q(ork info)-.1 E F1(endprotoent)128 276 Q F0(,)A F1(endservent)14.375 E F0(,)A F1(gethostbyaddr)14.375 E F0(,)A F1 (gethostbyname)14.375 E F0(,)A F1(gethostent)14.375 E F0(,)A F1 (getnetbyaddr)128 288 Q F0(,)A F1(getnetbyname)5.375 E F0(,)A F1 (getnetent)5.375 E F0(,)A F1(getprotobyname)5.375 E F0(,)A F1 (getprotobynumber)5.375 E F0(,)A F1(getprotoent)128 300 Q F0(,)A F1 (getservbyname)14.375 E F0(,)A F1(getservbyport)14.375 E F0(,)A F1 (getservent)14.375 E F0(,)A F1(sethostent)14.375 E F0(,)A F1(setnetent) 128 312 Q F0(,)A F1(setprotoent)2.5 E F0(,)A F1(setservent)2.5 E F0 -.35 (Ti)108 328.8 S(me-related functions).35 E F1(gmtime)128 340.8 Q F0(,)A F1(localtime)2.5 E F0(,)A F1(time)2.5 E F0(,)A F1(times)2.5 E F0 (Functions ne)108 357.6 Q 2.5(wi)-.25 G 2.5(np)-2.5 G(erl5)-2.5 E F1 (abs)128 369.6 Q F0(,)A F1(bless)3.05 E F0(,)A F1(break)3.05 E F0(,)A F1 (chomp)3.05 E F0(,)A F1(chr)3.05 E F0(,)A F1(continue)3.05 E F0(,)A F1 (default)3.05 E F0(,)A F1(exists)3.05 E F0(,)A F1(formline)3.05 E F0(,)A F1(given)3.05 E F0(,)A F1(glob)3.05 E F0(,)A F1(import)128 381.6 Q F0(,) A F1(lc)2.625 E F0(,)A F1(lcfirst)2.625 E F0(,)A F1(lock)2.625 E F0(,)A F1(map)2.625 E F0(,)A F1(my)2.625 E F0(,)A F1(no)2.625 E F0(,)A F1(our) 2.625 E F0(,)A F1(prototype)2.625 E F0(,)A F1(qr//)2.625 E F0(,)A F1 (qw//)2.625 E F0(,)A F1(qx//)2.625 E F0(,)A F1(readline)2.625 E F0(,)A F1(readpipe)128 393.6 Q F0(,)A F1(ref)2.5 E F0(,)A F1(sub)2.5 E F0(*,)A F1(sysopen)2.5 E F0(,)A F1(tie)2.5 E F0(,)A F1(tied)2.5 E F0(,)A F1(uc) 2.5 E F0(,)A F1(ucfirst)2.5 E F0(,)A F1(untie)2.5 E F0(,)A F1(use)2.5 E F0(,)A F1(when)2.5 E F0(*)128 411.6 Q F1(sub)2.5 E F0 -.1(wa)2.5 G 2.5 (sak).1 G -.15(ey)-2.6 G -.1(wo).15 G(rd in Perl 4, b).1 E (ut in Perl 5 it is an operator)-.2 E 2.5(,w)-.4 G (hich can be used in e)-2.5 E(xpressions.)-.15 E (Functions obsoleted in perl5)108 428.4 Q F1(dbmclose)128 440.4 Q F0(,)A F1(dbmopen)2.5 E/F2 10/Times-Bold@0 SF -.2(Po)87 457.2 S(rtability).2 E F0 .316(Perl w)108 469.2 R .317 (as born in Unix and can therefore access all common Unix system calls.) -.1 F .317(In non-Unix en)5.317 F(vironments,)-.4 E 1.018 (the functionality of some Unix system calls may not be a)108 481.2 R -.25(va)-.2 G 1.017(ilable or details of the a).25 F -.25(va)-.2 G 1.017 (ilable functionality).25 F(may dif)108 493.2 Q(fer slightly)-.25 E 5 (.T)-.65 G(he Perl functions af)-5 E(fected by this are:)-.25 E F1 108 510 Q F0(,)A F1(binmode)7.222 E F0(,)A F1(chmod)7.222 E F0(,)A F1 (chown)7.222 E F0(,)A F1(chroot)7.222 E F0(,)A F1(crypt)7.222 E F0(,)A F1(dbmclose)7.222 E F0(,)A F1(dbmopen)7.222 E F0(,)A F1(dump)7.223 E F0 (,)A F1(endgrent)7.223 E F0(,)A F1(endhostent)108 522 Q F0(,)A F1 (endnetent)5.715 E F0(,)A F1(endprotoent)5.715 E F0(,)A F1(endpwent) 5.714 E F0(,)A F1(endservent)5.714 E F0(,)A F1(exec)5.714 E F0(,)A F1 (fcntl)5.714 E F0(,)A F1(flock)5.714 E F0(,)A F1(fork)108 534 Q F0(,)A F1(getgrent)6.083 E F0(,)A F1(getgrgid)6.083 E F0(,)A F1(gethostbyname) 6.083 E F0(,)A F1(gethostent)6.083 E F0(,)A F1(getlogin)6.084 E F0(,)A F1(getnetbyaddr)6.084 E F0(,)A F1(getnetbyname)108 546 Q F0(,)A F1 (getnetent)9 E F0(,)A F1(getppid)9 E F0(,)A F1(getpgrp)9 E F0(,)A F1 (getpriority)9 E F0(,)A F1(getprotobynumber)9 E F0(,)A F1(getprotoent) 108 558 Q F0(,)A F1(getpwent)13.8 E F0(,)A F1(getpwnam)13.8 E F0(,)A F1 (getpwuid)13.8 E F0(,)A F1(getservbyport)13.8 E F0(,)A F1(getservent) 13.8 E F0(,)A F1(getsockopt)108 570 Q F0(,)A F1(glob)4.45 E F0(,)A F1 (ioctl)4.45 E F0(,)A F1(kill)4.45 E F0(,)A F1(link)4.45 E F0(,)A F1 (lstat)4.45 E F0(,)A F1(msgctl)4.45 E F0(,)A F1(msgget)4.45 E F0(,)A F1 (msgrcv)4.45 E F0(,)A F1(msgsnd)4.45 E F0(,)A F1(open)4.45 E F0(,)A F1 (pipe)108 582 Q F0(,)A F1(readlink)6.937 E F0(,)A F1(rename)6.937 E F0 (,)A F1(select)6.937 E F0(,)A F1(semctl)6.937 E F0(,)A F1(semget)6.938 E F0(,)A F1(semop)6.938 E F0(,)A F1(setgrent)6.938 E F0(,)A F1(sethostent) 6.938 E F0(,)A F1(setnetent)108 594 Q F0(,)A F1(setpgrp)3.084 E F0(,)A F1(setpriority)3.084 E F0(,)A F1(setprotoent)3.083 E F0(,)A F1(setpwent) 3.083 E F0(,)A F1(setservent)3.083 E F0(,)A F1(setsockopt)3.083 E F0(,)A F1(shmctl)108 606 Q F0(,)A F1(shmget)5.437 E F0(,)A F1(shmread)5.437 E F0(,)A F1(shmwrite)5.437 E F0(,)A F1(socket)5.437 E F0(,)A F1 (socketpair)5.438 E F0(,)A F1(stat)5.438 E F0(,)A F1(symlink)5.438 E F0 (,)A F1(syscall)5.438 E F0(,)A F1(sysopen)108 618 Q F0(,)A F1(system)2.5 E F0(,)A F1(times)2.5 E F0(,)A F1(truncate)2.5 E F0(,)A F1(umask)2.5 E F0(,)A F1(unlink)2.5 E F0(,)A F1(utime)2.5 E F0(,)A F1(wait)2.5 E F0(,)A F1(waitpid)2.5 E F0 -.15(Fo)108 634.8 S 3.782(rm).15 G 1.281(ore inform\ ation about the portability of these functions, see perlport and other \ a)-3.782 F -.25(va)-.2 G 1.281(ilable platform-).25 F (speci\214c documentation.)108 646.8 Q F2(Alphabetical Listing of P)87 663.6 Q(erl Functions)-.2 E F0108 675.6 Q/F3 9/Times-Roman@0 SF (FILEHANDLE)2.5 E F0108 687.6 Q F3(EXPR)2.5 E F0108 699.6 Q F3(DIRHANDLE)2.5 E F0108 711.6 Q 2.715<418c>128 711.6 S .215 (le test, where X is one of the letters listed belo)-2.715 F 4.015 -.65 (w. T)-.25 H .215(his unary operator tak).65 F .216(es one ar)-.1 F .216 (gument, either a)-.18 F .638(\214lename, a \214lehandle, or a dirhandl\ e, and tests the associated \214le to see if something is true about it\ .)128 723.6 R(perl v5.14.2)72 768 Q 203.17(2011-10-01 3)162.62 F 0 Cg EP %%Page: 4 4 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .18(If the ar)128 84 R .181(gument is omitted, tests)-.18 F/F1 10/Courier@0 SF($_)2.681 E F0 2.681(,e)C .181(xcept for)-2.831 F F12.681 E F0 2.681(,w)C .181 (hich tests)-2.681 F/F2 9/Times-Roman@0 SF(STDIN)2.681 E F0 5.181(.U)C .181(nless otherwise documented,)-5.181 F .231(it returns)128 96 R F1(1) 2.731 E F0 .231(for true and)2.731 F F1<0808>2.731 E F0 .231(for f)2.731 F .231(alse, or the unde\214ned v)-.1 F .231(alue if the \214le doesn') -.25 F 2.731(te)-.18 G 2.731(xist. Despite)-2.881 F .231(the funn)2.731 F(y)-.15 E(names, precedence is the same as an)128 108 Q 2.5(yo)-.15 G (ther named unary operator)-2.5 E 5(.T)-.55 G(he operator may be an)-5 E 2.5(yo)-.15 G(f:)-2.5 E F1 6(\255r File)152 126 R (is readable by effective uid/gid.)6 E 6(\255w File)152 138 R (is writable by effective uid/gid.)6 E 6(\255x File)152 150 R (is executable by effective uid/gid.)6 E 6(\255o File)152 162 R (is owned by effective uid.)6 E 6(\255R File)152 186 R (is readable by real uid/gid.)6 E 6(\255W File)152 198 R (is writable by real uid/gid.)6 E 6(\255X File)152 210 R (is executable by real uid/gid.)6 E 6(\255O File)152 222 R (is owned by real uid.)6 E 6(\255e File)152 246 R(exists.)6 E 6 (\255z File)152 258 R(has zero size \(is empty\).)6 E 6(\255s File)152 270 R(has nonzero size \(returns size in bytes\).)6 E 6(\255f File)152 294 R(is a plain file.)6 E 6(\255d File)152 306 R(is a directory.)6 E 6 (\255l File)152 318 R(is a symbolic link.)6 E 6(\255p File)152 330 R (is a named pipe \(FIFO\), or Filehandle is a pipe.)6 E 6(\255S File)152 342 R(is a socket.)6 E 6(\255b File)152 354 R(is a block special file.)6 E 6(\255c File)152 366 R(is a character special file.)6 E 6 (\255t Filehandle)152 378 R(is opened to a tty.)6 E 6(\255u File)152 402 R(has setuid bit set.)6 E 6(\255g File)152 414 R(has setgid bit set.)6 E 6(\255k File)152 426 R(has sticky bit set.)6 E 6(\255T File)152 450 R (is an ASCII text file \(heuristic guess\).)6 E 6(\255B File)152 462 R (is a "binary" file \(opposite of \255T\).)6 E 6(\255M Script)152 486 R (start time minus file modification time, in days.)6 E 6(\255A Same)152 498 R(for access time.)6 E 6(\255C Same)152 510 R (for inode change time \(Unix, may differ for other platforms\))6 E F0 (Example:)128 528 Q F1(while \(<>\) {)152 546 Q(chomp;)176 558 Q (next unless \255f $_;)176 570 Q 6(#i)12 G(gnore specials)-6 E(#...)176 582 Q(})152 594 Q F0 3.036(Note that)128 612 R F1(\255s/a/b/)5.536 E F0 3.036(does not do a ne)5.536 F -.05(ga)-.15 G 3.036(ted substitution.) .05 F(Saying)8.036 E F1(\255exp\($foo\))5.536 E F0 3.037(still w)5.536 F 3.037(orks as)-.1 F -.15(ex)128 624 S(pected, ho).15 E(we)-.25 E -.15 (ve)-.25 G(r: only single letters follo).15 E (wing a minus are interpreted as \214le tests.)-.25 E .164 (These operators are e)128 642 R -.15(xe)-.15 G .163(mpt from the `).15 F .163(`looks lik)-.74 F 2.663(eaf)-.1 G .163(unction rule')-2.663 F 2.663('d)-.74 G .163(escribed abo)-2.663 F -.15(ve)-.15 G 2.663(.T).15 G .163(hat is, an opening)-2.663 F 3.019 (parenthesis after the operator does not af)128 654 R 3.019(fect ho)-.25 F 5.519(wm)-.25 G 3.019(uch of the follo)-5.519 F 3.02 (wing code constitutes the)-.25 F(ar)128 666 Q .797(gument. Put the ope\ ning parentheses before the operator to separate it from code that foll\ o)-.18 F .796(ws \(this)-.25 F(applies only to operators with higher pr\ ecedence than unary operators, of course\):)128 678 Q F1 (\255s\($file\) + 1024)152 696 Q 6(#p)18 G (robably wrong; same as \255s\($file + 1024\))-6 E (\(\255s $file\) + 1024)152 708 Q 6(#c)12 G(orrect)-6 E F0 1.152 (The interpretation of the \214le permission operators)128 726 R F1 3.652 E F0(,)A F13.652 E F0(,)A F13.652 E F0(,)A F1 3.652 E F0(,)A F13.652 E F0 3.653(,a)C(nd)-3.653 E F1 3.653 E F0 1.153(is by def)3.653 F 1.153(ault based)-.1 F(perl v5.14.2) 72 768 Q 203.17(2011-10-01 4)162.62 F 0 Cg EP %%Page: 5 5 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .305 (solely on the mode of the \214le and the uids and gids of the user)128 84 R 5.305(.T)-.55 G .305(here may be other reasons you can')-5.305 F(t) -.18 E .356(actually read, write, or e)128 96 R -.15(xe)-.15 G .356 (cute the \214le: for e).15 F .357(xample netw)-.15 F .357 (ork \214lesystem access controls, A)-.1 F .357(CLs \(access)-.4 F .674 (control lists\), read-only \214lesystems, and unrecognized e)128 108 R -.15(xe)-.15 G .674(cutable formats.).15 F .674 (Note that the use of these)5.674 F .984(six speci\214c operators to v) 128 120 R .985(erify if some operation is possible is usually a mistak) -.15 F .985(e, because it may be)-.1 F(open to race conditions.)128 132 Q .063 (Also note that, for the superuser on the local \214lesystems, the)128 150 R/F1 10/Courier@0 SF2.563 E F0(,)A F12.563 E F0(,)A F1 2.562 E F0 2.562(,a)C(nd)-2.562 E F12.562 E F0 .062 (tests al)2.562 F -.1(wa)-.1 G .062(ys return 1,).1 F(and)128 162 Q F1 3.261 E F0(and)3.261 E F13.262 E F0 .762(return 1 if an) 3.262 F 3.262(ye)-.15 G -.15(xe)-3.412 G .762 (cute bit is set in the mode.).15 F .762 (Scripts run by the superuser may thus)5.762 F 1.108(need to do a)128 174 R/F2 10/Times-Italic@0 SF(stat\(\))3.608 E F0 1.108(to determine th\ e actual mode of the \214le, or temporarily set their ef)3.608 F(fecti) -.25 E 1.407 -.15(ve u)-.25 H 1.107(id to).15 F(something else.)128 186 Q .818(If you are using A)128 204 R .819(CLs, there is a pragma called) -.4 F F1(filetest)3.319 E F0 .819 (that may produce more accurate results)3.319 F 1.965(than the bare)128 216 R F2(stat\(\))4.464 E F0 1.964(mode bits.)4.464 F 1.964(When under) 6.964 F F1 1.964(use filetest \010access\010)4.464 F F0 1.964(the abo) 4.464 F -.15(ve)-.15 G(-mentioned).15 E 1.087(\214letests test whether \ the permission can\(not\) be granted using the)128 228 R F2(access)3.587 E F0 1.087(\(2\) f)1.666 F 1.087(amily of system calls.)-.1 F 2.464 (Also note that the)128 240 R F14.964 E F0(and)4.964 E F1 4.964 E F0 2.463(may under this pragma return true e)4.963 F -.15(ve) -.25 G 4.963(ni).15 G 4.963(ft)-4.963 G 2.463(here are no e)-4.963 F -.15(xe)-.15 G(cute).15 E 3.272(permission bits set \(nor an)128 252 R 5.773(ye)-.15 G 3.273(xtra e)-5.923 F -.15(xe)-.15 G 3.273 (cute permission A).15 F 5.773(CLs\). This)-.4 F 3.273 (strangeness is due to the)5.773 F 1.069(underlying system calls' de\ \214nitions. Note also that, due to the implementation of)128 264 R F1 1.069(use filetest)3.569 F(\010access\010)128 276 Q F0 3.545(,t)C(he) -3.545 E F1(_)3.545 E F0 1.045(special \214lehandle w)3.545 F(on')-.1 E 3.545(tc)-.18 G 1.045 (ache the results of the \214le tests when this pragma is in)-3.545 F (ef)128 288 Q 2.5(fect. Read)-.25 F(the documentation for the)2.5 E F1 (filetest)2.5 E F0(pragma for more information.)2.5 E(The)128 306 Q F1 4.427 E F0(and)4.427 E F14.427 E F0 1.927(switches w)4.427 F 1.927(ork as follo)-.1 F 4.426(ws. The)-.25 F 1.926 (\214rst block or so of the \214le is e)4.426 F 1.926(xamined for odd) -.15 F 1.945(characters such as strange control codes or characters wit\ h the high bit set.)128 318 R 1.946(If too man)6.946 F 4.446(ys)-.15 G (trange)-4.446 E .884(characters \(>30%\) are found, it')128 330 R 3.384 (sa)-.55 G F1A F0 .884(\214le; otherwise it')3.384 F 3.384(sa)-.55 G F1A F0 3.384(\214le. Also,)3.384 F(an)3.384 E 3.384<798c>-.15 G .883(le containing a zero)-3.384 F .778 (byte in the \214rst block is considered a binary \214le.)128 342 R(If) 5.778 E F13.278 E F0(or)3.278 E F13.278 E F0 .778 (is used on a \214lehandle, the current)3.278 F/F3 9/Times-Roman@0 SF (IO)3.278 E F0 -.2(bu)128 354 S -.25(ff).2 G .228(er is e).25 F .227 (xamined rather than the \214rst block.)-.15 F(Both)5.227 E F1 2.727 E F0(and)2.727 E F12.727 E F0 .227 (return true on an empty \214le, or a \214le at)2.727 F F3(EOF)128 366 Q F0 .763(when testing a \214lehandle.)3.263 F .763(Because you ha)5.763 F 1.064 -.15(ve t)-.2 H 3.264(or).15 G .764(ead a \214le to do the)-3.264 F F13.264 E F0 .764(test, on most occasions)3.264 F(you w)128 378 Q(ant to use a)-.1 E F12.5 E F0(ag)2.5 E (ainst the \214le \214rst, as in)-.05 E F1 (next unless \255f $file && \255T $file)2.5 E F0(.)A .047(If an)128 396 R 2.547(yo)-.15 G 2.546(ft)-2.547 G .046 (he \214le tests \(or either the)-2.546 F F1(stat)2.546 E F0(or)2.546 E F1(lstat)2.546 E F0 .046(operator\) is gi)2.546 F -.15(ve)-.25 G 2.546 (nt).15 G .046(he special \214lehandle consisting)-2.546 F .088 (of a solitary underline, then the stat structure of the pre)128 408 R .089(vious \214le test \(or stat operator\) is used, sa)-.25 F .089 (ving a)-.2 F .049(system call.)128 420 R .049(\(This doesn')5.049 F 2.549(tw)-.18 G .049(ork with)-2.649 F F12.549 E F0 2.549(,a)C .049(nd you need to remember that)-2.549 F F2(lstat\(\))2.549 E F0(and) 2.549 E F12.549 E F0(lea)2.549 E .348 -.15(ve v)-.2 H .048 (alues in)-.1 F 1.438 (the stat structure for the symbolic link, not the real \214le.\))128 432 R 1.438(\(Also, if the stat b)6.438 F(uf)-.2 E 1.438(fer w)-.25 F 1.438(as \214lled by an)-.1 F F1(lstat)128 444 Q F0(call,)2.5 E F1 2.5 E F0(and)2.5 E F12.5 E F0(will reset it with the results of) 2.5 E F1(stat _)2.5 E F0 2.5(\). Example:)B F1 (print "Can do.\\n" if \255r $a || \255w _ || \255x _;)152 462 Q (stat\($filename\);)152 486 Q(print "Readable\\n" if \255r _;)152 498 Q (print "Writable\\n" if \255w _;)152 510 Q (print "Executable\\n" if \255x _;)152 522 Q (print "Setuid\\n" if \255u _;)152 534 Q(print "Setgid\\n" if \255g _;) 152 546 Q(print "Sticky\\n" if \255k _;)152 558 Q (print "Text\\n" if \255T _;)152 570 Q(print "Binary\\n" if \255B _;)152 582 Q F0 .215(As of Perl 5.9.1, as a form of purely syntactic sug)128 600 R(ar)-.05 E 2.715(,y)-.4 G .215 (ou can stack \214le test operators, in a w)-2.715 F .214(ay that)-.1 F F12.714 E .151(\255w \255x $file)128 612 R F0 .151(is equi)2.651 F -.25(va)-.25 G .151(lent to).25 F F1 .151 (\255x $file && \255w _ && \255f _)2.651 F F0 2.651(.\()C .151 (This is only f)-2.651 F(anc)-.1 E 2.651(yf)-.15 G(anc)-2.751 E .151 (y: if you)-.15 F .697(use the return v)128 624 R .697(alue of)-.25 F F1 .697(\255f $file)3.197 F F0 .697(as an ar)3.197 F .696 (gument to another \214letest operator)-.18 F 3.196(,n)-.4 G 3.196(os) -3.196 G .696(pecial magic will)-3.196 F(happen.\))128 636 Q(abs)108 652.8 Q F3 -1.215(VA)2.5 G(LUE)1.215 E F0(abs)108 664.8 Q (Returns the absolute v)128 664.8 Q(alue of its ar)-.25 E 2.5 (gument. If)-.18 F F3 -1.215(VA)2.5 G(LUE)1.215 E F0(is omitted, uses) 2.5 E F1($_)2.5 E F0(.)A(accept)108 681.6 Q F3(NEWSOCKET)2.5 E F0 (,GENERICSOCKET)A 2.841(Accepts an incoming sock)128 693.6 R 2.841 (et connect, just as)-.1 F F2(accept)5.341 E F0 2.841(\(2\) does.)1.666 F 2.841(Returns the pack)7.841 F 2.841(ed address if it)-.1 F (succeeded, f)128 705.6 Q(alse otherwise.)-.1 E(See the e)5 E (xample in `)-.15 E(`Sock)-.74 E(ets: Client/Serv)-.1 E (er Communication')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E 1.179(On systems that support a close-on-e)128 723.6 R -.15(xe)-.15 G 3.679<638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.679 F 1.178(wly opened \214le)-.25 F(perl v5.14.2)72 768 Q 203.17 (2011-10-01 5)162.62 F 0 Cg EP %%Page: 6 6 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(descriptor)128 84 Q 2.5(,a)-.4 G 2.5(sd)-2.5 G(etermined by the v)-2.5 E(alue of $^F)-.25 E 5(.S)-.8 G(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv) -2.5 E(ar)-.25 E(.)-.55 E(alarm)108 100.8 Q/F1 9/Times-Roman@0 SF (SECONDS)2.5 E F0(alarm)108 112.8 Q .144(Arranges to ha)128 124.8 R .444 -.15(ve a)-.2 H F1(SIGALRM)2.794 E F0(deli)2.644 E -.15(ve)-.25 G .144 (red to this process after the speci\214ed number of w).15 F .144 (allclock seconds)-.1 F 2.265(has elapsed.)128 136.8 R(If)7.265 E F1 (SECONDS)4.765 E F0 2.265(is not speci\214ed, the v)4.765 F 2.265 (alue stored in)-.25 F/F2 10/Courier@0 SF($_)4.765 E F0 2.264 (is used. \(On some machines,)4.765 F(unfortunately)128 148.8 Q 3.411 (,t)-.65 G .912(he elapsed time may be up to one second less or more th\ an you speci\214ed because of)-3.411 F(ho)128 160.8 Q 2.5(ws)-.25 G (econds are counted, and process scheduling may delay the deli)-2.5 E -.15(ve)-.25 G(ry of the signal e).15 E -.15(ve)-.25 G 2.5(nf).15 G (urther)-2.5 E(.\))-.55 E .368(Only one timer may be counting at once.) 128 178.8 R .368(Each call disables the pre)5.368 F .368(vious timer) -.25 F 2.868(,a)-.4 G .367(nd an ar)-2.868 F .367(gument of)-.18 F F2(0) 2.867 E F0 1.064(may be supplied to cancel the pre)128 190.8 R 1.064 (vious timer without starting a ne)-.25 F 3.564(wo)-.25 G 3.564(ne. The) -3.564 F 1.064(returned v)3.564 F 1.065(alue is the)-.25 F (amount of time remaining on the pre)128 202.8 Q(vious timer)-.25 E(.) -.55 E -.15(Fo)128 220.8 S 3.844(rd).15 G 1.344 (elays of \214ner granularity than one second, the T)-3.844 F 1.344 (ime::HiRes module \(from)-.35 F F1(CP)3.844 E(AN)-.828 E F0 3.844(,a)C 1.343(nd starting)-3.844 F 1.802 (from Perl 5.8 part of the standard distrib)128 232.8 R 1.802 (ution\) pro)-.2 F(vides)-.15 E/F3 10/Times-Italic@0 SF(ualarm\(\))4.302 E F0 6.802(.Y)C 1.802(ou may also use Perl')-7.902 F 4.302(sf)-.55 G (our)-4.302 E(-)-.2 E(ar)128 244.8 Q .816(gument v)-.18 F .816 (ersion of)-.15 F F3(select\(\))3.316 E F0(lea)3.316 E .816 (ving the \214rst three ar)-.2 F .815 (guments unde\214ned, or you might be able to use)-.18 F(the)128 256.8 Q F2(syscall)2.5 E F0(interf)2.5 E(ace to access)-.1 E F3(setitimer)2.5 E F0(\(2\) if your system supports it. See perlf)1.666 E(aq8 for details.) -.1 E 2.253(It is usually a mistak)128 274.8 R 4.753(et)-.1 G 4.753(oi) -4.753 G(ntermix)-4.753 E F2(alarm)4.753 E F0(and)4.753 E F2(sleep)4.753 E F0 2.254(calls, because)4.753 F F2(sleep)4.754 E F0 2.254 (may be internally)4.754 F(implemented on your system with)128 286.8 Q F2(alarm)2.5 E F0(.)A .081(If you w)128 304.8 R .081(ant to use)-.1 F F2 (alarm)2.581 E F0 .081(to time out a system call you need to use an) 2.581 F F2(eval)2.581 E F0(/)A F2(die)A F0(pair)2.581 E 5.081(.Y)-.55 G .081(ou can')-6.181 F 2.58(tr)-.18 G(ely)-2.58 E .227 (on the alarm causing the system call to f)128 316.8 R .227(ail with)-.1 F F2($!)2.727 E F0 .227(set to)2.727 F F2(EINTR)2.727 E F0 .227 (because Perl sets up signal handlers)2.727 F .22 (to restart system calls on some systems.)128 328.8 R(Using)5.22 E F2 (eval)2.72 E F0(/)A F2(die)A F0(al)2.72 E -.1(wa)-.1 G .22(ys w).1 F .22 (orks, modulo the ca)-.1 F -.15(ve)-.2 G .22(ats gi).15 F -.15(ve)-.25 G 2.72(ni).15 G(n)-2.72 E -.74(``)128 340.8 S(Signals').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E F2(eval {)152 358.8 Q (local $SIG{ALRM} = sub { die "alarm\\n" }; # NB: \\n required)176 370.8 Q(alarm $timeout;)176 382.8 Q($nread = sysread SOCKET, $buffer, $size;) 176 394.8 Q(alarm 0;)176 406.8 Q(};)152 418.8 Q(if \($@\) {)152 430.8 Q (die unless $@ eq "alarm\\n";)176 442.8 Q 6(#p)18 G (ropagate unexpected errors)-6 E 6(#t)176 454.8 S(imed out)-6 E(})152 466.8 Q(else {)152 478.8 Q 6(#d)176 490.8 S(idn\010t)-6 E(})152 502.8 Q F0 -.15(Fo)128 520.8 S 2.5(rm).15 G(ore information see perlipc.)-2.5 E (atan2 Y)108 537.6 Q(,X)-1.29 E (Returns the arctangent of Y/X in the range \255PI to)128 549.6 Q F1(PI) 2.5 E F0(.)A -.15(Fo)128 567.6 S 5.176(rt).15 G 2.676 (he tangent operation, you may use the)-5.176 F F2(Math::Trig::tan)5.176 E F0 2.676(function, or use the f)5.176 F(amiliar)-.1 E(relation:)128 579.6 Q F2(sub tan { sin\($_[0]\) / cos\($_[0]\))152 597.6 Q(})12 E F0 1.447(The return v)128 615.6 R 1.447(alue for)-.25 F F2(atan2\(0,0\)) 3.947 E F0 1.447(is implementation-de\214ned; consult your)3.947 F F3 (atan2)3.946 E F0 1.446(\(3\) manpage for)1.666 F(more information.)128 627.6 Q(bind)108 644.4 Q F1(SOCKET)2.5 E F0(,N)A(AME)-.35 E 2.717 (Binds a netw)128 656.4 R 2.717(ork address to a sock)-.1 F 2.717 (et, just as)-.1 F F3(bind)5.217 E F0 2.717(\(2\) does.)1.666 F 2.717 (Returns true if it succeeded, f)7.717 F(alse)-.1 E(otherwise.)128 668.4 Q F1 -.315(NA)5.079 G(ME).315 E F0 .079(should be a pack)2.579 F .079 (ed address of the appropriate type for the sock)-.1 F 2.578(et. See)-.1 F .078(the e)2.578 F(xamples)-.15 E(in `)128 680.4 Q(`Sock)-.74 E (ets: Client/Serv)-.1 E(er Communication')-.15 E 2.5('i)-.74 G 2.5(np) -2.5 G(erlipc.)-2.5 E(binmode)108 697.2 Q F1(FILEHANDLE)2.5 E F0(,)A F1 (LA)2.5 E(YER)-.945 E F0(perl v5.14.2)72 768 Q 203.17(2011-10-01 6) 162.62 F 0 Cg EP %%Page: 7 7 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(binmode)108 84 Q /F1 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0 .992(Arranges for)128 96 R F1 (FILEHANDLE)3.492 E F0 .992(to be read or written in `)3.492 F(`binary') -.74 E 3.493('o)-.74 G 3.493(r`)-3.493 G(`te)-4.233 E(xt')-.15 E 3.493 ('m)-.74 G .993(ode on systems where the)-3.493 F 1.728 (run-time libraries distinguish between binary and te)128 108 R 1.728 (xt \214les.)-.15 F(If)6.728 E F1(FILEHANDLE)4.228 E F0 1.727(is an e) 4.228 F 1.727(xpression, the)-.15 F -.25(va)128 120 S .403(lue is tak) .25 F .403(en as the name of the \214lehandle.)-.1 F .404 (Returns true on success, otherwise it returns)5.404 F/F2 10/Courier@0 SF(undef)2.904 E F0(and)2.904 E(sets)128 132 Q F2($!)2.5 E F0 (\(errno\).)2.5 E .098(On some systems \(in general,)128 150 R F1 (DOS\255)2.597 E F0 .097(and W)2.597 F(indo)-.4 E .097 (ws-based systems\))-.25 F/F3 10/Times-Italic@0 SF(binmode\(\))2.597 E F0 .097(is necessary when you')2.597 F(re)-.5 E 1.914(not w)128 162 R 1.914(orking with a te)-.1 F 1.914(xt \214le.)-.15 F -.15(Fo)6.914 G 4.414(rt).15 G 1.914(he sak)-4.414 F 4.414(eo)-.1 G 4.414(fp)-4.414 G 1.914(ortability it is a good idea al)-4.414 F -.1(wa)-.1 G 1.914 (ys to use it when).1 F 1.598(appropriate, and ne)128 174 R -.15(ve)-.25 G 4.098(rt).15 G 4.098(ou)-4.098 G 1.598(se it when it isn')-4.098 F 4.098(ta)-.18 G 4.098(ppropriate. Also,)-4.098 F 1.597 (people can set their I/O to be by)4.098 F(def)128 186 Q (ault UTF8\255encoded Unicode, not bytes.)-.1 E(In other w)128 204 Q (ords: re)-.1 E -.05(ga)-.15 G(rdless of platform, use).05 E F3 (binmode\(\))2.5 E F0(on binary data, lik)2.5 E 2.5(ei)-.1 G (mages, for e)-2.5 E(xample.)-.15 E(If)128 222 Q F1(LA)3.371 E(YER)-.945 E F0 .871(is present it is a single string, b)3.371 F .872 (ut may contain multiple directi)-.2 F -.15(ve)-.25 G .872 (s. The directi).15 F -.15(ve)-.25 G 3.372(sa).15 G .872(lter the)-3.372 F(beha)128 234 Q(viour of the \214lehandle.)-.2 E(When)5 E F1(LA)2.5 E (YER)-.945 E F0(is present, using binmode on a te)2.5 E(xt \214le mak) -.15 E(es sense.)-.1 E(If)128 252 Q F1(LA)2.8 E(YER)-.945 E F0 .3 (is omitted or speci\214ed as)2.8 F F2(:raw)2.8 E F0 .3 (the \214lehandle is made suitable for passing binary data. This)2.8 F 2.602(includes turning of)128 264 R 5.103(fp)-.25 G(ossible)-5.103 E F1 (CRLF)5.103 E F0 2.603 (translation and marking it as bytes \(as opposed to Unicode)5.103 F 2.993(characters\). Note)128 276 R .493 (that, despite what may be implied in)2.993 F F3 -1.11(``)2.993 G(Pr) 1.11 E -.1(og)-.45 G -.15(ra).1 G .493(mming P).15 F(erl')-.8 E(')-1.11 E F0 .492(\(the Camel, 3rd edition\))2.993 F 1.253(or else)128 288 R (where,)-.25 E F2(:raw)3.753 E F0(is)3.753 E F3(not)3.753 E F0 1.253 (simply the in)3.753 F -.15(ve)-.4 G 1.253(rse of).15 F F2(:crlf)3.753 E F0 6.253(.O)C 1.253(ther layers that w)-6.253 F 1.253(ould af)-.1 F 1.254(fect the binary)-.25 F 1.89(nature of the stream are)128 300 R F3 (also)4.39 E F0 1.889 (disabled. See PerlIO, perlrun, and the discussion about the)4.389 F F1 (PERLIO)4.389 E F0(en)128 312 Q(vironment v)-.4 E(ariable.)-.25 E(The) 128 330 Q F2(:bytes)2.774 E F0(,)A F2(:crlf)2.774 E F0(,)A F2(:utf8) 2.774 E F0 2.774(,a)C .274(nd an)-2.774 F 2.774(yo)-.15 G .274 (ther directi)-2.774 F -.15(ve)-.25 G 2.774(so).15 G 2.774(ft)-2.774 G .274(he form)-2.774 F F2(:...)2.775 E F0 2.775(,a)C .275(re called I/O) -2.775 F F3(layer)2.775 E(s)-.1 E F0 5.275(.T)C(he)-5.275 E F2(open)128 342 Q F0(pragma can be used to establish def)2.5 E(ault I/O layers.)-.1 E(See open.)5 E F3(The)128 360 Q/F4 9/Times-Italic@0 SF(LA)2.647 E(YER) -.495 E F3(par)2.647 E .146 (ameter of the binmode\(\) function is described as `)-.15 F(`)-1.11 E F4(DISCIPLINE)A F3 2.366 -1.11('' i)D 2.646(n`)1.11 G(`Pr)-3.756 E -.1 (og)-.45 G -.15(ra).1 G .146(mming P).15 F(erl,)-.8 E(3r)128 372 Q 4.996 (dE)-.37 G(dition')-4.996 E 4.996('. Howe)-1.11 F(ver)-.15 E 4.996(,s) -1.11 G 2.497(ince the publishing of this book, by many known as `) -4.996 F(`Camel)-1.11 E F4(III)4.997 E F3 -1.11('')C 4.997(,t)1.11 G(he) -4.997 E 3.98(consensus of the naming of this functionality has mo)128 384 R 3.98(ved fr)-.1 F 3.98(om `)-.45 F(`discipline')-1.11 E 6.48('t) -1.11 G 6.48(o`)-6.48 G(`layer')-7.59 E 6.48('. All)-1.11 F .868 (documentation of this ver)128 396 R .868(sion of P)-.1 F .868(erl ther) -.8 F(efor)-.37 E 3.369(er)-.37 G(efer)-3.739 E 3.369(st)-.1 G 3.369(o`) -3.369 G(`layer)-4.479 E(s')-.1 E 3.369('r)-1.11 G .869(ather than to `) -3.519 F(`disciplines')-1.11 E 3.369('. Now)-1.11 F(bac)128 408 Q 2.5 (kt)-.2 G 2.5(ot)-2.5 G(he r)-2.5 E -.4(eg)-.37 G(ularly sc).4 E (heduled documentation...)-.15 E F0 1.971 -.8(To m)128 426 T(ark).8 E F1 (FILEHANDLE)2.871 E F0(as)2.871 E F1(UTF\2558)2.871 E F0 2.87(,u)C(se) -2.87 E F2(:utf8)2.87 E F0(or)2.87 E F2(:encoding\(UTF\2558\))2.87 E F0 (.)A F2(:utf8)5.37 E F0 .37(just marks the data)2.87 F(as)128 438 Q F1 (UTF\2558)3.406 E F0 .906(without further checking, while)3.406 F F2 (:encoding\(UTF\2558\))3.406 E F0 .906 (checks the data for actually being)3.406 F -.25(va)128 450 S(lid).25 E F1(UTF\2558)2.5 E F0 2.5(.M)C (ore details can be found in PerlIO::encoding.)-2.5 E 1.889(In general,) 128 468 R F3(binmode\(\))4.389 E F0 1.889(should be called after)4.389 F F3(open\(\))4.389 E F0 -.2(bu)4.389 G 4.389(tb).2 G 1.889(efore an) -4.389 F 4.389(yI)-.15 G 1.888(/O is done on the \214lehandle.)-4.389 F (Calling)128 480 Q F3(binmode\(\))2.597 E F0 .097(normally \215ushes an) 2.597 F 2.598(yp)-.15 G .098(ending b)-2.598 F(uf)-.2 E .098 (fered output data \(and perhaps pending input data\))-.25 F 2.055 (on the handle.)128 492 R 2.055(An e)7.055 F 2.055 (xception to this is the)-.15 F F2(:encoding)4.555 E F0 2.054 (layer that changes the def)4.555 F 2.054(ault character)-.1 F 1.062 (encoding of the handle; see `)128 504 R(`open')-.74 E 3.563('. The)-.74 F F2(:encoding)3.563 E F0 1.063 (layer sometimes needs to be called in mid-)3.563 F .947 (stream, and it doesn')128 516 R 3.447<748d>-.18 G .946(ush the stream.) -3.447 F(The)5.946 E F2(:encoding)3.446 E F0 .946 (also implicitly pushes on top of itself the)3.446 F F2(:utf8)128 528 Q F0(layer because internally Perl operates on UTF8\255encoded Unicode ch\ aracters.)2.5 E 1.772(The operating system, de)128 546 R 1.772(vice dri) -.25 F -.15(ve)-.25 G 1.773 (rs, C libraries, and Perl run-time system all conspire to let the).15 F .275(programmer treat a single character \()128 558 R F2(\\n)A F0 2.775 (\)a)C 2.775(st)-2.775 G .275(he line terminator)-2.775 F 2.774(,i)-.4 G (rrespecti)-2.774 E .574 -.15(ve o)-.25 H 2.774(fe).15 G .274 (xternal representation.)-2.924 F .42(On man)128 570 R 2.92(yo)-.15 G .42(perating systems, the nati)-2.92 F .72 -.15(ve t)-.25 H -.15(ex).15 G 2.92<748c>.15 G .42 (le representation matches the internal representation, b)-2.92 F(ut)-.2 E(on some platforms the e)128 582 Q(xternal representation of)-.15 E F2 (\\n)2.5 E F0(is made up of more than one character)2.5 E(.)-.55 E .068 (All v)128 600 R .068(ariants of Unix, Mac)-.25 F F1(OS)2.568 E F0 .068 (\(old and ne)2.568 F .068(w\), and Stream_LF \214les on)-.25 F F1(VMS) 2.567 E F0 .067(use a single character to end)2.567 F 2.454 (each line in the e)128 612 R 2.454(xternal representation of te)-.15 F 2.454(xt \(e)-.15 F -.15(ve)-.25 G 4.954(nt).15 G 2.455 (hough that single character is)-4.954 F F1(CARRIA)4.955 E(GE)-.36 E (RETURN)128 624 Q F0 .799(on old, pre-Darwin \215a)3.299 F -.2(vo)-.2 G .799(rs of Mac).2 F F1(OS)3.299 E F0 3.299(,a)C .799(nd is)-3.299 F F1 1.049(LINE FEED)3.299 F F0 .799(on Unix and most)3.299 F F1(VMS)3.299 E F0 .799(\214les\). In)3.299 F .813(other systems lik)128 636 R(e)-.1 E F1(OS/2)3.314 E F0(,)A F1(DOS)3.314 E F0 3.314(,a)C .814(nd the v)-3.314 F .814(arious \215a)-.25 F -.2(vo)-.2 G .814(rs of MS-W).2 F(indo)-.4 E .814(ws, your program sees a)-.25 F F2(\\n)3.314 E F0 .814(as a)3.314 F (simple)128 648 Q F2(\\cJ)3.621 E F0 3.621(,b)C 1.121(ut what')-3.821 F 3.621(ss)-.55 G 1.121(tored in te)-3.621 F 1.121(xt \214les are the tw) -.15 F 3.62(oc)-.1 G(haracters)-3.62 E F2(\\cM\\cJ)3.62 E F0 6.12(.T)C 1.12(hat means that if you)-6.12 F(don')128 660 Q 3.249(tu)-.18 G(se) -3.249 E F3(binmode\(\))3.249 E F0 .749(on these systems,)3.249 F F2 (\\cM\\cJ)3.249 E F0 .749(sequences on disk will be con)3.249 F -.15(ve) -.4 G .75(rted to).15 F F2(\\n)3.25 E F0 .75(on input,)3.25 F .358 (and an)128 672 R(y)-.15 E F2(\\n)2.858 E F0 .358 (in your program will be con)2.858 F -.15(ve)-.4 G .357(rted back to).15 F F2(\\cM\\cJ)2.857 E F0 .357(on output.)2.857 F .357 (This is what you w)5.357 F .357(ant for)-.1 F(te)128 684 Q (xt \214les, b)-.15 E(ut it can be disastrous for binary \214les.)-.2 E .274(Another consequence of using)128 702 R F3(binmode\(\))2.774 E F0 .274(\(on some systems\) is that special end-of-\214le mark)2.774 F .275 (ers will be)-.1 F .36(seen as part of the data stream.)128 714 R -.15 (Fo)5.36 G 2.86(rs).15 G .359(ystems from the Microsoft f)-2.86 F .359 (amily this means that, if your binary)-.1 F(data contain)128 726 Q F2 (\\cZ)2.5 E F0 2.5(,t)C(he I/O subsystem will re)-2.5 E -.05(ga)-.15 G (rd it as the end of the \214le, unless you use).05 E F3(binmode\(\))2.5 E F0(.)A(perl v5.14.2)72 768 Q 203.17(2011-10-01 7)162.62 F 0 Cg EP %%Page: 8 8 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10 /Times-Italic@0 SF(binmode\(\))128 84 Q F0 1.76 (is important not only for)4.26 F F1 -.37(re)4.261 G(adline\(\)).37 E F0 (and)4.261 E F1(print\(\))4.261 E F0 1.761(operations, b)4.261 F 1.761 (ut also when using)-.2 F F1 -.37(re)4.261 G(ad\(\)).37 E F0(,)A F1 (seek\(\))128 96 Q F0(,)A F1(sysr)3.115 E(ead\(\))-.37 E F0(,)A F1 (syswrite\(\))3.115 E F0(and)3.115 E F1(tell\(\))3.115 E F0 .614 (\(see perlport for more details\).)3.115 F .614(See the)5.614 F/F2 10 /Courier@0 SF($/)3.114 E F0(and)3.114 E F2($\\)3.114 E F0 -.25(va)3.114 G .614(riables in).25 F(perlv)128 108 Q(ar for ho)-.25 E 2.5(wt)-.25 G 2.5(om)-2.5 G (anually set your input and output line-termination sequences.)-2.5 E (bless)108 124.8 Q/F3 9/Times-Roman@0 SF(REF)2.5 E F0(,CLASSN)A(AME)-.35 E(bless)108 136.8 Q F3(REF)2.5 E F0 .453 (This function tells the thingy referenced by)128 148.8 R F3(REF)2.954 E F0 .454(that it is no)2.954 F 2.954(wa)-.25 G 2.954(no)-2.954 G .454 (bject in the)-2.954 F F3(CLASSN)2.954 E(AME)-.315 E F0(package.)2.954 E (If)128 160.8 Q F3(CLASSN)3.014 E(AME)-.315 E F0 .514 (is omitted, the current package is used.)3.014 F .514(Because a)5.514 F F2(bless)3.014 E F0 .514(is often the last thing in a)3.014 F (constructor)128 172.8 Q 4.963(,i)-.4 G 4.963(tr)-4.963 G 2.463 (eturns the reference for con)-4.963 F -.15(ve)-.4 G 4.963(nience. Al) .15 F -.1(wa)-.1 G 2.463(ys use the tw).1 F(o-ar)-.1 E 2.463(gument v) -.18 F 2.463(ersion if a)-.15 F(deri)128 184.8 Q -.15(ve)-.25 G 2.514 (dc).15 G .014(lass might inherit the function doing the blessing.) -2.514 F .013(See perltoot and perlobj for more about the)5.014 F (blessing \(and blessings\) of objects.)128 196.8 Q 2.775(Consider al) 128 214.8 R -.1(wa)-.1 G 2.775(ys blessing objects in CLASSN).1 F 2.775 (AMEs that are mix)-.35 F 2.775(ed case.)-.15 F 2.775 (Namespaces with all)7.775 F(lo)128 226.8 Q .733 (wercase names are considered reserv)-.25 F .733(ed for Perl pragmata.) -.15 F .733(Builtin types ha)5.733 F 1.033 -.15(ve a)-.2 H .733 (ll uppercase names.).15 F 4.962 -.8(To p)128 238.8 T(re).8 E -.15(ve) -.25 G 3.362(nt confusion, you may wish to a).15 F -.2(vo)-.2 G 3.362 (id such package names as well.).2 F(Mak)8.362 E 5.862(es)-.1 G 3.362 (ure that)-5.862 F F3(CLASSN)128 250.8 Q(AME)-.315 E F0(is a true v)2.5 E(alue.)-.25 E(See `)128 268.8 Q(`Perl Modules')-.74 E 2.5('i)-.74 G 2.5 (np)-2.5 G(erlmod.)-2.5 E(break)108 285.6 Q(Break out of a)128 297.6 Q F2(given\(\))2.5 E F0(block.)2.5 E 1.289(This k)128 315.6 R -.15(ey)-.1 G -.1(wo).15 G 1.289(rd is enabled by the).1 F F2("switch")3.789 E F0 1.288(feature: see feature for more information.)3.788 F(Alternately) 6.288 E(,)-.65 E(include a)128 327.6 Q F2(use v5.10)2.5 E F0 (or later to the current scope.)2.5 E(caller)108 344.4 Q F3(EXPR)2.5 E F0(caller)108 356.4 Q .308(Returns the conte)128 368.4 R .308 (xt of the current subroutine call.)-.15 F .308(In scalar conte)5.308 F .308(xt, returns the caller')-.15 F 2.808(sp)-.55 G .308(ackage name) -2.808 F 1.12(if there)128 380.4 R F1(is)3.62 E F0 3.62(ac)3.62 G 1.12 (aller \(that is, if we')-3.62 F 1.119(re in a subroutine or)-.5 F F2 (eval)3.619 E F0(or)3.619 E F2(require)3.619 E F0 3.619(\)a)C 1.119 (nd the unde\214ned v)-3.619 F(alue)-.25 E 2.5(otherwise. In)128 392.4 R (list conte)2.5 E(xt, returns)-.15 E F2 36 6(#0 1)152 410.4 T(2)54 E (\($package, $filename, $line\) = caller;)152 422.4 Q F0 -.4(Wi)128 440.4 S(th).4 E F3(EXPR)2.993 E F0 2.993(,i)C 2.994(tr)-2.993 G .494 (eturns some e)-2.994 F .494(xtra information that the deb)-.15 F .494 (ugger uses to print a stack trace.)-.2 F .494(The v)5.494 F(alue)-.25 E (of)128 452.4 Q F3(EXPR)2.5 E F0(indicates ho)2.5 E 2.5(wm)-.25 G(an) -2.5 E 2.5(yc)-.15 G(all frames to go back before the current one.)-2.5 E F2 24 12(#0 1)152 470.4 T -6 36(23 4)48 H (\($package, $filename, $line, $subroutine, $hasargs,)152 482.4 Q 30 12 (#5 6 7)152 506.4 T -36 42(89 1)60 H(0)-42 E ($wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash\))152 518.4 Q 6(=c)158 530.4 S(aller\($i\);)-6 E F0(Here)128 548.4 Q F2 ($subroutine)3.172 E F0 .672(may be)3.172 F F2(\(eval\))3.172 E F0 .672 (if the frame is not a subroutine call, b)3.172 F .671(ut an)-.2 F F2 (eval)3.171 E F0 5.671(.I)C 3.171(ns)-5.671 G .671(uch a)-3.171 F 1.845 (case additional elements)128 560.4 R F2($evaltext)4.346 E F0(and)4.346 E F2($is_require)4.346 E F0 1.846(are set:)4.346 F F2($is_require)4.346 E F0 1.846(is true if the)4.346 F .194(frame is created by a)128 572.4 R F2(require)2.693 E F0(or)2.693 E F2(use)2.693 E F0(statement,)2.693 E F2 ($evaltext)2.693 E F0 .193(contains the te)2.693 F .193(xt of the)-.15 F F2 .193(eval EXPR)2.693 F F0 6.976(statement. In)128 584.4 R(particular) 6.976 E 6.976(,f)-.4 G 4.476(or an)-6.976 F F2 4.476(eval BLOCK)6.976 F F0(statement,)6.976 E F2($subroutine)6.977 E F0(is)6.977 E F2(\(eval\)) 6.977 E F0 6.977(,b)C(ut)-7.177 E F2($evaltext)128 596.4 Q F0 .894 (is unde\214ned.)3.394 F .894(\(Note also that each)5.894 F F2(use)3.394 E F0 .893(statement creates a)3.394 F F2(require)3.393 E F0 .893 (frame inside an)3.393 F F2 .184(eval EXPR)128 608.4 R F0(frame.\))2.684 E F2($subroutine)5.184 E F0 .184(may also be)2.684 F F2(\(unknown\)) 2.684 E F0 .184(if this particular subroutine happens)2.684 F .194 (to ha)128 620.4 R .494 -.15(ve b)-.2 H .194 (een deleted from the symbol table.).15 F F2($hasargs)5.194 E F0 .194 (is true if a ne)2.694 F 2.694(wi)-.25 G .194(nstance of)-2.694 F F2(@_) 2.694 E F0 -.1(wa)2.694 G 2.694(ss).1 G .194(et up for)-2.694 F .622 (the frame.)128 632.4 R F2($hints)5.622 E F0(and)3.122 E F2($bitmask) 3.122 E F0 .622(contain pragmatic hints that the caller w)3.122 F .622 (as compiled with.)-.1 F(The)5.623 E F2($hints)128 644.4 Q F0(and)2.666 E F2($bitmask)2.666 E F0 -.25(va)2.666 G .166 (lues are subject to change between v).25 F .165 (ersions of Perl, and are not meant for)-.15 F -.15(ex)128 656.4 S (ternal use.).15 E F2($hinthash)128 674.4 Q F0 .875 (is a reference to a hash containing the v)3.375 F .875(alue of)-.25 F F2(%^H)3.375 E F0 .876(when the caller w)3.375 F .876(as compiled, or) -.1 F F2(undef)128 686.4 Q F0(if)3.007 E F2(%^H)3.007 E F0 -.1(wa)3.007 G 3.007(se).1 G(mpty)-3.007 E 3.007(.D)-.65 G 3.007(on)-3.007 G .506 (ot modify the v)-3.007 F .506(alues of this hash, as the)-.25 F 3.006 (ya)-.15 G .506(re the actual v)-3.006 F .506(alues stored)-.25 F (in the optree.)128 698.4 Q .088 (Furthermore, when called from within the)128 716.4 R F3(DB)2.588 E F0 .089(package, caller returns more detailed information: it sets)2.588 F (the list v)128 728.4 Q(ariable)-.25 E F2(@DB::args)2.5 E F0 (to be the ar)2.5 E(guments with which the subroutine w)-.18 E(as in)-.1 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E(perl v5.14.2)72 768 Q 203.17 (2011-10-01 8)162.62 F 0 Cg EP %%Page: 9 9 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .712(Be a)128 84 R -.1(wa)-.15 G .712(re that the optimizer might ha).1 F 1.012 -.15(ve o) -.2 H .712(ptimized call frames a).15 F -.1(wa)-.15 G 3.212(yb).1 G (efore)-3.212 E/F1 10/Courier@0 SF(caller)3.212 E F0 .711 (had a chance to)3.212 F .574(get the information.)128 96 R .574 (That means that)5.574 F F1(caller\(N\))3.074 E F0 .575 (might not return information about the call frame)3.074 F .992(you e) 128 108 R .992(xpect it to, for)-.15 F F1 6.991(N>1)3.491 G F0 5.991(.I) -6.991 G 3.491(np)-5.991 G(articular)-3.491 E(,)-.4 E F1(@DB::args)3.491 E F0 .991(might ha)3.491 F 1.291 -.15(ve i)-.2 H .991 (nformation from the pre).15 F(vious)-.25 E(time)128 120 Q F1(caller)2.5 E F0 -.1(wa)2.5 G 2.5(sc).1 G(alled.)-2.5 E .145(Be a)128 138 R -.1(wa) -.15 G .145(re that setting).1 F F1(@DB::args)2.645 E F0(is)2.645 E/F2 10/Times-Italic@0 SF .145(best ef)2.645 F(fort)-.18 E F0 2.645(,i)C .145 (ntended for deb)-2.645 F .145(ugging or generating backtraces, and)-.2 F .364(should not be relied upon. In particular)128 150 R 2.864(,a)-.4 G (s)-2.864 E F1(@_)2.864 E F0 .364(contains aliases to the caller')2.864 F 2.864(sa)-.55 G -.18(rg)-2.864 G .364(uments, Perl does not).18 F(tak) 128 162 Q 4.315(eac)-.1 G(op)-4.315 E 4.315(yo)-.1 G(f)-4.315 E F1(@_) 4.315 E F0 4.315(,s)C(o)-4.315 E F1(@DB::args)4.315 E F0 1.815 (will contain modi\214cations the subroutine mak)4.315 F 1.815(es to)-.1 F F1(@_)4.315 E F0 1.815(or its)4.315 F .64 (contents, not the original v)128 174 R .64(alues at call time.)-.25 F F1(@DB::args)3.14 E F0 3.14(,l)C(ik)-3.14 E(e)-.1 E F1(@_)3.14 E F0 3.14 (,d)C .64(oes not hold e)-3.14 F .64(xplicit references)-.15 F .865 (to its elements, so under certain cases its elements may ha)128 186 R 1.165 -.15(ve b)-.2 H .865(ecome freed and reallocated for other).15 F -.25(va)128 198 S .338(riables or temporary v).25 F .338(alues. Finally) -.25 F 2.838(,as)-.65 G .338(ide ef)-2.838 F .337 (fect of the current implementation is that the ef)-.25 F .337(fects of) -.25 F F1 .504(shift @_)128 210 R F0(can)3.004 E F2(normally)3.004 E F0 .504(be undone \(b)3.004 F .505(ut not)-.2 F F1 .505(pop @_)3.005 F F0 .505(or other splicing,)3.005 F F2(and)3.005 E F0 .505 (not if a reference to)3.005 F F1(@_)3.005 E F0 1.106(has been tak)128 222 R(en,)-.1 E F2(and)3.606 E F0 1.105(subject to the ca)3.606 F -.15 (ve)-.2 G 1.105(at about reallocated elements\), so).15 F F1(@DB::args) 3.605 E F0 1.105(is actually a)3.605 F -.05(hy)128 234 S (brid of the current state and initial state of).05 E F1(@_)2.5 E F0 2.5 (.B)C(uyer be)-2.5 E -.1(wa)-.25 G(re.).1 E(chdir)108 250.8 Q/F3 9 /Times-Roman@0 SF(EXPR)2.5 E F0(chdir)108 262.8 Q F3(FILEHANDLE)2.5 E F0 (chdir)108 274.8 Q F3(DIRHANDLE)2.5 E F0(chdir)108 286.8 Q 1.742 (Changes the w)128 298.8 R 1.742(orking directory to)-.1 F F3(EXPR)4.242 E F0 4.242(,i)C 4.242(fp)-4.242 G 1.742(ossible. If)-4.242 F F3(EXPR) 4.242 E F0 1.742(is omitted, changes to the directory)4.242 F 1.67 (speci\214ed by)128 310.8 R F1($ENV{HOME})4.17 E F0 4.17(,i)C 4.169(fs) -4.17 G 1.669(et; if not, changes to the directory speci\214ed by)-4.169 F F1($ENV{LOGDIR})4.169 E F0(.)A(\(Under)128 322.8 Q F3(VMS)2.752 E F0 2.752(,t)C .252(he v)-2.752 F(ariable)-.25 E F1($ENV{SYS$LOGIN})2.752 E F0 .253(is also check)2.753 F .253 (ed, and used if it is set.\) If neither is set,)-.1 F F1(chdir)128 334.8 Q F0(does nothing. It returns true on success, f)2.5 E (alse otherwise. See the e)-.1 E(xample under)-.15 E F1(die)2.5 E F0(.)A .236(On systems that support)128 352.8 R F2(fc)2.736 E(hdir)-.15 E F0 .236(\(2\), you may pass a \214lehandle or directory handle as the ar) 1.666 F 2.735(gument. On)-.18 F(systems that don')128 364.8 Q 2.5(ts) -.18 G(upport)-2.5 E F2(fc)2.5 E(hdir)-.15 E F0 (\(2\), passing handles raises an e)1.666 E(xception.)-.15 E(chmod)108 381.6 Q F3(LIST)2.5 E F0 1.3 (Changes the permissions of a list of \214les.)128 393.6 R 1.301 (The \214rst element of the list must be the numeric mode,)6.3 F .372 (which should probably be an octal number)128 405.6 R 2.872(,a)-.4 G .372(nd which de\214nitely should)-2.872 F F2(not)2.872 E F0 .371 (be a string of octal digits:)2.872 F F1(0644)128 417.6 Q F0 .395 (is okay)2.895 F 2.895(,b)-.65 G(ut)-3.095 E F1("0644")2.895 E F0 .395 (is not.)2.895 F .395 (Returns the number of \214les successfully changed.)5.395 F .395 (See also `)5.395 F(`oct')-.74 E(')-.74 E(if all you ha)128 429.6 Q .3 -.15(ve i)-.2 H 2.5(sas).15 G(tring.)-2.5 E F1 ($cnt = chmod 0755, "foo", "bar";)152 447.6 Q(chmod 0755, @executables;) 152 459.6 Q($mode = "0644"; chmod $mode, "foo";)152 471.6 Q 6(#!)36 G (!! sets mode to)-6 E 6<23ad>398 483.6 S-6 E ($mode = "0644"; chmod oct\($mode\), "foo"; # this is better)152 495.6 Q ($mode = 0644;)152 507.6 Q(chmod $mode, "foo";)18 E 6(#t)36 G (his is best)-6 E F0 .453(On systems that support)128 525.6 R F2(fc) 2.953 E(hmod)-.15 E F0 .453 (\(2\), you may pass \214lehandles among the \214les.)1.666 F .453 (On systems that don')5.453 F(t)-.18 E(support)128 537.6 Q F2(fc)3.663 E (hmod)-.15 E F0 1.163(\(2\), passing \214lehandles raises an e)1.666 F 3.663(xception. Filehandles)-.15 F 1.164(must be passed as globs or) 3.663 F(glob references to be recognized; bare)128 549.6 Q -.1(wo)-.25 G (rds are considered \214lenames.).1 E F1(open\(my $fh, "<", "foo"\);)152 567.6 Q(my $perm = \(stat $fh\)[2] & 07777;)152 579.6 Q (chmod\($perm | 0600, $fh\);)152 591.6 Q F0 -1.1(Yo)128 609.6 S 2.5(uc) 1.1 G(an also import the symbolic)-2.5 E F1(S_I*)2.5 E F0 (constants from the)2.5 E F1(Fcntl)2.5 E F0(module:)2.5 E F1 (use Fcntl qw\( :mode \);)152 627.6 Q (chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;)152 639.6 Q 6(#I)152 651.6 S(dentical to the chmod 0755 of the example above.)-6 E F0(chomp)108 668.4 Q F3 -1.215(VA)2.5 G(RIABLE)1.215 E F0(chomp\()108 680.4 Q F3(LIST)2.5 E F0(\))2.5 E(chomp)108 692.4 Q .811(This safer v) 128 704.4 R .811(ersion of `)-.15 F(`chop')-.74 E 3.311('r)-.74 G(emo) -3.311 E -.15(ve)-.15 G 3.311(sa).15 G 1.111 -.15(ny t)-3.311 H .81 (railing string that corresponds to the current v).15 F .81(alue of)-.25 F F1($/)3.31 E F0 2.504(\(also kno)128 716.4 R 2.504(wn as)-.25 F F1 ($INPUT_RECORD_SEPARATOR)5.004 E F0 2.504(in the)5.004 F F1(English) 5.005 E F0 5.005(module\). It)5.005 F 2.505(returns the total)5.005 F .507(number of characters remo)128 728.4 R -.15(ve)-.15 G 3.007(df).15 G .507(rom all its ar)-3.007 F 3.007(guments. It')-.18 F 3.007(so)-.55 G .507(ften used to remo)-3.007 F .807 -.15(ve t)-.15 H .507(he ne).15 F .506(wline from the)-.25 F(perl v5.14.2)72 768 Q 203.17(2011-10-01 9) 162.62 F 0 Cg EP %%Page: 10 10 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .255 (end of an input record when you')128 84 R .255(re w)-.5 F .255 (orried that the \214nal record may be missing its ne)-.1 F 2.755 (wline. When)-.25 F(in)2.755 E 1.062(paragraph mode \()128 96 R/F1 10 /Courier@0 SF 1.062($/ = "")B F0 1.062(\), it remo)B -.15(ve)-.15 G 3.562(sa).15 G 1.062(ll trailing ne)-3.562 F 1.062 (wlines from the string.)-.25 F 1.061(When in slurp mode)6.062 F(\()128 108 Q F1 .566($/ = undef)B F0 3.066(\)o)C 3.066<728c>-3.066 G -.15(xe) -3.066 G .566(d-length record mode \().15 F F1($/)A F0 .567 (is a reference to an inte)3.067 F .567(ger or the lik)-.15 F .567 (e; see perlv)-.1 F(ar\))-.25 E/F2 10/Times-Italic@0 SF -.15(ch)128 120 S(omp\(\)).15 E F0 -.1(wo)2.5 G(n').1 E 2.5(tr)-.18 G(emo)-2.5 E .3 -.15 (ve a)-.15 H -.15(ny).15 G 2.5(thing. If).15 F/F3 9/Times-Roman@0 SF -1.215(VA)2.5 G(RIABLE)1.215 E F0(is omitted, it chomps)2.5 E F1($_)2.5 E F0 5(.E)C(xample:)-5 E F1(while \(<>\) {)152 138 Q 6(chomp; #)176 150 R(avoid \\n on last field)6 E(@array = split\(/:/\);)176 162 Q 6(#.)176 174 S(..)-6 E(})152 186 Q F0(If)128 204 Q F3 -1.215(VA)2.5 G(RIABLE) 1.215 E F0(is a hash, it chomps the hash')2.5 E 2.5(sv)-.55 G(alues, b) -2.75 E(ut not its k)-.2 E -.15(ey)-.1 G(s.).15 E -1.1(Yo)128 222 S 2.5 (uc)1.1 G(an actually chomp an)-2.5 E(ything that')-.15 E 2.5(sa)-.55 G 2.5(nl)-2.5 G -.25(va)-2.5 G(lue, including an assignment:).25 E F1 (chomp\($cwd = \222pwd\222\);)152 240 Q(chomp\($answer = \);)152 252 Q F0(If you chomp a list, each element is chomped, and the total nu\ mber of characters remo)128 270 Q -.15(ve)-.15 G 2.5(di).15 G 2.5(sr) -2.5 G(eturned.)-2.5 E 1.622 (Note that parentheses are necessary when you')128 288 R 1.621 (re chomping an)-.5 F 1.621(ything that is not a simple v)-.15 F (ariable.)-.25 E .84(This is because)128 300 R F1 .84 (chomp $cwd = \222pwd\222;)3.34 F F0 .84(is interpreted as)3.34 F F1 .84 (\(chomp $cwd\) = \222pwd\222;)3.34 F F0 3.34(,r)C(ather)-3.34 E 1.765 (than as)128 312 R F1 1.765(chomp\( $cwd = \222pwd\222 \))4.265 F F0 1.765(which you might e)4.265 F 4.264(xpect. Similarly)-.15 F(,)-.65 E F1 1.764(chomp $a, $b)4.264 F F0(is)4.264 E(interpreted as)128 324 Q F1 (chomp\($a\), $b)2.5 E F0(rather than as)2.5 E F1(chomp\($a, $b\))2.5 E F0(.)A(chop)108 340.8 Q F3 -1.215(VA)2.5 G(RIABLE)1.215 E F0(chop\()108 352.8 Q F3(LIST)2.5 E F0(\))2.5 E(chop)108 364.8 Q .953(Chops of)128 376.8 R 3.453(ft)-.25 G .953 (he last character of a string and returns the character chopped.)-3.453 F .954(It is much more ef)5.954 F(\214cient)-.25 E(than)128 388.8 Q F1 (s/.$//s)3.1 E F0 .6(because it neither scans nor copies the string.)3.1 F(If)5.6 E F3 -1.215(VA)3.1 G(RIABLE)1.215 E F0 .6(is omitted, chops)3.1 F F1($_)3.1 E F0 5.6(.I)C(f)-5.6 E F3 -1.215(VA)128 400.8 S(RIABLE)1.215 E F0(is a hash, it chops the hash')2.5 E 2.5(sv)-.55 G(alues, b)-2.75 E (ut not its k)-.2 E -.15(ey)-.1 G(s.).15 E -1.1(Yo)128 418.8 S 2.5(uc) 1.1 G(an actually chop an)-2.5 E(ything that')-.15 E 2.5(sa)-.55 G 2.5 (nl)-2.5 G -.25(va)-2.5 G(lue, including an assignment.).25 E (If you chop a list, each element is chopped.)128 436.8 Q(Only the v)5 E (alue of the last)-.25 E F1(chop)2.5 E F0(is returned.)2.5 E 6.331 (Note that)128 454.8 R F1(chop)8.831 E F0 6.331 (returns the last character)8.831 F 11.331(.T)-.55 G 8.831(or)-12.131 G 6.332(eturn all b)-8.831 F 6.332(ut the last character)-.2 F 8.832(,u) -.4 G(se)-8.832 E F1(substr\($string, 0, \2551\))128 466.8 Q F0(.)A (See also `)128 484.8 Q(`chomp')-.74 E('.)-.74 E(cho)108 501.6 Q(wn)-.25 E F3(LIST)2.5 E F0 .148(Changes the o)128 513.6 R .148 (wner \(and group\) of a list of \214les.)-.25 F .147(The \214rst tw) 5.148 F 2.647(oe)-.1 G .147(lements of the list must be the)-2.647 F F2 (numeric)2.647 E F0 .307(uid and gid, in that order)128 525.6 R 5.307 (.A)-.55 G -.25(va)-2.5 G .308 (lue of \2551 in either position is interpreted by most systems to lea) .25 F .608 -.15(ve t)-.2 H(hat).15 E -.25(va)128 537.6 S(lue unchanged.) .25 E(Returns the number of \214les successfully changed.)5 E F1 ($cnt = chown $uid, $gid, \010foo\010, \010bar\010;)152 555.6 Q (chown $uid, $gid, @filenames;)152 567.6 Q F0 .49 (On systems that support)128 585.6 R F2(fc)2.99 E(hown)-.15 E F0 .49 (\(2\), you may pass \214lehandles among the \214les.)1.666 F .489 (On systems that don')5.489 F(t)-.18 E(support)128 597.6 Q F2(fc)3.705 E (hown)-.15 E F0 1.205(\(2\), passing \214lehandles raises an e)1.666 F 3.706(xception. Filehandles)-.15 F 1.206(must be passed as globs or) 3.706 F(glob references to be recognized; bare)128 609.6 Q -.1(wo)-.25 G (rds are considered \214lenames.).1 E(Here')128 627.6 Q 2.5(sa)-.55 G 2.5(ne)-2.5 G (xample that looks up nonnumeric uids in the passwd \214le:)-2.65 E F1 (print "User: ";)152 645.6 Q(chomp\($user = \);)152 657.6 Q (print "Files: ";)152 669.6 Q(chomp\($pattern = \);)152 681.6 Q (\($login,$pass,$uid,$gid\) = getpwnam\($user\))152 705.6 Q (or die "$user not in passwd file";)176 717.6 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 10)162.62 F 0 Cg EP %%Page: 11 11 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (@ary = glob\($pattern\);)152 84 Q 6(#e)12 G(xpand filenames)-6 E (chown $uid, $gid, @ary;)152 96 Q F0 .351 (On most systems, you are not allo)128 114 R .351(wed to change the o) -.25 F .35(wnership of the \214le unless you')-.25 F .35 (re the superuser)-.5 F(,)-.4 E 1.909 (although you should be able to change the group to an)128 126 R 4.41 (yo)-.15 G 4.41(fy)-4.41 G 1.91(our secondary groups.)-4.41 F 1.91 (On insecure)6.91 F .684(systems, these restrictions may be relax)128 138 R .684(ed, b)-.15 F .684(ut this is not a portable assumption.)-.2 F (On)5.684 E/F2 9/Times-Roman@0 SF(POSIX)3.184 E F0(systems,)3.183 E (you can detect this condition this w)128 150 Q(ay:)-.1 E F1 (use POSIX qw\(sysconf _PC_CHOWN_RESTRICTED\);)152 168 Q ($can_chown_giveaway = not sysconf\(_PC_CHOWN_RESTRICTED\);)152 180 Q F0 (chr)108 196.8 Q F2(NUMBER)2.5 E F0(chr)108 208.8 Q 1.146 (Returns the character represented by that)128 208.8 R F2(NUMBER)3.646 E F0 1.146(in the character set.)3.646 F -.15(Fo)6.147 G 3.647(re).15 G (xample,)-3.797 E F1(chr\(65\))3.647 E F0(is)3.647 E F1("A")128 220.8 Q F0(in either)2.5 E F2(ASCII)2.5 E F0 (or Unicode, and chr\(0x263a\) is a Unicode smile)2.5 E 2.5(yf)-.15 G (ace.)-2.6 E(Ne)128 238.8 Q -.05(ga)-.15 G(ti).05 E .557 -.15(ve v)-.25 H .257(alues gi)-.1 F .556 -.15(ve t)-.25 H .256 (he Unicode replacement character \().15 F/F3 10/Times-Italic@0 SF -.15 (ch)C(r).15 E F0(\(0xf)1.666 E -.25(ff)-.25 G .256(d\)\), e).25 F .256 (xcept under the bytes pragma,)-.15 F(where the lo)128 250.8 Q 2.5(we) -.25 G(ight bits of the v)-2.5 E(alue \(truncated to an inte)-.25 E (ger\) are used.)-.15 E(If)128 268.8 Q F2(NUMBER)2.5 E F0 (is omitted, uses)2.5 E F1($_)2.5 E F0(.)A -.15(Fo)128 286.8 S 2.5(rt) .15 G(he re)-2.5 E -.15(ve)-.25 G(rse, use `).15 E(`ord')-.74 E('.)-.74 E 1.035(Note that characters from 128 to 255 \(inclusi)128 304.8 R -.15 (ve)-.25 G 3.535(\)a).15 G 1.035(re by def)-3.535 F 1.035 (ault internally not encoded as)-.1 F F2(UTF\2558)3.536 E F0(for)3.536 E (backw)128 316.8 Q(ard compatibility reasons.)-.1 E (See perlunicode for more about Unicode.)128 334.8 Q(chroot)108 351.6 Q F2(FILEN)2.5 E(AME)-.315 E F0(chroot)108 363.6 Q .238(This function w) 128 375.6 R .238(orks lik)-.1 F 2.738(et)-.1 G .237 (he system call by the same name: it mak)-2.738 F .237 (es the named directory the ne)-.1 F 2.737(wr)-.25 G(oot)-2.737 E .294 (directory for all further pathnames that be)128 387.6 R .294 (gin with a)-.15 F F1(/)2.794 E F0 .294 (by your process and all its children.)2.794 F .294(\(It doesn')5.294 F (t)-.18 E 2.963(change your current w)128 399.6 R 2.963 (orking directory)-.1 F 5.462(,w)-.65 G 2.962(hich is unaf)-5.462 F 5.462(fected.\) F)-.25 F 2.962(or security reasons, this call is)-.15 F (restricted to the superuser)128 411.6 Q 5(.I)-.55 G(f)-5 E F2(FILEN)2.5 E(AME)-.315 E F0(is omitted, does a)2.5 E F1(chroot)2.5 E F0(to)2.5 E F1 ($_)2.5 E F0(.)A(close)108 428.4 Q F2(FILEHANDLE)2.5 E F0(close)108 440.4 Q .454(Closes the \214le or pipe associated with the \214lehandle\ , \215ushes the)128 452.4 R F2(IO)2.954 E F0 -.2(bu)2.954 G -.25(ff).2 G .454(ers, and closes the system \214le).25 F(descriptor)128 464.4 Q 5.546(.R)-.55 G .546 (eturns true if those operations succeed and if no error w)-5.546 F .545 (as reported by an)-.1 F 3.045(yP)-.15 G .545(erlIO layer)-3.045 F(.) -.55 E(Closes the currently selected \214lehandle if the ar)128 476.4 Q (gument is omitted.)-.18 E -1.1(Yo)128 494.4 S 2.618(ud)1.1 G(on')-2.618 E 2.618(th)-.18 G -2.25 -.2(av e)-2.618 H .119(to close)2.819 F F2 (FILEHANDLE)2.619 E F0 .119(if you are immediately going to do another) 2.619 F F1(open)2.619 E F0 .119(on it, because)2.619 F F1(open)128 506.4 Q F0 1.387(closes it for you.)3.888 F(\(See)6.387 E F1(open)3.887 E F0 3.887(.\) Ho)B(we)-.25 E -.15(ve)-.25 G 2.187 -.4(r, a).15 H 3.887(ne).4 G(xplicit)-4.037 E F1(close)3.887 E F0 1.387 (on an input \214le resets the line)3.887 F(counter \()128 518.4 Q F1 ($.)A F0(\), while the implicit close done by)A F1(open)2.5 E F0 (does not.)2.5 E 1.087(If the \214lehandle came from a piped open,)128 536.4 R F1(close)3.587 E F0 1.087(returns f)3.587 F 1.087 (alse if one of the other syscalls in)-.1 F -.2(vo)-.4 G(lv).2 E(ed)-.15 E -.1(fa)128 548.4 S .173(ils or if its program e).1 F .173 (xits with non-zero status.)-.15 F .173(If the only problem w)5.173 F .172(as that the program e)-.1 F .172(xited non-)-.15 F(zero,)128 560.4 Q F1($!)2.868 E F0 .368(will be set to)5.368 F F1(0)2.868 E F0 5.368(.C) C .368(losing a pipe also w)-5.368 F .369(aits for the process e)-.1 F -.15(xe)-.15 G .369(cuting on the pipe to e).15 F -.834(xit \212 in)-.15 F .141(case you wish to look at the output of the pipe afterw)128 572.4 R -.834(ards \212 and)-.1 F .141(implicitly puts the e)2.641 F .141 (xit status v)-.15 F .141(alue of)-.25 F(that command into)128 584.4 Q F1($?)2.5 E F0(and)2.5 E F1(${^CHILD_ERROR_NATIVE})2.5 E F0(.)A .875 (If there are multiple threads running,)128 602.4 R F1(close)3.375 E F0 .876(on a \214lehandle from a piped open returns true without)3.376 F -.1(wa)128 614.4 S(iting for the child process to terminate, if the \ \214lehandle is still open in another thread.).1 E .058(Closing the rea\ d end of a pipe before the process writing to it at the other end is do\ ne writing results in)128 632.4 R .823(the writer recei)128 644.4 R .823 (ving a)-.25 F F2(SIGPIPE)3.323 E F0 5.823(.I)C 3.323(ft)-5.823 G .823 (he other end can')-3.323 F 3.324(th)-.18 G .824 (andle that, be sure to read all the data before)-3.324 F (closing the pipe.)128 656.4 Q(Example:)128 674.4 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 11)162.62 F 0 Cg EP %%Page: 12 12 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (open\(OUTPUT, \010|sort >foo\010\))152 84 Q 6(#p)12 G(ipe to sort)-6 E (or die "Can\010t start sort: $!";)176 96 Q 138(#... #)152 108 R (print stuff to output)6 E(close OUTPUT)152 120 Q 6(#w)96 G (ait for sort to finish)-6 E(or warn $! ? "Error closing sort pipe: $!") 176 132 Q 6(:")242 144 S(Exit status $? from sort";)-6 E (open\(INPUT, \010foo\010\))152 156 Q 6(#g)60 G(et sort\010s results)-6 E(or die "Can\010t open \010foo\010 for input: $!";)176 168 Q/F2 9 /Times-Roman@0 SF(FILEHANDLE)128 186 Q F0 .145(may be an e)2.646 F .145 (xpression whose v)-.15 F .145 (alue can be used as an indirect \214lehandle, usually the real)-.25 F (\214lehandle name or an auto)128 198 Q(vi)-.15 E(vi\214ed handle.)-.25 E(closedir)108 214.8 Q F2(DIRHANDLE)2.5 E F0 (Closes a directory opened by)128 226.8 Q F1(opendir)2.5 E F0 (and returns the success of that system call.)2.5 E(connect)108 243.6 Q F2(SOCKET)2.5 E F0(,N)A(AME)-.35 E 2.102 (Attempts to connect to a remote sock)128 255.6 R 2.102(et, just lik)-.1 F(e)-.1 E/F3 10/Times-Italic@0 SF(connect)4.602 E F0 4.602 (\(2\). Returns)1.666 F 2.103(true if it succeeded, f)4.602 F(alse)-.1 E (otherwise.)128 267.6 Q F2 -.315(NA)5.079 G(ME).315 E F0 .079 (should be a pack)2.579 F .079 (ed address of the appropriate type for the sock)-.1 F 2.578(et. See)-.1 F .078(the e)2.578 F(xamples)-.15 E(in `)128 279.6 Q(`Sock)-.74 E (ets: Client/Serv)-.1 E(er Communication')-.15 E 2.5('i)-.74 G 2.5(np) -2.5 G(erlipc.)-2.5 E(continue)108 296.4 Q F2(BLOCK)2.5 E F0(continue) 108 308.4 Q F1(continue)128 320.4 Q F0 2.031(is actually a \215o)4.531 F 4.531(wc)-.25 G 2.031(ontrol statement rather than a function.)-4.531 F 2.032(If there is a)7.032 F F1(continue)4.532 E F2(BLOCK)128 332.4 Q F0 .858(attached to a)3.358 F F2(BLOCK)3.358 E F0 .858(\(typically in a) 3.358 F F1(while)3.357 E F0(or)3.357 E F1(foreach)3.357 E F0 .857 (\), it is al)B -.1(wa)-.1 G .857(ys e).1 F -.15(xe)-.15 G .857 (cuted just before).15 F .513(the conditional is about to be e)128 344.4 R -.25(va)-.25 G .514(luated ag).25 F .514(ain, just lik)-.05 F 3.014 (et)-.1 G .514(he third part of a)-3.014 F F1(for)3.014 E F0 .514 (loop in C.)3.014 F .514(Thus it can)5.514 F .513 (be used to increment a loop v)128 356.4 R .513(ariable, e)-.25 F -.15 (ve)-.25 G 3.013(nw).15 G .513(hen the loop has been continued via the) -3.013 F F1(next)3.013 E F0(statement)3.012 E (\(which is similar to the C)128 368.4 Q F1(continue)2.5 E F0 (statement\).)2.5 E F1(last)128 386.4 Q F0(,)A F1(next)2.555 E F0 2.555 (,o)C(r)-2.555 E F1(redo)2.555 E F0 .055(may appear within a)2.555 F F1 (continue)2.555 E F0(block;)2.555 E F1(last)2.555 E F0(and)2.555 E F1 (redo)2.555 E F0(beha)2.556 E .356 -.15(ve a)-.2 H 2.556(si).15 G 2.556 (ft)-2.556 G(he)-2.556 E 2.556(yh)-.15 G(ad)-2.556 E .621(been e)128 398.4 R -.15(xe)-.15 G .621(cuted within the main block.).15 F .621 (So will)5.621 F F1(next)3.121 E F0 3.121(,b)C .62(ut since it will e) -3.321 F -.15(xe)-.15 G .62(cute a).15 F F1(continue)3.12 E F0 .62 (block, it)3.12 F(may be more entertaining.)128 410.4 Q F1 (while \(EXPR\) {)152 428.4 Q(### redo always comes here)176 440.4 Q (do_something;)176 452.4 Q 6(}c)152 464.4 S(ontinue {)-6 E (### next always comes here)176 476.4 Q(do_something_else;)176 488.4 Q 6 (#t)176 500.4 S(hen back the top to re\255check EXPR)-6 E(})152 512.4 Q (### last always comes here)152 524.4 Q F0 .2(Omitting the)128 542.4 R F1(continue)2.7 E F0 .2(section is equi)2.7 F -.25(va)-.25 G .201 (lent to using an empty one, logically enough, so).25 F F1(next)2.701 E F0(goes)2.701 E (directly back to check the condition at the top of the loop.)128 554.4 Q .049(If the)128 572.4 R F1("switch")2.549 E F0 .048 (feature is enabled,)2.548 F F1(continue)2.548 E F0 .048 (is also a function that f)2.548 F .048(alls through the current)-.1 F F1(when)2.548 E F0(or)128 584.4 Q F1(default)4.658 E F0 2.158 (block instead of iterating a dynamically enclosing)4.658 F F1(foreach) 4.659 E F0 2.159(or e)4.659 F 2.159(xiting a le)-.15 F(xically)-.15 E (enclosing)128 596.4 Q F1(given)2.5 E F0 5(.S)C(ee feature and `)-5 E (`Switch statements')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlsyn for more information.)-2.5 E(cos)108 613.2 Q F2(EXPR)2.5 E F0 (cos)108 625.2 Q(Returns the cosine of)128 625.2 Q F2(EXPR)2.5 E F0(\(e) 2.5 E(xpressed in radians\).)-.15 E(If)5 E F2(EXPR)2.5 E F0 (is omitted, tak)2.5 E(es the cosine of)-.1 E F1($_)2.5 E F0(.)A -.15 (Fo)128 643.2 S 4.168(rt).15 G 1.668(he in)-4.168 F -.15(ve)-.4 G 1.668 (rse cosine operation, you may use the).15 F F1(Math::Trig::acos\(\)) 4.168 E F0 1.667(function, or use this)4.167 F(relation:)128 655.2 Q F1 (sub acos { atan2\( sqrt\(1 \255 $_[0] * $_[0]\), $_[0] \) })152 673.2 Q F0(crypt)108 690 Q F2(PLAINTEXT)2.5 E F0(,SAL)A(T)-.92 E .734 (Creates a digest string e)128 702 R .734(xactly lik)-.15 F 3.234(et)-.1 G(he)-3.234 E F3(crypt)3.234 E F0 .734 (\(3\) function in the C library \(assuming that you actually)1.666 F (ha)128 714 Q .3 -.15(ve a ve)-.2 H(rsion there that has not been e).15 E(xtirpated as a potential munition\).)-.15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 12)162.62 F 0 Cg EP %%Page: 13 13 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10 /Times-Italic@0 SF(crypt\(\))128 84 Q F0 .452(is a one-w)2.952 F .452 (ay hash function.)-.1 F(The)5.452 E/F2 9/Times-Roman@0 SF(PLAINTEXT) 2.952 E F0(and)2.952 E F2(SAL)2.952 E(T)-.828 E F0 .451 (are turned into a short string, called a)2.952 F 1.289 (digest, which is returned.)128 96 R 1.289(The same)6.289 F F2 (PLAINTEXT)3.789 E F0(and)3.789 E F2(SAL)3.789 E(T)-.828 E F0 1.289 (will al)3.789 F -.1(wa)-.1 G 1.289(ys return the same string, b).1 F (ut)-.2 E 2.612(there is no \(kno)128 108 R 2.612(wn\) w)-.25 F 2.612 (ay to get the original)-.1 F F2(PLAINTEXT)5.112 E F0 2.612 (from the hash.)5.112 F 2.611(Small changes in the)7.612 F F2(PLAINTEXT) 128 120 Q F0(or)2.5 E F2(SAL)2.5 E(T)-.828 E F0(will result in lar)2.5 E (ge changes in the digest.)-.18 E 1.167(There is no decrypt function.) 128 138 R 1.167(This function isn')6.167 F 3.667(ta)-.18 G 1.168 (ll that useful for cryptograph)-3.667 F 3.668(y\()-.05 G 1.168 (for that, look for)-3.668 F F1(Crypt)128 150 Q F0 .483 (modules on your nearby)2.984 F F2(CP)2.983 E(AN)-.828 E F0 .483 (mirror\) and the name `)2.983 F(`crypt')-.74 E 2.983('i)-.74 G 2.983 (sab)-2.983 G .483(it of a misnomer)-2.983 F 5.483(.I)-.55 G .483 (nstead it)-5.483 F .077(is primarily used to check if tw)128 162 R 2.577(op)-.1 G .077(ieces of te)-2.577 F .077 (xt are the same without ha)-.15 F .077 (ving to transmit or store the te)-.2 F(xt)-.15 E 3.385(itself. An)128 174 R -.15(ex)3.385 G .885(ample is checking if a correct passw).15 F .885(ord is gi)-.1 F -.15(ve)-.25 G 3.385(n. The).15 F .884 (digest of the passw)3.385 F .884(ord is stored,)-.1 F .393 (not the passw)128 186 R .393(ord itself.)-.1 F .394 (The user types in a passw)5.393 F .394(ord that is)-.1 F F1(crypt\(\)) 2.894 E F0 1.394 -.5('d w)D .394(ith the same salt as the stored).5 F 2.5(digest. If)128 198 R(the tw)2.5 E 2.5(od)-.1 G (igests match, the passw)-2.5 E(ord is correct.)-.1 E .314(When v)128 216 R .314(erifying an e)-.15 F .313 (xisting digest string you should use the digest as the salt \(lik)-.15 F(e)-.1 E/F3 10/Courier@0 SF(crypt\($plain,)2.813 E .259 ($digest\) eq $digest)128 228 R F0 2.76(\). The)B F2(SAL)2.76 E(T)-.828 E F0 .26(used to create the digest is visible as part of the digest.) 2.76 F(This)5.26 E(ensures)128 240 Q F1(crypt\(\))3.722 E F0 1.222 (will hash the ne)3.722 F 3.722(ws)-.25 G 1.222 (tring with the same salt as the digest.)-3.722 F 1.221(This allo)6.221 F 1.221(ws your code to)-.25 F -.1(wo)128 252 S .548 (rk with the standard crypt and with more e).1 F .548 (xotic implementations.)-.15 F .548(In other w)5.548 F .548 (ords, assume nothing)-.1 F (about the returned string itself nor about ho)128 264 Q 2.5(wm)-.25 G (an)-2.5 E 2.5(yb)-.15 G(ytes of)-2.5 E F2(SAL)2.5 E(T)-.828 E F0 (may matter)2.5 E(.)-.55 E -.35(Tr)128 282 S .15 (aditionally the result is a string of 13 bytes: tw).35 F 2.65<6f8c>-.1 G .15(rst bytes of the salt, follo)-2.65 F .15(wed by 11 bytes from the) -.25 F(set)128 294 Q F3([./0\2559A\255Za\255z])2.815 E F0 2.815(,a)C .315(nd only the \214rst eight bytes of)-2.815 F F2(PLAINTEXT)2.815 E F0 .316(mattered. But alternati)2.816 F .616 -.15(ve h)-.25 H(ashing).15 E 2.481(schemes \(lik)128 306 R(e)-.1 E F2(MD5)4.98 E F0 2.48 (\), higher le)B -.15(ve)-.25 G 4.98(ls).15 G 2.48 (ecurity schemes \(lik)-4.98 F 4.98(eC)-.1 G 2.48 (2\), and implementations on non-Unix)-4.98 F(platforms may produce dif) 128 318 Q(ferent strings.)-.25 E .848(When choosing a ne)128 336 R 3.348 (ws)-.25 G .849(alt create a random tw)-3.348 F 3.349(oc)-.1 G .849 (haracter string whose characters come from the set)-3.349 F F3 ([./0\2559A\255Za\255z])128 348 Q F0(\(lik)3.847 E(e)-.1 E F3 1.346(joi\ n \010\010, \(\010.\010, \010/\010, 0..9, \010A\010..\010Z\010, \010a\ \010..\010z\010\)[rand)3.847 F .332(64, rand 64])128 360 R F0 2.832 (\). This)B .333 (set of characters is just a recommendation; the characters allo)2.832 F .333(wed in the salt)-.25 F(depend solely on your system')128 372 Q 2.5 (sc)-.55 G(rypt library)-2.5 E 2.5(,a)-.65 G(nd Perl can')-2.5 E 2.5(tr) -.18 G(estrict what salts)-2.5 E F3(crypt\(\))2.5 E F0(accepts.)2.5 E (Here')128 390 Q 2.5(sa)-.55 G 2.5(ne)-2.5 G(xample that mak)-2.65 E (es sure that whoe)-.1 E -.15(ve)-.25 G 2.5(rr).15 G (uns this program kno)-2.5 E(ws their passw)-.25 E(ord:)-.1 E F3 ($pwd = \(getpwuid\($<\)\)[1];)152 408 Q(system "stty \255echo";)152 432 Q(print "Password: ";)152 444 Q(chomp\($word = \);)152 456 Q (print "\\n";)152 468 Q(system "stty echo";)152 480 Q (if \(crypt\($word, $pwd\) ne $pwd\) {)152 504 Q(die "Sorry...\\n";)176 516 Q 6(}e)152 528 S(lse {)-6 E(print "ok\\n";)176 540 Q(})152 552 Q F0 (Of course, typing in your o)128 570 Q(wn passw)-.25 E(ord to whoe)-.1 E -.15(ve)-.25 G 2.5(ra).15 G(sks you for it is unwise.)-2.5 E .437 (The crypt function is unsuitable for hashing lar)128 588 R .437 (ge quantities of data, not least of all because you can')-.18 F(t)-.18 E(get the information back.)128 600 Q (Look at the Digest module for more rob)5 E(ust algorithms.)-.2 E .121 (If using)128 618 R F1(crypt\(\))2.621 E F0 .121 (on a Unicode string \(which)2.621 F F1(potentially)2.621 E F0 .122 (has characters with codepoints abo)2.621 F .422 -.15(ve 2)-.15 H .122 (55\), Perl).15 F .615(tries to mak)128 630 R 3.115(es)-.1 G .614 (ense of the situation by trying to do)-3.115 F .614(wngrade \(a cop) -.25 F 3.114(yo)-.1 G .614(f\) the string back to an eight-bit)-3.114 F .764(byte string before calling)128 642 R F1(crypt\(\))3.264 E F0 .764 (\(on that cop)3.264 F 3.264(y\). If)-.1 F .764(that w)3.264 F .764 (orks, good.)-.1 F .764(If not,)5.764 F F1(crypt\(\))3.264 E F0 .765 (dies with)3.264 F F3(Wide)3.265 E(character in crypt)128 654 Q F0(.)A (dbmclose)108 670.8 Q F2(HASH)2.5 E F0([This function has been lar)128 682.8 Q(gely superseded by the)-.18 E F3(untie)2.5 E F0(function.])2.5 E (Breaks the binding between a)128 700.8 Q F2(DBM)2.5 E F0 (\214le and a hash.)2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 13) 162.62 F 0 Cg EP %%Page: 14 14 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(dbmopen)108 84 Q /F1 9/Times-Roman@0 SF(HASH)2.5 E F0(,DBN)A(AME,MASK)-.35 E ([This function has been lar)128 96 Q(gely superseded by the)-.18 E/F2 10/Courier@0 SF(tie)2.5 E F0(function.])2.5 E .558(This binds a)128 114 R/F3 10/Times-Italic@0 SF(dbm)3.058 E F0(\(3\),)1.666 E F3(ndbm)3.058 E F0(\(3\),)1.666 E F3(sdbm)3.058 E F0(\(3\),)1.666 E F3(gdbm)3.058 E F0 .558(\(3\), or Berk)1.666 F(ele)-.1 E(y)-.15 E F1(DB)3.057 E F0 .557 (\214le to a hash.)3.057 F F1(HASH)5.557 E F0 .557(is the name)3.057 F 1.22(of the hash.)128 126 R(\(Unlik)6.22 E 3.72(en)-.1 G(ormal)-3.72 E F2(open)3.72 E F0 3.72(,t)C 1.22(he \214rst ar)-3.72 F 1.221(gument is) -.18 F F3(not)3.721 E F0 3.721<618c>3.721 G 1.221(lehandle, e)-3.721 F -.15(ve)-.25 G 3.721(nt).15 G 1.221(hough it looks lik)-3.721 F(e)-.1 E (one\).)128 138 Q F1(DBN)5.211 E(AME)-.315 E F0 .211 (is the name of the database \(without the)2.711 F F3(.dir)2.71 E F0(or) 2.71 E F3(.pa)2.71 E(g)-.1 E F0 -.15(ex)2.71 G .21(tension if an).15 F 2.71(y\). If)-.15 F .21(the database)2.71 F .788(does not e)128 150 R .789(xist, it is created with protection speci\214ed by)-.15 F F1(MASK) 3.289 E F0 .789(\(as modi\214ed by the)3.289 F F2(umask)3.289 E F0 3.289 (\). If)B(your)3.289 E 2.234(system supports only the older)128 162 R F1 (DBM)4.734 E F0 2.234(functions, you may mak)4.734 F 4.734(eo)-.1 G 2.234(nly one)-4.734 F F2(dbmopen)4.734 E F0 2.233(call in your)4.734 F 4.09(program. In)128 174 R 1.59(older v)4.09 F 1.59 (ersions of Perl, if your system had neither)-.15 F F1(DBM)4.091 E F0 1.591(nor ndbm, calling)4.091 F F2(dbmopen)4.091 E F0(produced a f)128 186 Q(atal error; it no)-.1 E 2.5(wf)-.25 G(alls back to)-2.6 E F3(sdbm) 2.5 E F0(\(3\).)1.666 E .396(If you don')128 204 R 2.896(th)-.18 G -2.25 -.2(av e)-2.896 H .396(write access to the)3.096 F F1(DBM)2.896 E F0 .395(\214le, you can only read hash v)2.895 F .395 (ariables, not set them.)-.25 F .395(If you)5.395 F -.1(wa)128 216 S 1.019(nt to test whether you can write, either use \214le tests or try \ setting a dummy hash entry inside an).1 F F2(eval)128 228 Q F0 (to trap the error)2.5 E(.)-.55 E .624(Note that functions such as)128 246 R F2(keys)3.124 E F0(and)3.124 E F2(values)3.124 E F0 .624 (may return huge lists when used on lar)3.124 F(ge)-.18 E F1(DBM)3.124 E F0(\214les.)3.124 E -1.1(Yo)128 258 S 2.5(um)1.1 G(ay prefer to use the) -2.5 E F2(each)2.5 E F0(function to iterate o)2.5 E -.15(ve)-.15 G 2.5 (rl).15 G(ar)-2.5 E(ge)-.18 E F1(DBM)2.5 E F0 2.5(\214les. Example:)2.5 F F2 6(#p)152 276 S(rint out history file offsets)-6 E (dbmopen\(%HIST,\010/usr/lib/news/history\010,0666\);)152 288 Q (while \(\($key,$val\) = each %HIST\) {)152 300 Q (print $key, \010 = \010, unpack\(\010L\010,$val\), "\\n";)176 312 Q(}) 152 324 Q(dbmclose\(%HIST\);)152 336 Q F0 2.028(See also An)128 354 R 2.029 (yDBM_File for a more general description of the pros and cons of the v) -.15 F 2.029(arious dbm)-.25 F (approaches, as well as DB_File for a particularly rich implementation.) 128 366 Q -1.1(Yo)128 384 S 2.5(uc)1.1 G(an control which)-2.5 E F1(DBM) 2.5 E F0(library you use by loading that library before you call)2.5 E F3(dbmopen\(\))2.5 E F0(:)A F2(use DB_File;)152 402 Q (dbmopen\(%NS_Hist, "$ENV{HOME}/.netscape/history.db"\))152 414 Q (or die "Can\010t open netscape history file: $!";)176 426 Q F0(def)108 442.8 Q(ault)-.1 E F1(BLOCK)2.5 E F0 -.4(Wi)128 454.8 S 1.706(thin a).4 F F2(foreach)4.206 E F0 1.706(or a)4.206 F F2(given)4.206 E F0 4.206(,a) C F2(default)A F1(BLOCK)4.206 E F0 1.705(acts lik)4.206 F 4.205(ea)-.1 G F2(when)A F0(that')4.205 E 4.205(sa)-.55 G -.1(lwa)-4.205 G 1.705 (ys true.).1 F(Only)6.705 E -.2(av)128 466.8 S (ailable after Perl 5.10, and only if the)-.05 E F2(switch)2.5 E F0 (feature has been requested.)2.5 E(See `)5 E(`when')-.74 E('.)-.74 E (de\214ned)108 483.6 Q F1(EXPR)2.5 E F0(de\214ned)108 495.6 Q .578 (Returns a Boolean v)128 507.6 R .578(alue telling whether)-.25 F F1 (EXPR)3.078 E F0 .578(has a v)3.078 F .579 (alue other than the unde\214ned v)-.25 F(alue)-.25 E F2(undef)3.079 E F0 5.579(.I)C(f)-5.579 E F1(EXPR)128 519.6 Q F0(is not present,)2.5 E F2 ($_)2.5 E F0(is check)2.5 E(ed.)-.1 E(Man)128 537.6 Q 2.792(yo)-.15 G .292(perations return)-2.792 F F2(undef)2.792 E F0 .292(to indicate f) 2.792 F .291(ailure, end of \214le, system error)-.1 F 2.791(,u)-.4 G .291(ninitialized v)-2.791 F .291(ariable, and)-.25 F .91(other e)128 549.6 R .91(xceptional conditions.)-.15 F .911(This function allo)5.91 F .911(ws you to distinguish)-.25 F F2(undef)3.411 E F0 .911(from other v) 3.411 F 3.411(alues. \(A)-.25 F .147 (simple Boolean test will not distinguish among)128 561.6 R F2(undef) 2.647 E F0 2.647(,z)C .147(ero, the empty string, and)-2.647 F F2("0") 2.647 E F0 2.647(,w)C .146(hich are all)-2.647 F 1.126(equally f)128 573.6 R 3.626(alse.\) Note)-.1 F 1.126(that since)3.626 F F2(undef)3.626 E F0 1.127(is a v)3.627 F 1.127(alid scalar)-.25 F 3.627(,i)-.4 G 1.127 (ts presence doesn')-3.627 F(t)-.18 E F3(necessarily)3.627 E F0 1.127 (indicate an)3.627 F -.15(ex)128 585.6 S .373(ceptional condition:).15 F F2(pop)2.873 E F0(returns)2.873 E F2(undef)2.873 E F0 .373(when its ar) 2.873 F .373(gument is an empty array)-.18 F(,)-.65 E F3(or)2.872 E F0 .372(when the element)2.872 F(to return happens to be)128 597.6 Q F2 (undef)2.5 E F0(.)A -1.1(Yo)128 615.6 S 3.748(um)1.1 G 1.248 (ay also use)-3.748 F F2(defined\(&func\))3.748 E F0 1.248 (to check whether subroutine)3.748 F F2(&func)3.749 E F0 1.249(has e) 3.749 F -.15(ve)-.25 G 3.749(rb).15 G 1.249(een de\214ned.)-3.749 F .108 (The return v)128 627.6 R .108(alue is unaf)-.25 F .108(fected by an) -.25 F 2.608(yf)-.15 G(orw)-2.608 E .108(ard declarations of)-.1 F F2 (&func)2.607 E F0 5.107(.A)C .107(subroutine that is not de\214ned)-2.5 F .463(may still be callable: its package may ha)128 639.6 R .764 -.15 (ve a)-.2 H(n).15 E F2(AUTOLOAD)2.964 E F0 .464(method that mak)2.964 F .464(es it spring into e)-.1 F(xistence)-.15 E (the \214rst time that it is called; see perlsub)128 651.6 Q(.)-.4 E .484(Use of)128 669.6 R F2(defined)2.984 E F0 .484(on aggre)2.984 F -.05 (ga)-.15 G .483(tes \(hashes and arrays\) is deprecated.).05 F .483 (It used to report whether memory)5.483 F 1.203(for that aggre)128 681.6 R -.05(ga)-.15 G 1.203(te had e).05 F -.15(ve)-.25 G 3.703(rb).15 G 1.203(een allocated.)-3.703 F 1.203(This beha)6.203 F 1.204 (vior may disappear in future v)-.2 F 1.204(ersions of Perl.)-.15 F -1.1 (Yo)128 693.6 S 2.5(us)1.1 G(hould instead use a simple test for size:) -2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 14)162.62 F 0 Cg EP %%Page: 15 15 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (if \(@an_array\) { print "has array elements\\n" })152 84 Q (if \(%a_hash\))152 96 Q 6({p)18 G(rint "has hash members\\n")-6 E(})18 E F0 .625(When used on a hash element, it tells you whether the v)128 114 R .625(alue is de\214ned, not whether the k)-.25 F .924 -.15(ey ex) -.1 H .624(ists in).15 F(the hash.)128 126 Q(Use `)5 E(`e)-.74 E(xists') -.15 E 2.5('f)-.74 G(or the latter purpose.)-2.5 E(Examples:)128 144 Q F1(print if defined $switch{D};)152 162 Q (print "$val\\n" while defined\($val = pop\(@ary\)\);)152 174 Q (die "Can\010t readlink $sym: $!")152 186 Q (unless defined\($value = readlink $sym\);)176 198 Q (sub foo { defined &$bar ? &$bar\(@_\) : die "No bar"; })152 210 Q ($debugging = 0 unless defined $debugging;)152 222 Q F0 2.717(Note: Man) 128 240 R 2.717(yf)-.15 G .217(olks tend to o)-2.717 F -.15(ve)-.15 G (ruse).15 E F1(defined)2.717 E F0 .218(and are then surprised to disco) 2.718 F -.15(ve)-.15 G 2.718(rt).15 G .218(hat the number)-2.718 F F1(0) 2.718 E F0(and)2.718 E F1("")128 252 Q F0 (\(the zero-length string\) are, in f)2.5 E(act, de\214ned v)-.1 E 2.5 (alues. F)-.25 F(or e)-.15 E(xample, if you say)-.15 E F1 ("ab" =~ /a\(.*\)b/;)152 270 Q F0 .514(The pattern match succeeds and) 128 288 R F1($1)3.013 E F0 .513(is de\214ned, although it matched `) 3.013 F(`nothing')-.74 E 3.013('. It)-.74 F(didn')3.013 E 3.013(tr)-.18 G .513(eally f)-3.013 F .513(ail to)-.1 F .988(match an)128 300 R 3.488 (ything. Rather)-.15 F 3.488(,i)-.4 G 3.488(tm)-3.488 G .989 (atched something that happened to be zero characters long.)-3.488 F .989(This is all)5.989 F -.15(ve)128 312 S 1.11(ry abo).15 F -.15(ve) -.15 G 1.11(-board and honest.).15 F 1.11 (When a function returns an unde\214ned v)6.11 F 1.11(alue, it')-.25 F 3.61(sa)-.55 G 3.61(na)-3.61 G 1.11(dmission that it)-3.61 F(couldn')128 324 Q 2.605(tg)-.18 G -2.15 -.25(iv e)-2.605 H .105 (you an honest answer)2.855 F 5.105(.S)-.55 G 2.605(oy)-5.105 G .105 (ou should use)-2.605 F F1(defined)2.605 E F0 .106 (only when questioning the inte)2.606 F(grity)-.15 E(of what you')128 336 Q(re trying to do.)-.5 E(At other times, a simple comparison to)5 E F1(0)2.5 E F0(or)2.5 E F1("")2.5 E F0(is what you w)2.5 E(ant.)-.1 E (See also `)128 354 Q -1.95(`undef ')-.74 F(', `)-.74 E(`e)-.74 E (xists')-.15 E(', `)-.74 E -1.95(`ref ')-.74 F('.)-.74 E(delete)108 370.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0(Gi)128 382.8 Q -.15(ve)-.25 G 4.904(na).15 G 4.904(ne)-4.904 G 2.404 (xpression that speci\214es an element or slice of a hash,)-5.054 F F1 (delete)4.904 E F0 2.404(deletes the speci\214ed)4.904 F .312 (elements from that hash so that)128 394.8 R/F3 10/Times-Italic@0 SF -.2 (ex)2.812 G(ists\(\)).2 E F0 .312 (on that element no longer returns true.)2.812 F .313 (Setting a hash element)5.313 F(to the unde\214ned v)128 406.8 Q (alue does not remo)-.25 E .3 -.15(ve i)-.15 H(ts k).15 E -.15(ey)-.1 G 2.5(,b)-.5 G(ut deleting it does; see `)-2.7 E(`e)-.74 E(xists')-.15 E ('.)-.74 E 1.493(In list conte)128 424.8 R 1.493(xt, returns the v)-.15 F 1.493(alue or v)-.25 F 1.492 (alues deleted, or the last such element in scalar conte)-.25 F 3.992 (xt. The)-.15 F .262(return list')128 436.8 R 2.762(sl)-.55 G .263 (ength al)-2.762 F -.1(wa)-.1 G .263(ys matches that of the ar).1 F .263 (gument list: deleting non-e)-.18 F .263(xistent elements returns the) -.15 F(unde\214ned v)128 448.8 Q(alue in their corresponding positions.) -.25 E F3(delete\(\))128 466.8 Q F0 .213 (may also be used on arrays and array slices, b)2.714 F .213 (ut its beha)-.2 F .213(vior is less straightforw)-.2 F 2.713 (ard. Although)-.1 F F3 -.2(ex)128 478.8 S(ists\(\)).2 E F0 .706 (will return f)3.206 F .706 (alse for deleted entries, deleting array elements ne)-.1 F -.15(ve)-.25 G 3.207(rc).15 G .707(hanges indices of e)-3.207 F(xisting)-.15 E -.25 (va)128 490.8 S .584(lues; use).25 F F3(shift\(\))3.084 E F0(or)3.084 E F3(splice\(\))3.084 E F0 .584(for that.)3.084 F(Ho)5.584 E(we)-.25 E -.15(ve)-.25 G 1.384 -.4(r, i).15 H 3.084(fa).4 G .584 (ll deleted elements f)-3.084 F .583(all at the end of an array)-.1 F 3.083(,t)-.65 G(he)-3.083 E(array')128 502.8 Q 2.709(ss)-.55 G .209(ize\ shrinks to the position of the highest element that still tests true f\ or)-2.709 F F3 -.2(ex)2.709 G(ists\(\)).2 E F0 2.709(,o)C 2.709(rt) -2.709 G 2.709(o0i)-2.709 G 2.709(fn)-2.709 G(one)-2.709 E(do.)128 514.8 Q/F4 9/Times-Bold@0 SF -1.08(WA)128 532.8 S(RNING:)1.08 E F0 .011 (Calling delete on array v)2.512 F .011(alues is deprecated and lik)-.25 F .011(ely to be remo)-.1 F -.15(ve)-.15 G 2.511(di).15 G 2.511(naf) -2.511 G .011(uture v)-2.511 F .011(ersion of)-.15 F(Perl.)128 544.8 Q .947(Deleting from)128 562.8 R F1(%ENV)3.447 E F0 .947 (modi\214es the en)3.447 F 3.447(vironment. Deleting)-.4 F .947 (from a hash tied to a)3.447 F F2(DBM)3.448 E F0 .948 (\214le deletes the)3.448 F .47(entry from the)128 574.8 R F2(DBM)2.97 E F0 2.97(\214le. Deleting)2.97 F .47(from a)2.97 F F1(tied)2.97 E F0 .47 (hash or array may not necessarily return an)2.97 F .469(ything; it)-.15 F 1.092(depends on the implementation of the)128 586.8 R F1(tied)3.592 E F0(package')3.592 E(s)-.55 E F2(DELETE)3.592 E F0 1.092 (method, which may do whate)3.592 F -.15(ve)-.25 G 3.592(ri).15 G(t) -3.592 E(pleases.)128 598.8 Q(The)128 616.8 Q F1 .762(delete local EXPR) 3.262 F F0 .762 (construct localizes the deletion to the current block at run time.) 3.262 F(Until)5.762 E 1.99(the block e)128 628.8 R 1.991 (xits, elements locally deleted temporarily no longer e)-.15 F 4.491 (xist. See)-.15 F -.74(``)4.491 G 1.991(Localized deletion of).74 F (elements of composite types')128 640.8 Q 2.5('i)-.74 G 2.5(np)-2.5 G (erlsub)-2.5 E(.)-.4 E F1(%hash = \(foo => 11, bar => 22, baz => 33\);) 152 658.8 Q($scalar = delete $hash{foo};)152 670.8 Q 6(#$)78 G (scalar is 11)-6 E($scalar = delete @hash{qw\(foo bar\)};)152 682.8 Q 6 (#$)30 G(scalar is 22)-6 E 6(@array =)152 694.8 R (delete @hash{qw\(foo bar baz\)}; # @array)6 E(is \(undef,undef,33\))12 E F0(The follo)128 712.8 Q(wing \(inef)-.25 E (\214ciently\) deletes all the v)-.25 E(alues of)-.25 E F1(%HASH)2.5 E F0(and)2.5 E F1(@ARRAY:)2.5 E F0(perl v5.14.2)72 768 Q 198.17 (2011-10-01 15)162.62 F 0 Cg EP %%Page: 16 16 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (foreach $key \(keys %HASH\) {)152 84 Q(delete $HASH{$key};)176 96 Q(}) 152 108 Q(foreach $index \(0 .. $#ARRAY\) {)152 132 Q (delete $ARRAY[$index];)176 144 Q(})152 156 Q F0(And so do these:)128 174 Q F1(delete @HASH{keys %HASH};)152 192 Q (delete @ARRAY[0 .. $#ARRAY];)152 216 Q F0 1.59(But both are slo)128 234 R 1.589(wer than assigning the empty list or unde\214ning)-.25 F F1 (%HASH)4.089 E F0(or)4.089 E F1(@ARRAY)4.089 E F0 4.089(,w)C 1.589 (hich is the)-4.089 F(customary w)128 246 Q(ay to empty out an aggre)-.1 E -.05(ga)-.15 G(te:).05 E F1(%HASH = \(\);)152 264 Q 6(#c)30 G (ompletely empty %HASH)-6 E(undef %HASH;)152 276 Q 6(#f)24 G (orget %HASH ever existed)-6 E(@ARRAY = \(\);)152 300 Q 6(#c)24 G (ompletely empty @ARRAY)-6 E(undef @ARRAY;)152 312 Q 6(#f)18 G (orget @ARRAY ever existed)-6 E F0(The)128 330 Q/F2 9/Times-Roman@0 SF (EXPR)4.291 E F0 1.791(can be arbitrarily complicated pro)4.291 F 1.791 (vided its \214nal operation is an element or slice of an)-.15 F(aggre) 128 342 Q -.05(ga)-.15 G(te:).05 E F1(delete $ref\255>[$x][$y]{$key};) 152 360 Q(delete @{$ref\255>[$x][$y]}{$key1, $key2, @morekeys};)152 372 Q(delete $ref\255>[$x][$y][$index];)152 396 Q (delete @{$ref\255>[$x][$y]}[$index1, $index2, @moreindices];)152 408 Q F0(die)108 424.8 Q F2(LIST)2.5 E F1(die)128 436.8 Q F0 2.093 (raises an e)4.593 F 2.093(xception. Inside an)-.15 F F1(eval)4.593 E F0 2.092(the error message is stuf)4.592 F 2.092(fed into)-.25 F F1($@) 4.592 E F0 2.092(and the)4.592 F F1(eval)4.592 E F0(is)4.592 E 1.748 (terminated with the unde\214ned v)128 448.8 R 4.248(alue. If)-.25 F 1.748(the e)4.248 F 1.748(xception is outside of all enclosing)-.15 F F1 (eval)4.248 E F0 1.748(s, then the)B 1.078(uncaught e)128 460.8 R 1.078 (xception prints)-.15 F F2(LIST)3.577 E F0(to)3.577 E F1(STDERR)3.577 E F0 1.077(and e)3.577 F 1.077(xits with a non-zero v)-.15 F 1.077 (alue. If you need to e)-.25 F 1.077(xit the)-.15 F (process with a speci\214c e)128 472.8 Q(xit code, see `)-.15 E(`e)-.74 E(xit')-.15 E('.)-.74 E(Equi)128 490.8 Q -.25(va)-.25 G(lent e).25 E (xamples:)-.15 E F1(die "Can\010t cd to spool: $!\\n" unless chdir \010\ /usr/spool/news\010;)152 508.8 Q (chdir \010/usr/spool/news\010 or die "Can\010t cd to spool: $!\\n")152 520.8 Q F0 1.197(If the last element of)128 538.8 R F2(LIST)3.697 E F0 1.197(does not end in a ne)3.697 F 1.198 (wline, the current script line number and input line)-.25 F .756 (number \(if an)128 550.8 R .756(y\) are also printed, and a ne)-.15 F .755(wline is supplied.)-.25 F .755(Note that the `)5.755 F .755 (`input line number')-.74 F 3.255('\()-.74 G(also)-3.255 E(kno)128 562.8 Q .872(wn as `)-.25 F(`chunk')-.74 E .873('\) is subject to whate)-.74 F -.15(ve)-.25 G 3.373(rn).15 G .873(otion of `)-3.373 F(`line')-.74 E 3.373('h)-.74 G .873(appens to be currently in ef)-3.373 F .873 (fect, and is)-.25 F(also a)128 574.8 Q -.25(va)-.2 G (ilable as the special v).25 E(ariable)-.25 E F1($.)2.5 E F0 5(.S)C (ee `)-5 E(`$/')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar and `) -.25 E(`$.)-.74 E 1.48 -.74('' i)-.7 H 2.5(np).74 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E .484(Hint: sometimes appending)128 592.8 R F1 .484 (", stopped")2.984 F F0 .483(to your message will cause it to mak)2.984 F 2.983(eb)-.1 G .483(etter sense when)-2.983 F(the string)128 604.8 Q F1("at foo line 123")2.5 E F0(is appended.)2.5 E (Suppose you are running script `)5 E(`canasta')-.74 E('.)-.74 E F1 (die "/etc/games is no good";)152 622.8 Q (die "/etc/games is no good, stopped";)152 634.8 Q F0(produce, respecti) 128 652.8 Q -.15(ve)-.25 G(ly).15 E F1 (/etc/games is no good at canasta line 123.)152 670.8 Q (/etc/games is no good, stopped at canasta line 123.)152 682.8 Q F0 .937 (If the output is empty and)128 700.8 R F1($@)3.437 E F0 .937 (already contains a v)3.437 F .937(alue \(typically from a pre)-.25 F .938(vious e)-.25 F -.25(va)-.25 G .938(l\) that v).25 F .938(alue is) -.25 F(reused after appending)128 712.8 Q F1("\\t...propagated")2.5 E F0 5(.T)C(his is useful for propag)-5 E(ating e)-.05 E(xceptions:)-.15 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 16)162.62 F 0 Cg EP %%Page: 17 17 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (eval { ... };)152 84 Q(die unless $@ =~ /Expected exception/;)152 96 Q F0 1.924(If the output is empty and)128 114 R F1($@)4.424 E F0 1.924 (contains an object reference that has a)4.424 F F1(PROPAGATE)4.423 E F0 1.923(method, that)4.423 F .692(method will be called with additional \ \214le and line number parameters.)128 126 R .692(The return v)5.692 F .692(alue replaces the)-.25 F -.25(va)128 138 S .368(lue in).25 F F1($@) 2.868 E F0 5.368(;i)C .368(.e., as if)-5.368 F F1 .367 ($@ = eval { $@\255>PROPAGATE\(_)2.867 F -4.334(_FILE_ _,)1.666 F 1.666 (__)6.367 G -4.334(LINE_ _\))-1.666 F(};)6.367 E F0(were)2.867 E (called.)128 150 Q(If)128 168 Q F1($@)2.5 E F0(is empty then the string) 2.5 E F1("Died")2.5 E F0(is used.)2.5 E .601(If an uncaught e)128 186 R .601(xception results in interpreter e)-.15 F .601(xit, the e)-.15 F .601(xit code is determined from the v)-.15 F .602(alues of)-.25 F F1 ($!)3.102 E F0(and)128 198 Q F1($?)2.5 E F0(with this pseudocode:)2.5 E F1(exit $! if $!;)152 216 Q 6(#e)84 G(rrno)-6 E (exit $? >> 8 if $? >> 8;)152 228 Q 6(#c)24 G(hild exit status)-6 E (exit 255;)152 240 Q 6(#l)114 G(ast resort)-6 E F0 .502 (The intent is to squeeze as much possible information about the lik)128 258 R .501(ely cause into the limited space of)-.1 F .249(the system e) 128 270 R .249(xit code. Ho)-.15 F(we)-.25 E -.15(ve)-.25 G 1.049 -.4 (r, a).15 H(s).4 E F1($!)2.749 E F0 .249(is the v)2.749 F .249 (alue of C')-.25 F(s)-.55 E F1(errno)2.75 E F0 2.75(,w)C .25 (hich can be set by an)-2.75 F 2.75(ys)-.15 G .25(ystem call,)-2.75 F .323(this means that the v)128 282 R .323(alue of the e)-.25 F .323 (xit code used by)-.15 F F1(die)2.823 E F0 .322 (can be non-predictable, so should not be relied)2.823 F (upon, other than to be non-zero.)128 294 Q -1.1(Yo)128 312 S 3.081(uc) 1.1 G .581(an also call)-3.081 F F1(die)3.081 E F0 .581 (with a reference ar)3.081 F .581 (gument, and if this is trapped within an)-.18 F F1(eval)3.081 E F0(,)A F1($@)3.082 E F0(contains)3.082 E .973(that reference.)128 324 R .973 (This permits more elaborate e)5.973 F .972 (xception handling using objects that maintain arbitrary)-.15 F .335 (state about the e)128 336 R 2.835(xception. Such)-.15 F 2.835(as)2.835 G .335(cheme is sometimes preferable to matching particular string v) -2.835 F(alues)-.25 E(of)128 348 Q F1($@)2.788 E F0 .288(with re)2.788 F .288(gular e)-.15 F 2.788(xpressions. Because)-.15 F F1($@)2.788 E F0 .288(is a global v)2.788 F .288(ariable and)-.25 F F1(eval)2.787 E F0 .287(may be used within object)2.787 F .58 (implementations, be careful that analyzing the error object doesn')128 360 R 3.08(tr)-.18 G .58(eplace the reference in the global)-3.08 F -.25 (va)128 372 S 4.551(riable. It').25 F 4.551(se)-.55 G 2.051 (asiest to mak)-4.551 F 4.551(eal)-.1 G 2.051(ocal cop)-4.551 F 4.551 (yo)-.1 G 4.551(ft)-4.551 G 2.05(he reference before an)-4.551 F 4.55 (ym)-.15 G 4.55(anipulations. Here')-4.55 F 4.55(sa)-.55 G(n)-4.55 E -.15(ex)128 384 S(ample:).15 E F1(use Scalar::Util "blessed";)152 402 Q (eval { ... ; die Some::Module::Exception\255>new\( FOO => "bar" \) };) 152 426 Q(if \(my $ev_err = $@\) {)152 438 Q(if \(blessed\($ev_err\) &&\ $ev_err\255>isa\("Some::Module::Exception"\)\) {)176 450 Q 6(#h)200 462 S(andle Some::Module::Exception)-6 E(})176 474 Q(else {)176 486 Q 6(#h) 200 498 S(andle all other possible exceptions)-6 E(})176 510 Q(})152 522 Q F0 .21(Because Perl stringi\214es uncaught e)128 540 R .211 (xception messages before display)-.15 F 2.711(,y)-.65 G(ou')-2.711 E .211(ll probably w)-.1 F .211(ant to o)-.1 F -.15(ve)-.15 G(rload).15 E (stringi\214cation operations on e)128 552 Q(xception objects.)-.15 E (See o)5 E -.15(ve)-.15 G(rload for details about that.).15 E -1.1(Yo) 128 570 S 5.767(uc)1.1 G 3.266 (an arrange for a callback to be run just before the)-5.767 F F1(die) 5.766 E F0 3.266(does its deed, by setting the)5.766 F F1 -4.334 ($SIG{_ _DIE_ _})128 582 R F0 3.952(hook. The)3.952 F 1.453 (associated handler is called with the error te)3.952 F 1.453 (xt and can change the)-.15 F .288 (error message, if it sees \214t, by calling)128 594 R F1(die)2.788 E F0 (ag)2.788 E 2.788(ain. See)-.05 F -.74(``)2.788 G(%SIG').74 E 2.788('i) -.74 G 2.788(np)-2.788 G(erlv)-2.788 E .287(ar for details on setting) -.25 F F1(%SIG)2.787 E F0 .394(entries, and `)128 606 R(`e)-.74 E -.25 (va)-.25 G(l).25 E/F2 9/Times-Roman@0 SF(BLOCK)2.894 E F0 1.874 -.74 ('' f)D .394(or some e).74 F 2.894(xamples. Although)-.15 F .394 (this feature w)2.894 F .395(as to be run only right before)-.1 F 1.323 (your program w)128 618 R 1.323(as to e)-.1 F 1.323 (xit, this is not currently so: the)-.15 F F1 -4.334($SIG{_ _DIE_ _}) 3.822 F F0 1.322(hook is currently called)3.822 F -2.15 -.25(ev e)128 630 T 2.5(ni).25 G(nside)-2.5 E/F3 10/Times-Italic@0 SF -.15(ev)2.5 G (al\(\)).15 E F0(ed blocks/strings!)A(If one w)5 E (ants the hook to do nothing in such situations, put)-.1 E F1 (die @_ if $^S;)152 648 Q F0 1.874 (as the \214rst line of the handler \(see `)128 666 R(`$^S')-.74 E 4.375 ('i)-.74 G 4.375(np)-4.375 G(erlv)-4.375 E 4.375(ar\). Because)-.25 F 1.875(this promotes strange action at a)4.375 F (distance, this counterintuiti)128 678 Q .3 -.15(ve b)-.25 H(eha).15 E (vior may be \214x)-.2 E(ed in a future release.)-.15 E(See also)128 696 Q F3 -.2(ex)2.5 G(it\(\)).2 E F0(,)A F3(warn\(\))2.5 E F0 2.5(,a)C (nd the Carp module.)-2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 17) 162.62 F 0 Cg EP %%Page: 18 18 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(do)108 84 Q/F1 9 /Times-Roman@0 SF(BLOCK)2.5 E F0 .492(Not really a function.)128 96 R .492(Returns the v)5.492 F .492 (alue of the last command in the sequence of commands indicated)-.25 F (by)128 108 Q F1(BLOCK)2.764 E F0 5.264(.W)C .264(hen modi\214ed by the) -5.264 F/F2 10/Courier@0 SF(while)2.764 E F0(or)2.764 E F2(until)2.765 E F0 .265(loop modi\214er)2.765 F 2.765(,e)-.4 G -.15(xe)-2.915 G .265 (cutes the).15 F F1(BLOCK)2.765 E F0 .265(once before)2.765 F(testing t\ he loop condition. \(On other statements the loop modi\214ers test the \ conditional \214rst.\))128 120 Q F2 .237(do BLOCK)128 138 R F0(does) 2.737 E/F3 10/Times-Italic@0 SF(not)2.736 E F0 .236 (count as a loop, so the loop control statements)2.736 F F2(next)2.736 E F0(,)A F2(last)2.736 E F0 2.736(,o)C(r)-2.736 E F2(redo)2.736 E F0 .236 (cannot be)2.736 F(used to lea)128 150 Q .3 -.15(ve o)-.2 H 2.5(rr).15 G (estart the block.)-2.5 E(See perlsyn for alternati)5 E .3 -.15(ve s) -.25 H(trate).15 E(gies.)-.15 E(do)108 166.8 Q F1(SUBR)2.5 E(OUTINE)-.36 E F0(\()A F1(LIST)A F0(\))A 1.125 (This form of subroutine call is deprecated.)128 178.8 R F1(SUBR)6.126 E (OUTINE)-.36 E F0 1.126(can be a bare)3.626 F -.1(wo)-.25 G 1.126 (rd, a scalar v).1 F 1.126(ariable or a)-.25 F(subroutine be)128 190.8 Q (ginning with)-.15 E F2(&)2.5 E F0(.)A(do)108 207.6 Q F1(EXPR)2.5 E F0 (Uses the v)128 219.6 Q(alue of)-.25 E F1(EXPR)2.5 E F0 (as a \214lename and e)2.5 E -.15(xe)-.15 G (cutes the contents of the \214le as a Perl script.).15 E F2 (do \010stat.pl\010;)152 237.6 Q F0(is just lik)128 255.6 Q(e)-.1 E F2 (eval \222cat stat.pl\222;)152 273.6 Q F0 -.15(ex)128 291.6 S 1.6 (cept that it').15 F 4.1(sm)-.55 G 1.6(ore ef)-4.1 F 1.599 (\214cient and concise, k)-.25 F 1.599 (eeps track of the current \214lename for error messages,)-.1 F 1.193 (searches the)128 303.6 R F2(@INC)3.693 E F0 1.193 (directories, and updates)3.693 F F2(%INC)3.694 E F0 1.194 (if the \214le is found.)3.694 F 1.194(See `)6.194 F(`@INC')-.74 E 3.694 ('i)-.74 G 3.694(np)-3.694 G(erlv)-3.694 E 1.194(ar and)-.25 F -.74(``) 128 315.6 S(%INC').74 E 3.792('i)-.74 G 3.792(np)-3.792 G(erlv)-3.792 E 1.292(ar for these v)-.25 F 3.791(ariables. It)-.25 F 1.291(also dif) 3.791 F 1.291(fers in that code e)-.25 F -.25(va)-.25 G 1.291 (luated with).25 F F2 1.291(do FILENAME)3.791 F F0 1.199(cannot see le) 128 327.6 R 1.199(xicals in the enclosing scope;)-.15 F F2 1.199 (eval STRING)3.699 F F0 3.699(does. It')3.699 F 3.7(st)-.55 G 1.2 (he same, ho)-3.7 F(we)-.25 E -.15(ve)-.25 G 2 -.4(r, i).15 H 3.7(nt).4 G 1.2(hat it)-3.7 F(does reparse the \214le e)128 339.6 Q -.15(ve)-.25 G (ry time you call it, so you probably don').15 E 2.5(tw)-.18 G (ant to do this inside a loop.)-2.6 E(If)128 357.6 Q F2(do)2.799 E F0 .299(can read the \214le b)2.799 F .299 (ut cannot compile it, it returns)-.2 F F2(undef)2.799 E F0 .298 (and sets an error message in)2.798 F F2($@)2.798 E F0 5.298(.I)C(f) -5.298 E F2(do)2.798 E F0 .798 (cannot read the \214le, it returns undef and sets)128 369.6 R F2($!) 3.298 E F0 .798(to the error)3.298 F 5.799(.A)-.55 G -.1(lwa)-5.799 G .799(ys check).1 F F2($@)3.299 E F0 .799(\214rst, as compilation)3.299 F .689(could f)128 381.6 R .689(ail in a w)-.1 F .689(ay that also sets) -.1 F F2($!)3.189 E F0 5.689(.I)C 3.189(ft)-5.689 G .689 (he \214le is successfully compiled,)-3.189 F F2(do)3.189 E F0 .689 (returns the v)3.189 F .689(alue of the)-.25 F(last e)128 393.6 Q (xpression e)-.15 E -.25(va)-.25 G(luated.).25 E 1.654 (Inclusion of library modules is better done with the)128 411.6 R F2 (use)4.155 E F0(and)4.155 E F2(require)4.155 E F0 1.655 (operators, which also do)4.155 F (automatic error checking and raise an e)128 423.6 Q(xception if there') -.15 E 2.5(sap)-.55 G(roblem.)-2.5 E -1.1(Yo)128 441.6 S 2.972(um)1.1 G .472(ight lik)-2.972 F 2.972(et)-.1 G 2.972(ou)-2.972 G(se)-2.972 E F2 (do)2.972 E F0 .472(to read in a program con\214guration \214le.)2.972 F .471(Manual error checking can be done)5.471 F(this w)128 453.6 Q(ay:) -.1 E F2 6(#r)152 471.6 S(ead in config files: system first, then user) -6 E(for $file \("/share/prog/defaults.rc",)152 483.6 Q ("$ENV{HOME}/.someprogrc"\))218 495.6 Q({)152 507.6 Q (unless \($return = do $file\) {)176 519.6 Q (warn "couldn\010t parse $file: $@" if $@;)200 531.6 Q (warn "couldn\010t do $file: $!")200 543.6 Q(unless defined $return;)24 E(warn "couldn\010t run $file")200 555.6 Q(unless $return;)42 E(})176 567.6 Q(})152 579.6 Q F0(dump)108 596.4 Q F1(LABEL)2.5 E F0(dump)108 608.4 Q 1.862(This function causes an immediate core dump.)128 620.4 R 1.862(See also the)6.862 F/F4 10/Times-Bold@0 SF4.362 E F0 1.863 (command-line switch in perlrun,)4.362 F .462 (which does the same thing.)128 632.4 R .461 (Primarily this is so that you can use the)5.461 F F4(undump)2.961 E F0 .461(program \(not supplied\))2.961 F 1.738 (to turn your core dump into an e)128 644.4 R -.15(xe)-.15 G 1.739 (cutable binary after ha).15 F 1.739(ving initialized all your v)-.2 F 1.739(ariables at the)-.25 F(be)128 656.4 Q 2.034 (ginning of the program.)-.15 F 2.034(When the ne)7.034 F 4.534(wb)-.25 G 2.034(inary is e)-4.534 F -.15(xe)-.15 G 2.034(cuted it will be).15 F 2.033(gin by e)-.15 F -.15(xe)-.15 G 2.033(cuting a).15 F F2(goto)4.533 E(LABEL)128 668.4 Q F0 1.134(\(with all the restrictions that)3.634 F F2 (goto)3.634 E F0(suf)3.634 E 3.634(fers\). Think)-.25 F 1.134 (of it as a goto with an interv)3.634 F 1.135(ening core)-.15 F (dump and reincarnation.)128 680.4 Q(If)5 E F2(LABEL)2.5 E F0 (is omitted, restarts the program from the top.)2.5 E/F5 9/Times-Bold@0 SF -1.08(WA)128 698.4 S(RNING)1.08 E F0 2.903(:A)C .703 -.15(ny \214) -2.903 H .403(les opened at the time of the dump will).15 F F3(not)2.902 E F0 .402(be open an)2.902 F 2.902(ym)-.15 G .402 (ore when the program is)-2.902 F (reincarnated, with possible resulting confusion by Perl.)128 710.4 Q 1.657(This function is no)128 728.4 R 4.157(wl)-.25 G(ar)-4.157 E 1.657 (gely obsolete, mostly because it')-.18 F 4.158(sv)-.55 G 1.658 (ery hard to con)-4.308 F -.15(ve)-.4 G 1.658(rt a core \214le into an) .15 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 18)162.62 F 0 Cg EP %%Page: 19 19 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E -.15(exe)128 84 S .212(cutable. That').15 F 2.712(sw)-.55 G .312 -.05(hy y)-2.712 H .212 (ou should no).05 F 2.712(wi)-.25 G -1.9 -.4(nv o)-2.712 H .412 -.1 (ke i).4 H 2.712(ta).1 G(s)-2.712 E/F1 10/Courier@0 SF(CORE::dump\(\)) 2.712 E F0 2.712(,i)C 2.712(fy)-2.712 G .212(ou don')-2.712 F 2.712(tw) -.18 G .211(ant to be w)-2.812 F(arned)-.1 E(ag)128 96 Q (ainst a possible typo.)-.05 E(each)108 112.8 Q/F2 9/Times-Roman@0 SF (HASH)2.5 E F0(each)108 124.8 Q F2(ARRA)2.5 E(Y)-.945 E F0(each)108 136.8 Q F2(EXPR)2.5 E F0 1.829(When called in list conte)128 148.8 R 1.829(xt, returns a 2\255element list consisting of the k)-.15 F 2.13 -.15(ey a)-.1 H 1.83(nd v).15 F 1.83(alue for the ne)-.25 F(xt)-.15 E .37(element of a hash, or the inde)128 160.8 R 2.87(xa)-.15 G .37(nd v) -2.87 F .37(alue for the ne)-.25 F .37(xt element of an array)-.15 F 2.87(,s)-.65 G 2.87(ot)-2.87 G .37(hat you can iterate o)-2.87 F -.15 (ve)-.15 G(r).15 E 3.643(it. When)128 172.8 R 1.143 (called in scalar conte)3.643 F 1.143(xt, returns only the k)-.15 F 1.443 -.15(ey \()-.1 H 1.144(not the v).15 F 1.144 (alue\) in a hash, or the inde)-.25 F 3.644(xi)-.15 G 3.644(na)-3.644 G (n)-3.644 E(array)128 184.8 Q(.)-.65 E .097 (Hash entries are returned in an apparently random order)128 202.8 R 5.097(.T)-.55 G .097(he actual random order is subject to change)-5.097 F .551(in future v)128 214.8 R .551(ersions of Perl, b)-.15 F .551 (ut it is guaranteed to be in the same order as either the)-.2 F F1 (keys)3.051 E F0(or)3.051 E F1(values)3.051 E F0 .254(function w)128 226.8 R .254(ould produce on the same \(unmodi\214ed\) hash.)-.1 F .254 (Since Perl 5.8.2 the ordering can be dif)5.254 F(ferent)-.25 E -2.15 -.25(ev e)128 238.8 T 3.816(nb).25 G 1.316(etween dif)-3.816 F 1.316 (ferent runs of Perl for security reasons \(see `)-.25 F -.8(`A)-.74 G 1.316(lgorithmic Comple).8 F 1.317(xity Attacks')-.15 F 3.817('i)-.74 G (n)-3.817 E(perlsec\).)128 250.8 Q(After)128 268.8 Q F1(each)2.64 E F0 .14(has returned all entries from the hash or array)2.64 F 2.639(,t)-.65 G .139(he ne)-2.639 F .139(xt call to)-.15 F F1(each)2.639 E F0 .139 (returns the empty list)2.639 F .658(in list conte)128 280.8 R .658 (xt and)-.15 F F1(undef)3.158 E F0 .658(in scalar conte)3.158 F 3.158 (xt. The)-.15 F(ne)3.158 E .658(xt call follo)-.15 F .658 (wing that one restarts iteration.)-.25 F(Each)5.659 E 1.188 (hash or array has its o)128 292.8 R 1.188(wn internal iterator)-.25 F 3.688(,a)-.4 G 1.187(ccessed by)-3.688 F F1(each)3.687 E F0(,)A F1(keys) 3.687 E F0 3.687(,a)C(nd)-3.687 E F1(values)3.687 E F0 6.187(.T)C 1.187 (he iterator is)-6.187 F .499(implicitly reset when)128 304.8 R F1(each) 2.999 E F0 .499(has reached the end as just described; it can be e)2.999 F .5(xplicitly reset by calling)-.15 F F1(keys)128 316.8 Q F0(or)2.923 E F1(values)2.923 E F0 .422(on the hash or array)2.922 F 5.422(.I)-.65 G 2.922(fy)-5.422 G .422(ou add or delete a hash')-2.922 F 2.922(se)-.55 G .422(lements while iterating o)-2.922 F -.15(ve)-.15 G 2.922(ri).15 G (t,)-2.922 E .028(entries may be skipped or duplicated)128 328.8 R 1.666 <8a73>1.666 G 2.529(od)-1.666 G(on')-2.529 E 2.529(td)-.18 G 2.529(ot) -2.529 G 2.529(hat. Exception:)-2.529 F .029(It is al)2.529 F -.1(wa)-.1 G .029(ys safe to delete the item).1 F(most recently returned by)128 340.8 Q F1(each\(\))2.5 E F0 2.5(,s)C 2.5(ot)-2.5 G(he follo)-2.5 E (wing code w)-.25 E(orks properly:)-.1 E F1 (while \(\($key, $value\) = each %hash\) {)176 358.8 Q (print $key, "\\n";)188 370.8 Q(delete $hash{$key};)188 382.8 Q 6(#T)18 G(his is safe)-6 E(})176 394.8 Q F0(This prints out your en)128 412.8 Q (vironment lik)-.4 E 2.5(et)-.1 G(he)-2.5 E/F3 10/Times-Italic@0 SF (printen)2.5 E(v)-.4 E F0(\(1\) program, b)1.666 E(ut in a dif)-.2 E (ferent order:)-.25 E F1(while \(\($key,$value\) = each %ENV\) {)152 430.8 Q(print "$key=$value\\n";)176 442.8 Q(})152 454.8 Q F0 .141 (Starting with Perl 5.14,)128 472.8 R F1(each)2.641 E F0 .141(can tak) 2.641 F 2.64(eas)-.1 G(calar)-2.64 E F2(EXPR)2.64 E F0 2.64(,w)C .14 (hich must hold reference to an unblessed hash)-2.64 F .326(or array)128 484.8 R 5.326(.T)-.65 G .326(he ar)-5.326 F .326 (gument will be dereferenced automatically)-.18 F 5.326(.T)-.65 G .327 (his aspect of)-5.326 F F1(each)2.827 E F0 .327(is considered highly) 2.827 F -.15(ex)128 496.8 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E F1(while \(\($key,$value\) = each $hashref\) { ... })152 514.8 Q F0(See also)128 532.8 Q F1(keys)2.5 E F0(,)A F1(values)2.5 E F0 2.5(,a)C (nd)-2.5 E F1(sort)2.5 E F0(.)A(eof)108 549.6 Q F2(FILEHANDLE)2.5 E F0 (eof \(\))108 561.6 Q(eof)108 573.6 Q 1.385(Returns 1 if the ne)128 573.6 R 1.385(xt read on)-.15 F F2(FILEHANDLE)3.885 E F0 1.385 (will return end of \214le)3.885 F F3(or)3.884 E F0(if)3.884 E F2 (FILEHANDLE)3.884 E F0 1.384(is not open.)3.884 F F2(FILEHANDLE)128 585.6 Q F0 1.244(may be an e)3.744 F 1.244(xpression whose v)-.15 F 1.244(alue gi)-.25 F -.15(ve)-.25 G 3.744(st).15 G 1.244 (he real \214lehandle.)-3.744 F 1.245(\(Note that this function)6.245 F .369(actually reads a character and then)128 597.6 R F1(ungetc)2.868 E F0 2.868(si)C .368(t, so isn')-2.868 F 2.868(tu)-.18 G .368 (seful in an interacti)-2.868 F .668 -.15(ve c)-.25 H(onte).15 E 2.868 (xt.\) Do)-.15 F .368(not read)2.868 F .025 (from a terminal \214le \(or call)128 609.6 R F1(eof\(FILEHANDLE\))2.525 E F0 .025(on it\) after end-of-\214le is reached.)2.525 F .025 (File types such as)5.025 F (terminals may lose the end-of-\214le condition if you do.)128 621.6 Q (An)128 639.6 Q F1(eof)5.059 E F0 2.559(without an ar)5.059 F 2.559 (gument uses the last \214le read.)-.18 F(Using)7.559 E F1(eof\(\))5.058 E F0 2.558(with empty parentheses is)5.058 F(dif)128 651.6 Q 2.536 (ferent. It)-.25 F .037(refers to the pseudo \214le formed from the \ \214les listed on the command line and accessed via)2.536 F(the)128 663.6 Q F1(<>)2.892 E F0(operator)2.892 E 5.392(.S)-.55 G(ince)-5.392 E F1(<>)2.892 E F0(isn')2.892 E 2.892(te)-.18 G .392 (xplicitly opened, as a normal \214lehandle is, an)-3.042 F F1(eof\(\)) 2.891 E F0(before)2.891 E F1(<>)2.891 E F0(has)2.891 E .518 (been used will cause)128 675.6 R F1(@ARGV)3.018 E F0 .518(to be e)3.018 F .518(xamined to determine if input is a)-.15 F -.25(va)-.2 G 5.518 (ilable. Similarly).25 F 3.019(,a)-.65 G(n)-3.019 E F1(eof\(\))3.019 E F0(after)128 687.6 Q F1(<>)4.505 E F0 2.005 (has returned end-of-\214le will assume you are processing another)4.505 F F1(@ARGV)4.504 E F0 2.004(list, and if you)4.504 F(ha)128 699.6 Q -.15 (ve)-.2 G(n').15 E 2.5(ts)-.18 G(et)-2.5 E F1(@ARGV)2.5 E F0 2.5(,w)C (ill read input from)-2.5 E F1(STDIN)2.5 E F0 2.5(;s)C(ee `)-2.5 E (`I/O Operators')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E 1.192 (In a)128 717.6 R F1 1.192(while \(<>\))3.692 F F0(loop,)3.692 E F1(eof) 3.692 E F0(or)3.692 E F1(eof\(ARGV\))3.692 E F0 1.192 (can be used to detect the end of each \214le, whereas)3.692 F F1 (eof\(\))128 729.6 Q F0(will detect the end of the v)2.5 E (ery last \214le only)-.15 E 5(.E)-.65 G(xamples:)-5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 19)162.62 F 0 Cg EP %%Page: 20 20 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#r)152 84 S(eset line numbering on each input file)-6 E (while \(<>\) {)152 96 Q(next if /^\\s*#/;)176 108 Q 6(#s)12 G (kip comments)-6 E(print "$.\\t$_";)176 120 Q 6(}c)152 132 S(ontinue {) -6 E(close ARGV if eof;)176 144 Q 6(#N)12 G(ot eof\(\)!)-6 E(})152 156 Q 6(#i)152 180 S(nsert dashes just before last line of last file)-6 E (while \(<>\) {)152 192 Q(if \(eof\(\)\) {)176 204 Q 6(#c)12 G (heck for end of last file)-6 E <7072696e742022adadadadadadadadadadadadadad5c6e223b>200 216 Q(})176 228 Q(print;)176 240 Q(last if eof\(\);)176 252 Q 6(#n)60 G (eeded if we\010re reading from a terminal)-6 E(})152 264 Q F0 .644 (Practical hint: you almost ne)128 282 R -.15(ve)-.25 G 3.143(rn).15 G .643(eed to use)-3.143 F F1(eof)3.143 E F0 .643 (in Perl, because the input operators typically return)3.143 F F1(undef) 128 294 Q F0(when the)2.5 E 2.5(yr)-.15 G (un out of data or encounter an error)-2.5 E(.)-.55 E -.25(eva)108 310.8 S(l).25 E/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0 -.25(eva)108 322.8 S(l).25 E F2(BLOCK)2.5 E F0 -.25(eva)108 334.8 S(l).25 E .897 (In the \214rst form, the return v)128 346.8 R .898(alue of)-.25 F F2 (EXPR)3.398 E F0 .898(is parsed and e)3.398 F -.15(xe)-.15 G .898 (cuted as if it were a little Perl program.).15 F 1.223(The v)128 358.8 R 1.223(alue of the e)-.25 F 1.223 (xpression \(which is itself determined within scalar conte)-.15 F 1.222 (xt\) is \214rst parsed, and if)-.15 F .689(there were no errors, e)128 370.8 R -.15(xe)-.15 G .689(cuted in the le).15 F .689(xical conte)-.15 F .69(xt of the current Perl program, so that an)-.15 F 3.19(yv)-.15 G (ariable)-3.44 E 1.075 (settings or subroutine and format de\214nitions remain afterw)128 382.8 R 3.574(ards. Note)-.1 F 1.074(that the v)3.574 F 1.074 (alue is parsed e)-.25 F -.15(ve)-.25 G(ry).15 E 1.819(time the)128 394.8 R F1(eval)4.319 E F0 -.15(exe)4.319 G 4.319(cutes. If).15 F F2 (EXPR)4.319 E F0 1.819(is omitted, e)4.319 F -.25(va)-.25 G(luates).25 E F1($_)4.319 E F0 6.819(.T)C 1.819(his form is typically used to delay) -6.819 F(parsing and subsequent e)128 406.8 Q -.15(xe)-.15 G (cution of the te).15 E(xt of)-.15 E F2(EXPR)2.5 E F0(until run time.) 2.5 E 1.661(In the second form, the code within the)128 424.8 R F2 (BLOCK)4.16 E F0 1.66(is parsed only once)4.16 F 1.666<8a61>1.666 G 4.16 (tt)-1.666 G 1.66(he same time the code)-4.16 F 2.949(surrounding the) 128 436.8 R F1(eval)5.449 E F0 2.949(itself w)5.449 F 2.949(as parsed) -.1 F 1.666<8a61>1.666 G 2.949(nd e)-1.666 F -.15(xe)-.15 G 2.949 (cuted within the conte).15 F 2.949(xt of the current Perl)-.15 F 3.866 (program. This)128 448.8 R 1.366(form is typically used to trap e)3.866 F 1.365(xceptions more ef)-.15 F 1.365 (\214ciently than the \214rst \(see belo)-.25 F(w\),)-.25 E (while also pro)128 460.8 Q (viding the bene\214t of checking the code within)-.15 E F2(BLOCK)2.5 E F0(at compile time.)2.5 E(The \214nal semicolon, if an)128 478.8 Q 1.3 -.65(y, m)-.15 H(ay be omitted from the v).65 E(alue of)-.25 E F2(EXPR) 2.5 E F0(or within the)2.5 E F2(BLOCK)2.5 E F0(.)A .218 (In both forms, the v)128 496.8 R .218(alue returned is the v)-.25 F .218(alue of the last e)-.25 F .218(xpression e)-.15 F -.25(va)-.25 G .219(luated inside the mini-program;).25 F 3.805(ar)128 508.8 S 1.305 (eturn statement may be also used, just as with subroutines.)-3.805 F 1.304(The e)6.304 F 1.304(xpression pro)-.15 F 1.304(viding the return) -.15 F -.25(va)128 520.8 S 1.224(lue is e).25 F -.25(va)-.25 G 1.224 (luated in v).25 F 1.224(oid, scalar)-.2 F 3.724(,o)-.4 G 3.724(rl) -3.724 G 1.224(ist conte)-3.724 F 1.224(xt, depending on the conte)-.15 F 1.224(xt of the)-.15 F F1(eval)3.724 E F0 3.725(itself. See)3.725 F -.74(``)128 532.8 S -.1(wa).74 G(ntarray').1 E 2.5('f)-.74 G (or more on ho)-2.5 E 2.5(wt)-.25 G(he e)-2.5 E -.25(va)-.25 G (luation conte).25 E(xt can be determined.)-.15 E 1.093 (If there is a syntax error or runtime error)128 550.8 R 3.593(,o)-.4 G 3.593(ra)-3.593 G F1(die)A F0 1.093(statement is e)3.593 F -.15(xe)-.15 G(cuted,).15 E F1(eval)3.592 E F0(returns)3.592 E F1(undef)3.592 E F0 (in)3.592 E .69(scalar conte)128 562.8 R .69(xt or an empty list)-.15 F 1.666<8a6f>1.666 G 1.49 -.4(r, f)-1.666 H .691 (or syntax errors, a list containing a single unde\214ned v).4 F -.834 (alue \212 in)-.25 F .508(list conte)128 574.8 R .508(xt, and)-.15 F F1 ($@)3.008 E F0 .508(is set to the error message.)3.008 F .507 (The discrepanc)5.507 F 3.007(yi)-.15 G 3.007(nt)-3.007 G .507 (he return v)-3.007 F .507(alues in list conte)-.25 F .507(xt is)-.15 F .491(considered a b)128 586.8 R .491 (ug by some, and will probably be \214x)-.2 F .492 (ed in a future release.)-.15 F .492(If there w)5.492 F .492 (as no error)-.1 F(,)-.4 E F1($@)2.992 E F0(is)2.992 E 2.386 (guaranteed to be the empty string.)128 598.8 R(Be)7.386 E -.1(wa)-.25 G 2.386(re that using).1 F F1(eval)4.886 E F0 2.385 (neither silences Perl from printing)4.886 F -.1(wa)128 610.8 S .94 (rnings to).1 F F2(STDERR)3.44 E F0 3.44(,n)C .941(or does it stuf)-3.44 F 3.441(ft)-.25 G .941(he te)-3.441 F .941(xt of w)-.15 F .941 (arning messages into)-.1 F F1($@)3.441 E F0 5.941(.T)C 3.441(od)-6.741 G 3.441(oe)-3.441 G .941(ither of those,)-3.441 F 1.325(you ha)128 622.8 R 1.625 -.15(ve t)-.2 H 3.825(ou).15 G 1.325(se the)-3.825 F F1 -4.334 ($SIG{_ _WARN_ _})3.825 F F0 -.1(fa)3.825 G(cility).1 E 3.825(,o)-.65 G 3.825(rt)-3.825 G 1.325(urn of)-3.825 F 3.825(fw)-.25 G 1.325 (arnings inside the)-3.925 F F2(BLOCK)3.825 E F0(or)3.824 E F2(EXPR) 3.824 E F0(using)128 634.8 Q F1(no\302 warnings\302 \010all\010)2.5 E F0 5(.S)C(ee `)-5 E(`w)-.74 E(arn')-.1 E(', perlv)-.74 E(ar)-.25 E 2.5(,w) -.4 G(arnings and perlle)-2.6 E(xw)-.15 E(arn.)-.1 E .545 (Note that, because)128 652.8 R F1(eval)3.045 E F0 .546 (traps otherwise-f)3.045 F .546 (atal errors, it is useful for determining whether a particular)-.1 F 3.637(feature \(such as)128 664.8 R F1(socket)6.137 E F0(or)6.137 E F1 (symlink)6.137 E F0 6.137(\)i)C 6.137(si)-6.137 G 6.137(mplemented. It) -6.137 F 3.636(is also Perl')6.136 F 6.136(se)-.55 G(xception-trapping) -6.286 E(mechanism, where the die operator is used to raise e)128 676.8 Q(xceptions.)-.15 E .372(If you w)128 694.8 R .372 (ant to trap errors when loading an)-.1 F F2(XS)2.872 E F0 .372 (module, some problems with the binary interf)2.872 F .373(ace \(such) -.1 F .674(as Perl v)128 706.8 R .674(ersion sk)-.15 F -.25(ew)-.1 G 3.174(\)m).25 G .674(ay be f)-3.174 F .674(atal e)-.1 F -.15(ve)-.25 G 3.174(nw).15 G(ith)-3.174 E F1(eval)3.173 E F0(unless)3.173 E F1 ($ENV{PERL_DL_NONLAZY})3.173 E F0 .673(is set. See)3.173 F(perlrun.)128 718.8 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 20)162.62 F 0 Cg EP %%Page: 21 21 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.116 (If the code to be e)128 84 R -.15(xe)-.15 G 1.116(cuted doesn').15 F 3.616(tv)-.18 G(ary)-3.866 E 3.616(,y)-.65 G 1.116(ou may use the e) -3.616 F -.25(va)-.25 G 1.116(l-BLOCK form to trap run-time errors).25 F 1.797(without incurring the penalty of recompiling each time.)128 96 R 1.797(The error)6.797 F 4.297(,i)-.4 G 4.297(fa)-4.297 G -.15(ny)-4.297 G 4.297(,i)-.5 G 4.297(ss)-4.297 G 1.797(till returned in)-4.297 F/F1 10 /Courier@0 SF($@)4.296 E F0(.)A(Examples:)128 108 Q F1 6(#m)152 126 S (ake divide\255by\255zero nonfatal)-6 E (eval { $answer = $a / $b; }; warn $@ if $@;)152 138 Q 6(#s)152 162 S (ame thing, but less efficient)-6 E (eval \010$answer = $a / $b\010; warn $@ if $@;)152 174 Q 6(#ac)152 198 S(ompile\255time error)-6 E(eval { $answer = }; # WRONG)152 210 Q 6(#ar) 152 234 S(un\255time error)-6 E(eval \010$answer =\010;)152 246 Q 6(#s) 18 G(ets $@)-6 E F0 .794(Using the)128 264 R F1(eval{})3.294 E F0 .794 (form as an e)3.294 F .795(xception trap in libraries does ha)-.15 F 1.095 -.15(ve s)-.2 H .795(ome issues.).15 F .795(Due to the current) 5.795 F(ar)128 276 Q 1.12(guably brok)-.18 F 1.12(en state of)-.1 F F1 1.666(__)3.62 G -4.334(DIE_ _)-1.666 F F0 1.12 (hooks, you may wish not to trigger an)3.62 F(y)-.15 E F1 1.666(__)3.619 G -4.334(DIE_ _)-1.666 F F0 1.119(hooks that)3.619 F 2.782 (user code may ha)128 288 R 3.082 -.15(ve i)-.2 H 5.282(nstalled. Y).15 F 2.782(ou can use the)-1.1 F F1 2.782(local $SIG{_)5.282 F -4.334 (_DIE_ _})1.666 F F0 2.783(construct for this)5.282 F (purpose, as this e)128 300 Q(xample sho)-.15 E(ws:)-.25 E F1 6(#ap)152 318 S(rivate exception trap for divide\255by\255zero)-6 E (eval { local $SIG{\010_)152 330 Q -4.334(_DIE_ _\010};)1.666 F ($answer = $a / $b; };)6 E(warn $@ if $@;)152 342 Q F0 .381 (This is especially signi\214cant, gi)128 360 R -.15(ve)-.25 G 2.881(nt) .15 G(hat)-2.881 E F1 1.666(__)2.881 G -4.334(DIE_ _)-1.666 F F0 .381 (hooks can call)2.881 F F1(die)2.88 E F0(ag)2.88 E .38 (ain, which has the ef)-.05 F .38(fect of)-.25 F (changing their error messages:)128 372 Q F1 6(#_)152 390 S -4.334 (_DIE_ _)-4.334 F(hooks may modify error messages)6 E({)152 402 Q (local $SIG{\010_)170 414 Q -4.334(_DIE_ _\010})1.666 F(=)6 E (sub { \(my $x = $_[0]\) =~ s/foo/bar/g; die $x };)212 426 Q (eval { die "foo lives here" };)170 438 Q(print $@ if $@;)170 450 Q 6 (#p)96 G(rints "bar lives here")-6 E(})152 462 Q F0 1.557 (Because this promotes action at a distance, this counterintuiti)128 480 R 1.857 -.15(ve b)-.25 H(eha).15 E 1.558(vior may be \214x)-.2 F 1.558 (ed in a future)-.15 F(release.)128 492 Q -.4(Wi)128 510 S(th an).4 E F1 (eval)2.5 E F0 2.5(,y)C (ou should be especially careful to remember what')-2.5 E 2.5(sb)-.55 G (eing look)-2.5 E(ed at when:)-.1 E F1(eval $x;)152 528 Q 6(#C)48 G (ASE 1)-6 E(eval "$x";)152 540 Q 6(#C)36 G(ASE 2)-6 E(eval \010$x\010;) 152 564 Q 6(#C)36 G(ASE 3)-6 E(eval { $x };)152 576 Q 6(#C)24 G(ASE 4)-6 E(eval "\\$$x++";)152 600 Q 6(#C)12 G(ASE 5)-6 E 54($$x++; #)152 612 R (CASE 6)6 E F0 1.077(Cases 1 and 2 abo)128 630 R 1.377 -.15(ve b)-.15 H (eha).15 E 1.377 -.15(ve i)-.2 H 1.077(dentically: the).15 F 3.577(yr) -.15 G 1.077(un the code contained in the v)-3.577 F(ariable)-.25 E F1 ($x)3.576 E F0 6.076(.\()C(Although)-6.076 E .088 (case 2 has misleading double quotes making the reader w)128 642 R .089 (onder what else might be happening \(nothing)-.1 F 2.693(is\).\) Cases) 128 654 R 2.692(3a)2.693 G .192(nd 4 lik)-2.692 F -.25(ew)-.1 G .192 (ise beha).25 F .492 -.15(ve i)-.2 H 2.692(nt).15 G .192(he same w) -2.692 F .192(ay: the)-.1 F 2.692(yr)-.15 G .192(un the code)-2.692 F F1 <08247808>2.692 E F0 2.692(,w)C .192(hich does nothing b)-2.692 F(ut)-.2 E .451(return the v)128 666 R .451(alue of)-.25 F F1($x)2.951 E F0 5.451 (.\()C .451(Case 4 is preferred for purely visual reasons, b)-5.451 F .451(ut it also has the adv)-.2 F .452(antage of)-.25 F .143 (compiling at compile-time instead of at run-time.\))128 678 R .142 (Case 5 is a place where normally you)5.142 F/F2 10/Times-Italic@0 SF (would)2.642 E F0(lik)2.642 E 2.642(et)-.1 G(o)-2.642 E .11 (use double quotes, e)128 690 R .11(xcept that in this particular situa\ tion, you can just use symbolic references instead,)-.15 F (as in case 6.)128 702 Q .084(Before Perl 5.14, the assignment to)128 720 R F1($@)2.584 E F0 .083(occurred before restoration of localised v) 2.584 F .083(ariables, which means)-.25 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 21)162.62 F 0 Cg EP %%Page: 22 22 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .472 (that for your code to run on older v)128 84 R .473 (ersions, a temporary is required if you w)-.15 F .473 (ant to mask some b)-.1 F .473(ut not)-.2 F(all errors:)128 96 Q/F1 10 /Courier@0 SF 6(#a)152 114 S(lter $@ on nefarious repugnancy only)-6 E ({)152 126 Q(my $e;)170 138 Q({)170 150 Q (local $@; # protect existing $@)188 162 Q (eval { test_repugnancy\(\) };)188 174 Q 6(#$)188 186 S 6(@=)-6 G 6(~/) -6 G(nefarious/ and die $@; # Perl 5.14 and higher only)-6 E ($@ =~ /nefarious/ and $e = $@;)188 198 Q(})170 210 Q (die $e if defined $e)170 222 Q(})152 234 Q .247(eval BLOCK)128 252 R F0 (does)2.747 E/F2 10/Times-Italic@0 SF(not)2.747 E F0 .247 (count as a loop, so the loop control statements)2.747 F F1(next)2.746 E F0(,)A F1(last)2.746 E F0 2.746(,o)C(r)-2.746 E F1(redo)2.746 E F0 (cannot)2.746 E(be used to lea)128 264 Q .3 -.15(ve o)-.2 H 2.5(rr).15 G (estart the block.)-2.5 E(An)128 282 Q F1 1.13(eval \010\010)3.63 F F0 -.15(exe)3.63 G 1.13(cuted within the).15 F F1(DB)3.63 E F0 1.13 (package doesn')3.63 F 3.63(ts)-.18 G 1.13(ee the usual surrounding le) -3.63 F 1.13(xical scope, b)-.15 F(ut)-.2 E 1.195 (rather the scope of the \214rst non-DB piece of code that called it. Y) 128 294 R 1.195(ou don')-1.1 F 3.695(tn)-.18 G 1.195(ormally need to w) -3.695 F(orry)-.1 E(about this unless you are writing a Perl deb)128 306 Q(ugger)-.2 E(.)-.55 E -.15(exe)108 322.8 S(c).15 E/F3 9/Times-Roman@0 SF(LIST)2.5 E F0 -.15(exe)108 334.8 S(c).15 E F3(PR)2.5 E .25 (OGRAM LIST)-.36 F F0(The)128 346.8 Q F1(exec)3.258 E F0 .758 (function e)3.258 F -.15(xe)-.15 G .758(cutes a system command).15 F F2 .758(and ne)3.258 F .758(ver r)-.15 F(eturns)-.37 E F0 3.258(;u)C(se) -3.258 E F1(system)3.258 E F0 .758(instead of)3.258 F F1(exec)3.258 E F0 (if)3.258 E .668(you w)128 358.8 R .668(ant it to return.)-.1 F .668 (It f)5.668 F .668(ails and returns f)-.1 F .667 (alse only if the command does not e)-.1 F(xist)-.15 E F2(and)3.167 E F0 .667(it is e)3.167 F -.15(xe)-.15 G(cuted).15 E (directly instead of via your system')128 370.8 Q 2.5(sc)-.55 G (ommand shell \(see belo)-2.5 E(w\).)-.25 E .616(Since it')128 388.8 R 3.116(sac)-.55 G .616(ommon mistak)-3.116 F 3.116(et)-.1 G 3.116(ou) -3.116 G(se)-3.116 E F1(exec)3.116 E F0 .616(instead of)3.116 F F1 (system)3.116 E F0 3.116(,P)C .616(erl w)-3.116 F .616 (arns you if there is a follo)-.1 F(wing)-.25 E .154 (statement that isn')128 400.8 R(t)-.18 E F1(die)2.654 E F0(,)A F1(warn) 2.654 E F0 2.653(,o)C(r)-2.653 E F1(exit)2.653 E F0(\(if)2.653 E F1 2.653 E F0 .153(is set)2.653 F 1.666<8a62>1.666 G .153(ut you al) -1.866 F -.1(wa)-.1 G .153(ys do that, right?\).).1 F .153(If you)7.653 F F2 -.37(re)2.653 G(ally).37 E F0 -.1(wa)128 412.8 S 1.676(nt to follo) .1 F 4.176(wa)-.25 G(n)-4.176 E F1(exec)4.176 E F0 1.677 (with some other statement, you can use one of these styles to a)4.176 F -.2(vo)-.2 G 1.677(id the).2 F -.1(wa)128 424.8 S(rning:).1 E F1 (exec \(\010foo\010\))152 442.8 Q (or print STDERR "couldn\010t exec foo: $!";)18 E 6({e)152 454.8 S (xec \(\010foo\010\) }; print STDERR "couldn\010t exec foo: $!";)-6 E F0 1.364(If there is more than one ar)128 472.8 R 1.364(gument in)-.18 F F3 (LIST)3.864 E F0 3.864(,o)C 3.864(ri)-3.864 G(f)-3.864 E F3(LIST)3.864 E F0 1.364(is an array with more than one v)3.864 F 1.364(alue, calls)-.25 F F2 -.2(ex)128 484.8 S(ecvp).2 E F0 1.702(\(3\) with the ar)1.666 F 1.702(guments in)-.18 F F3(LIST)4.202 E F0 6.702(.I)C 4.202(ft)-6.702 G 1.702(here is only one scalar ar)-4.202 F 1.702 (gument or an array with one)-.18 F 2.404(element in it, the ar)128 496.8 R 2.404(gument is check)-.18 F 2.404 (ed for shell metacharacters, and if there are an)-.1 F 3.703 -.65(y, t) -.15 H 2.403(he entire).65 F(ar)128 508.8 Q 2.516 (gument is passed to the system')-.18 F 5.017(sc)-.55 G 2.517 (ommand shell for parsing \(this is)-5.017 F F1 2.517(/bin/sh \255c) 5.017 F F0 2.517(on Unix)5.017 F 1.107(platforms, b)128 520.8 R 1.107 (ut v)-.2 F 1.107(aries on other platforms\).)-.25 F 1.107 (If there are no shell metacharacters in the ar)6.107 F 1.106 (gument, it is)-.18 F(split into w)128 532.8 Q (ords and passed directly to)-.1 E F1(execvp)2.5 E F0 2.5(,w)C (hich is more ef)-2.5 E 2.5(\214cient. Examples:)-.25 F F1 (exec \010/bin/echo\010, \010Your arguments are: \010, @ARGV;)152 550.8 Q(exec "sort $outfile | uniq";)152 562.8 Q F0 .238(If you don')128 580.8 R 2.739(tr)-.18 G .239(eally w)-2.739 F .239(ant to e)-.1 F -.15(xe)-.15 G .239(cute the \214rst ar).15 F .239(gument, b)-.18 F .239(ut w)-.2 F .239(ant to lie to the program you are e)-.1 F -.15(xe)-.15 G(cuting).15 E 1.243(about its o)128 592.8 R 1.243 (wn name, you can specify the program you actually w)-.25 F 1.243 (ant to run as an `)-.1 F 1.242(`indirect object')-.74 F(')-.74 E .002 (\(without a comma\) in front of the)128 604.8 R F3(LIST)2.502 E F0 5.002(.\()C .002(This al)-5.002 F -.1(wa)-.1 G .003 (ys forces interpretation of the).1 F F3(LIST)2.503 E F0 .003 (as a multi)2.503 F -.25(va)-.25 G(lued).25 E(list, e)128 616.8 Q -.15 (ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G (here is only a single scalar in the list.\))-2.5 E(Example:)5 E F1 ($shell = \010/bin/csh\010;)152 634.8 Q(exec $shell \010\255sh\010;)152 646.8 Q 6(#p)24 G(retend it\010s a login shell)-6 E F0(or)128 664.8 Q 2.5(,m)-.4 G(ore directly)-2.5 E(,)-.65 E F1 (exec {\010/bin/csh\010} \010\255sh\010;)152 682.8 Q 6(#p)12 G (retend it\010s a login shell)-6 E F0 .124(When the ar)128 700.8 R .124 (guments get e)-.18 F -.15(xe)-.15 G .124(cuted via the system shell, r\ esults are subject to its quirks and capabilities.).15 F(See `)128 712.8 Q -.74(``)-.74 G(STRING`').74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlop for details.)-2.5 E .933(Using an indirect object with)128 730.8 R F1(exec)3.433 E F0(or)3.433 E F1(system)3.433 E F0 .933 (is also more secure.)3.433 F .933(This usage \(which also w)5.933 F (orks)-.1 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 22)162.62 F 0 Cg EP %%Page: 23 23 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .413(\214ne with) 128 84 R/F1 10/Times-Italic@0 SF(system\(\))2.913 E F0 2.913(\)f)C .413 (orces interpretation of the ar)-2.913 F .413(guments as a multi)-.18 F -.25(va)-.25 G .413(lued list, e).25 F -.15(ve)-.25 G 2.913(ni).15 G 2.913(ft)-2.913 G .413(he list had just)-2.913 F 1.113(one ar)128 96 R 3.613(gument. That)-.18 F -.1(wa)3.613 G 3.613(yy).1 G(ou')-3.613 E 1.113(re safe from the shell e)-.5 F 1.114 (xpanding wildcards or splitting up w)-.15 F 1.114(ords with)-.1 F (whitespace in them.)128 108 Q/F2 10/Courier@0 SF (@args = \( "echo surprise" \);)152 126 Q(exec @args;)152 150 Q 6(#s)90 G(ubject to shell escapes)-6 E 6(#i)320 162 S 6(f@)-6 G(args == 1)-6 E (exec { $args[0] } @args;)152 174 Q 6(#s)12 G (afe even with one\255arg list)-6 E F0 .601(The \214rst v)128 192 R .601 (ersion, the one without the indirect object, ran the)-.15 F F1(ec)3.1 E (ho)-.15 E F0 .6(program, passing it)3.1 F F2("surprise")3.1 E F0 .406 (an ar)128 204 R 2.906(gument. The)-.18 F .407(second v)2.907 F .407 (ersion didn')-.15 F .407(t; it tried to run a program named)-.18 F F1 -1.11(``)2.907 G(ec)1.11 E .407(ho surprise')-.15 F(')-1.11 E F0 2.907 (,d)C(idn')-2.907 E 2.907<748c>-.18 G(nd)-2.907 E(it, and set)128 216 Q F2($?)2.5 E F0(to a non-zero v)2.5 E(alue indicating f)-.25 E(ailure.) -.1 E(Be)128 234 Q .598(ginning with v5.6.0, Perl attempts to \215ush a\ ll \214les opened for output before the e)-.15 F -.15(xe)-.15 G .598 (c, b).15 F .598(ut this may)-.2 F 4.029 (not be supported on some platforms \(see perlport\).)128 246 R 5.629 -.8(To b)9.029 H 6.529(es).8 G 4.03(afe, you may need to set)-6.529 F F2 ($|)6.53 E F0(\($A)128 258 Q(UT)-.55 E 2.52 (OFLUSH in English\) or call the)-.18 F F2(autoflush\(\))5.02 E F0 2.52 (method of)5.02 F F2(IO::Handle)5.02 E F0 2.52(on an)5.02 F 5.02(yo)-.15 G(pen)-5.02 E(handles to a)128 270 Q -.2(vo)-.2 G(id lost output.).2 E (Note that)128 288 Q F2(exec)2.5 E F0(will not call your)2.5 E F2(END) 2.5 E F0(blocks, nor will it in)2.5 E -.2(vo)-.4 G -.1(ke).2 G F2 (DESTROY)2.6 E F0(methods on your objects.)2.5 E -.15(ex)108 304.8 S (ists).15 E/F3 9/Times-Roman@0 SF(EXPR)2.5 E F0(Gi)128 316.8 Q -.15(ve) -.25 G 3.7(na).15 G 3.7(ne)-3.7 G 1.2(xpression that speci\214es an ele\ ment of a hash, returns true if the speci\214ed element in the)-3.85 F (hash has e)128 328.8 Q -.15(ve)-.25 G 2.5(rb).15 G(een initialized, e) -2.5 E -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(he corresponding v)-2.5 E(alue is unde\214ned.)-.25 E F2(print "Exists\\n")152 346.8 Q (if exists $hash{$key};)24 E(print "Defined\\n")152 358.8 Q (if defined $hash{$key};)18 E(print "True\\n")152 370.8 Q (if $hash{$key};)36 E F0 -.15(ex)128 388.8 S .445 (ists may also be called on array elements, b).15 F .445(ut its beha)-.2 F .445(vior is much less ob)-.2 F .445(vious and is strongly tied)-.15 F .298(to the use of `)128 400.8 R(`delete')-.74 E 2.798('o)-.74 G 2.798 (na)-2.798 G(rrays.)-2.798 E/F4 10/Times-Bold@0 SF .298(Be awar)5.298 F (e)-.18 E F0 .298(that calling e)2.798 F .299(xists on array v)-.15 F .299(alues is deprecated and lik)-.25 F(ely)-.1 E(to be remo)128 412.8 Q -.15(ve)-.15 G 2.5(di).15 G 2.5(naf)-2.5 G(uture v)-2.5 E (ersion of Perl.)-.15 E F2(print "Exists\\n")152 430.8 Q (if exists $array[$index];)24 E(print "Defined\\n")152 442.8 Q (if defined $array[$index];)18 E(print "True\\n")152 454.8 Q (if $array[$index];)36 E F0 3.488(Ah)128 472.8 S .988 (ash or array element can be true only if it')-3.488 F 3.488(sd)-.55 G .988(e\214ned and de\214ned only if it e)-3.488 F .988(xists, b)-.15 F .988(ut the re)-.2 F -.15(ve)-.25 G(rse).15 E(doesn')128 484.8 Q 2.5(tn) -.18 G(ecessarily hold true.)-2.5 E(Gi)128 502.8 Q -.15(ve)-.25 G 2.646 (na).15 G 2.646(ne)-2.646 G .146(xpression that speci\214es the name of\ a subroutine, returns true if the speci\214ed subroutine has)-2.796 F -2.15 -.25(ev e)128 514.8 T 3.332(rb).25 G .832(een declared, e)-3.332 F -.15(ve)-.25 G 3.332(ni).15 G 3.331(fi)-3.332 G 3.331(ti)-3.331 G 3.331 (su)-3.331 G 3.331(nde\214ned. Mentioning)-3.331 F 3.331(as)3.331 G .831 (ubroutine name for e)-3.331 F .831(xists or de\214ned does)-.15 F .677 (not count as declaring it.)128 526.8 R .677 (Note that a subroutine that does not e)5.677 F .678 (xist may still be callable: its package)-.15 F .443(may ha)128 538.8 R .743 -.15(ve a)-.2 H(n).15 E F2(AUTOLOAD)2.943 E F0 .442 (method that mak)2.943 F .442(es it spring into e)-.1 F .442 (xistence the \214rst time that it is called; see)-.15 F(perlsub)128 550.8 Q(.)-.4 E F2(print "Exists\\n")152 568.8 Q(if exists &subroutine;) 12 E(print "Defined\\n" if defined &subroutine;)152 580.8 Q F0 .417 (Note that the)128 598.8 R F3(EXPR)2.917 E F0 .418(can be arbitrarily c\ omplicated as long as the \214nal operation is a hash or array k)2.917 F -.15(ey)-.1 G(lookup or subroutine name:)128 610.8 Q F2 (if \(exists $ref\255>{A}\255>{B}\255>{$key}\))152 628.8 Q 6({})12 G (if \(exists $hash{A}{B}{$key}\))152 640.8 Q 6({})42 G (if \(exists $ref\255>{A}\255>{B}\255>[$ix]\))152 664.8 Q 6({})18 G (if \(exists $hash{A}{B}[$ix]\))152 676.8 Q 6({})48 G (if \(exists &{$ref\255>{A}{B}{$key}}\))152 700.8 Q 6({})18 G F0 2.423 (Although the mostly deeply nested array or hash will not spring into e) 128 718.8 R 2.423(xistence just because its)-.15 F -.15(ex)128 730.8 S .164(istence w).15 F .164(as tested, an)-.1 F 2.664(yi)-.15 G(nterv) -2.664 E .164(ening ones will.)-.15 F(Thus)5.164 E F2($ref\255>{"A"}) 2.664 E F0(and)2.664 E F2($ref\255>{"A"}\255>{"B"})2.664 E F0 (perl v5.14.2)72 768 Q 198.17(2011-10-01 23)162.62 F 0 Cg EP %%Page: 24 24 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 2.484 (will spring into e)128 84 R 2.484(xistence due to the e)-.15 F 2.484 (xistence test for the)-.15 F/F1 10/Courier@0 SF($key)4.984 E F0 2.484 (element abo)4.984 F -.15(ve)-.15 G 7.484(.T).15 G 2.484(his happens) -7.484 F(an)128 96 Q(ywhere the arro)-.15 E 2.5(wo)-.25 G (perator is used, including e)-2.5 E -.15(ve)-.25 G 2.5(nh).15 G(ere:) -2.5 E F1(undef $ref;)152 114 Q(if \(exists $ref\255>{"Some key"}\))152 126 Q 6({})24 G(print $ref;)152 138 Q 6(#p)12 G(rints HASH\(0x80d3d5c\)) -6 E F0 1.076(This surprising auto)128 156 R(vi)-.15 E 1.077 (vi\214cation in what does not at \214rst)-.25 F 1.666<8a6f>1.666 G 3.577(re)-1.666 G -.15(ve)-3.827 G 3.577(ns).15 G -.834 (econd \212 glance)-3.577 F 1.077(appear to be an)3.577 F(lv)128 168 Q (alue conte)-.25 E(xt may be \214x)-.15 E(ed in a future release.)-.15 E (Use of a subroutine call, rather than a subroutine name, as an ar)128 186 Q(gument to)-.18 E/F2 10/Times-Italic@0 SF -.2(ex)2.5 G(ists\(\)).2 E F0(is an error)2.5 E(.)-.55 E F1(exists ⊂)152 204 Q 6(#O)24 G(K)-6 E(exists &sub\(\);)152 216 Q 6(#E)12 G(rror)-6 E F0 -.15(ex)108 232.8 S (it).15 E/F3 9/Times-Roman@0 SF(EXPR)2.5 E F0 -.15(ex)108 244.8 S(it).15 E(Ev)128 244.8 Q(aluates)-.25 E F3(EXPR)2.5 E F0(and e)2.5 E (xits immediately with that v)-.15 E 7.5(alue. Example:)-.25 F F1 ($ans = ;)152 262.8 Q(exit 0 if $ans =~ /^[Xx]/;)152 274.8 Q F0 1.285(See also)128 292.8 R F1(die)3.785 E F0 6.285(.I)C(f)-6.285 E F3 (EXPR)3.785 E F0 1.285(is omitted, e)3.785 F 1.285(xits with)-.15 F F1 (0)3.785 E F0 3.785(status. The)3.785 F 1.284(only uni)3.785 F -.15(ve) -.25 G 1.284(rsally recognized v).15 F 1.284(alues for)-.25 F F3(EXPR) 128 304.8 Q F0(are)3.699 E F1(0)3.699 E F0 1.199(for success and)3.699 F F1(1)3.7 E F0 1.2(for error; other v)3.7 F 1.2 (alues are subject to interpretation depending on the)-.25 F(en)128 316.8 Q .016(vironment in which the Perl program is running.)-.4 F -.15 (Fo)5.016 G 2.515(re).15 G .015(xample, e)-2.665 F .015(xiting 69 \() -.15 F F3(EX_UN)A -1.215(AVA)-.315 G(ILABLE)1.215 E F0 2.515(\)f)C(rom) -2.515 E(a)128 328.8 Q F2(sendmail)2.786 E F0 .286 (incoming-mail \214lter will cause the mailer to return the item undeli) 2.786 F -.15(ve)-.25 G .287(red, b).15 F .287(ut that')-.2 F 2.787(sn) -.55 G .287(ot true)-2.787 F -2.15 -.25(ev e)128 340.8 T(rywhere.).25 E (Don')128 358.8 Q 2.877(tu)-.18 G(se)-2.877 E F1(exit)2.877 E F0 .377 (to abort a subroutine if there')2.877 F 2.876(sa)-.55 G .676 -.15(ny c) -2.876 H .376(hance that someone might w).15 F .376(ant to trap whate) -.1 F -.15(ve)-.25 G(r).15 E(error happened.)128 370.8 Q(Use)5 E F1(die) 2.5 E F0(instead, which can be trapped by an)2.5 E F1(eval)2.5 E F0(.)A (The)128 388.8 Q F2 -.2(ex)2.797 G(it\(\)).2 E F0 .297 (function does not al)2.797 F -.1(wa)-.1 G .297(ys e).1 F .297 (xit immediately)-.15 F 5.297(.I)-.65 G 2.798(tc)-5.297 G .298(alls an) -2.798 F 2.798(yd)-.15 G(e\214ned)-2.798 E F1(END)2.798 E F0 .298 (routines \214rst, b)2.798 F .298(ut these)-.2 F F1(END)128 400.8 Q F0 .061(routines may not themselv)2.561 F .061(es abort the e)-.15 F 2.561 (xit. Lik)-.15 F -.25(ew)-.1 G .061(ise an).25 F 2.561(yo)-.15 G .06 (bject destructors that need to be called)-2.561 F .69 (are called before the real e)128 412.8 R(xit.)-.15 E F1(END)5.69 E F0 .691(routines and destructors can change the e)3.191 F .691 (xit status by modifying)-.15 F F1($?)128 424.8 Q F0 4.544(.I)C 4.544 (ft)-4.544 G 2.043(his is a problem, you can call)-4.544 F F1 (POSIX:_exit\($status\))4.543 E F0 2.043(to a)4.543 F -.2(vo)-.2 G(id).2 E F3(END)4.543 E F0 2.043(and destructor)4.543 F 2.5(processing. See)128 436.8 R(perlmod for details.)2.5 E -.15(ex)108 453.6 S(p).15 E F3(EXPR) 2.5 E F0 -.15(ex)108 465.6 S(p).15 E(Returns)128 465.6 Q F2(e)2.5 E F0 (\(the natural log)2.5 E(arithm base\) to the po)-.05 E(wer of)-.25 E F3 (EXPR)2.5 E F0 5(.I)C(f)-5 E F3(EXPR)2.5 E F0(is omitted, gi)2.5 E -.15 (ve)-.25 G(s).15 E F1(exp\($_\))2.5 E F0(.)A(fcntl)108 482.4 Q F3 (FILEHANDLE)2.5 E F0(,FUNCTION,SCALAR)A(Implements the)128 494.4 Q F2 (fcntl)2.5 E F0(\(2\) function.)1.666 E -1.1(Yo)5 G(u')1.1 E (ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1 (use Fcntl;)152 512.4 Q F0 1.342 (\214rst to get the correct constant de\214nitions.)128 530.4 R(Ar)6.342 E 1.342(gument processing and v)-.18 F 1.342(alue returned w)-.25 F 1.343(ork just lik)-.1 F(e)-.1 E F1(ioctl)128 542.4 Q F0(belo)2.5 E 3.8 -.65(w. F)-.25 H(or e).5 E(xample:)-.15 E F1(use Fcntl;)152 560.4 Q (fcntl\($filehandle, F_GETFL, $packed_return_buffer\))152 572.4 Q (or die "can\010t fcntl F_GETFL: $!";)176 584.4 Q F0 -1.1(Yo)128 602.4 S 3.3(ud)1.1 G(on')-3.3 E 3.3(th)-.18 G -2.25 -.2(av e)-3.3 H .8 (to check for)3.5 F F1(defined)3.3 E F0 .8(on the return from)3.3 F F1 (fcntl)3.3 E F0 5.8(.L)C(ik)-5.8 E(e)-.1 E F1(ioctl)3.3 E F0 3.3(,i)C 3.3(tm)-3.3 G .8(aps a)-3.3 F F1(0)3.3 E F0(return)3.3 E 1.023 (from the system call into)128 614.4 R F1 1.023("0 but true")3.523 F F0 1.023(in Perl.)3.523 F 1.023(This string is true in boolean conte)6.023 F 1.024(xt and)-.15 F F1(0)3.524 E F0(in)3.524 E(numeric conte)128 626.4 Q 2.5(xt. It)-.15 F(is also e)2.5 E -.15(xe)-.15 G(mpt from the normal) .15 E/F4 10/Times-Bold@0 SF2.5 E F0 -.1(wa)2.5 G (rnings on improper numeric con).1 E -.15(ve)-.4 G(rsions.).15 E .879 (Note that)128 644.4 R F1(fcntl)3.379 E F0 .879(raises an e)3.379 F .878 (xception if used on a machine that doesn')-.15 F 3.378(ti)-.18 G (mplement)-3.378 E F2(fcntl)3.378 E F0 3.378(\(2\). See)1.666 F(the) 3.378 E(Fcntl module or your)128 656.4 Q F2(fcntl)2.5 E F0 (\(2\) manpage to learn what functions are a)1.666 E -.25(va)-.2 G (ilable on your system.).25 E(Here')128 674.4 Q 4.125(sa)-.55 G 4.125 (ne)-4.125 G 1.625(xample of setting a \214lehandle named)-4.275 F F1 (REMOTE)4.125 E F0 1.626(to be non-blocking at the system le)4.125 F -.15(ve)-.25 G(l.).15 E -1.1(Yo)128 686.4 S(u')1.1 E(ll ha)-.1 E .3 -.15 (ve t)-.2 H 2.5(on).15 G -.15(eg)-2.5 G(otiate).15 E F1($|)2.5 E F0 (on your o)2.5 E(wn, though.)-.25 E F1 (use Fcntl qw\(F_GETFL F_SETFL O_NONBLOCK\);)152 704.4 Q ($flags = fcntl\(REMOTE, F_GETFL, 0\))152 728.4 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 24)162.62 F 0 Cg EP %%Page: 25 25 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (or die "Can\010t get flags for the socket: $!\\n";)224 84 Q ($flags = fcntl\(REMOTE, F_SETFL, $flags | O_NONBLOCK\))152 108 Q (or die "Can\010t set flags for the socket: $!\\n";)224 120 Q F0 (\214leno)108 136.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0 .138(Re\ turns the \214le descriptor for a \214lehandle, or unde\214ned if the \ \214lehandle is not open.)128 148.8 R .138(If there is no real)5.138 F .521(\214le descriptor at the)128 160.8 R F2(OS)3.021 E F0(le)3.022 E -.15(ve)-.25 G .522 (l, as can happen with \214lehandles connected to memory objects via).15 F F1(open)3.022 E F0(with a reference for the third ar)128 172.8 Q (gument, \2551 is returned.)-.18 E 3.204 (This is mainly useful for constructing bitmaps for)128 190.8 R F1 (select)5.704 E F0 3.204(and lo)5.704 F(w-le)-.25 E -.15(ve)-.25 G(l).15 E F2(POSIX)5.704 E F0(tty-handling)5.704 E 2.845(operations. If)128 202.8 R F2(FILEHANDLE)2.845 E F0 .345(is an e)2.845 F .345 (xpression, the v)-.15 F .345(alue is tak)-.25 F .346 (en as an indirect \214lehandle, generally its)-.1 F(name.)128 214.8 Q -1.1(Yo)128 232.8 S 2.5(uc)1.1 G(an use this to \214nd out whether tw) -2.5 E 2.5(oh)-.1 G(andles refer to the same underlying descriptor:)-2.5 E F1(if \(fileno\(THIS\) == fileno\(THAT\)\) {)152 250.8 Q (print "THIS and THAT are dups\\n";)176 262.8 Q(})152 274.8 Q F0 (\215ock)108 291.6 Q F2(FILEHANDLE)2.5 E F0(,OPERA)A(TION)-1.11 E(Calls) 128 303.6 Q/F3 10/Times-Italic@0 SF(\215oc)4.247 E(k)-.2 E F0 1.747 (\(2\), or an emulation of it, on)1.666 F F2(FILEHANDLE)4.246 E F0 6.746 (.R)C 1.746(eturns true for success, f)-6.746 F 1.746(alse on f)-.1 F (ailure.)-.1 E 2.003(Produces a f)128 315.6 R 2.004 (atal error if used on a machine that doesn')-.1 F 4.504(ti)-.18 G (mplement)-4.504 E F3(\215oc)4.504 E(k)-.2 E F0(\(2\),)1.666 E F3(fcntl) 4.504 E F0 2.004(\(2\) locking, or)1.666 F F3(loc)128 327.6 Q(kf)-.2 E F0(\(3\).)1.666 E F1(flock)7.516 E F0 2.516(is Perl')5.016 F 5.016(sp) -.55 G 2.516(ortable \214le-locking interf)-5.016 F 2.516 (ace, although it locks entire \214les only)-.1 F 5.015(,n)-.65 G(ot) -5.015 E(records.)128 339.6 Q -1 -.8(Tw o)128 357.6 T 1.262 (potentially non-ob)4.562 F 1.262(vious b)-.15 F 1.262(ut traditional) -.2 F F1(flock)3.762 E F0 1.262(semantics are that it w)3.762 F 1.263 (aits inde\214nitely until the)-.1 F .093 (lock is granted, and that its locks are)128 369.6 R/F4 10/Times-Bold@0 SF(mer)2.593 E .092(ely advisory)-.18 F F0 5.092(.S)C .092 (uch discretionary locks are more \215e)-5.092 F .092(xible, b)-.15 F (ut)-.2 E(of)128 381.6 Q 1.93(fer fe)-.25 F 1.93(wer guarantees.)-.25 F 1.93(This means that programs that do not also use)6.93 F F1(flock)4.43 E F0 1.93(may modify \214les)4.43 F(lock)128 393.6 Q .55(ed with)-.1 F F1(flock)3.05 E F0 5.549(.S)C .549(ee perlport, your port')-5.549 F 3.049(ss)-.55 G .549 (peci\214c documentation, and your system-speci\214c local)-3.049 F 1.622(manpages for details.)128 405.6 R(It')6.622 E 4.122(sb)-.55 G 1.622(est to assume traditional beha)-4.122 F 1.622(vior if you')-.2 F 1.623(re writing portable programs.)-.5 F 3.366(\(But if you')128 417.6 R 3.366(re not, you should as al)-.5 F -.1(wa)-.1 G 3.365 (ys feel perfectly free to write for your o).1 F 3.365(wn system')-.25 F (s)-.55 E .394(idiosyncrasies \(sometimes called `)128 429.6 R (`features')-.74 E 2.894('\). Sla)-.74 F .394 (vish adherence to portability concerns shouldn')-.2 F 2.894(tg)-.18 G (et)-2.894 E(in the w)128 441.6 Q(ay of your getting your job done.\)) -.1 E F2(OPERA)128 459.6 Q(TION)-.999 E F0 .193(is one of)2.693 F F2 (LOCK_SH)2.692 E F0(,)A F2(LOCK_EX)2.692 E F0 2.692(,o)C(r)-2.692 E F2 (LOCK_UN)2.692 E F0 2.692(,p)C .192(ossibly combined with)-2.692 F F2 (LOCK_NB)2.692 E F0 5.192(.T)C(hese)-5.192 E .043 (constants are traditionally v)128 471.6 R .043(alued 1, 2, 8 and 4, b) -.25 F .043(ut you can use the symbolic names if you import them)-.2 F .333(from the Fcntl module, either indi)128 483.6 R(vidually)-.25 E 2.833(,o)-.65 G 2.833(ra)-2.833 G 2.833(sa)-2.833 G .332 (group using the)-.001 F F1(:flock)2.832 E F0(tag.)2.832 E F2(LOCK_SH) 5.332 E F0 .332(requests a)2.832 F .077(shared lock,)128 495.6 R F2 (LOCK_EX)2.577 E F0 .077(requests an e)2.577 F(xclusi)-.15 E .377 -.15 (ve l)-.25 H .077(ock, and).15 F F2(LOCK_UN)2.577 E F0 .077 (releases a pre)2.577 F .077(viously requested lock.)-.25 F(If)128 507.6 Q F2(LOCK_NB)3.787 E F0 1.287(is bitwise-or'ed with)3.787 F F2(LOCK_SH) 3.786 E F0(or)3.786 E F2(LOCK_EX)3.786 E F0 3.786(,t)C(hen)-3.786 E F1 (flock)3.786 E F0 1.286(returns immediately rather)3.786 F (than blocking w)128 519.6 Q (aiting for the lock; check the return status to see if you got it.)-.1 E 4.885 -.8(To a)128 537.6 T -.2(vo).6 G 3.285 (id the possibility of miscoordination, Perl no).2 F 5.785<778d>-.25 G (ushes)-5.785 E F2(FILEHANDLE)5.785 E F0 3.285(before locking or)5.785 F (unlocking it.)128 549.6 Q 3.234(Note that the emulation b)128 567.6 R 3.234(uilt with)-.2 F F3(loc)5.734 E(kf)-.2 E F0 3.234(\(3\) doesn') 1.666 F 5.734(tp)-.18 G(ro)-5.734 E 3.234 (vide shared locks, and it requires that)-.15 F F2(FILEHANDLE)128 579.6 Q F0 .883(be open with write intent.)3.383 F .883 (These are the semantics that)5.883 F F3(loc)3.383 E(kf)-.2 E F0 .884 (\(3\) implements.)1.666 F .884(Most if)5.884 F 1.407 (not all systems implement)128 591.6 R F3(loc)3.907 E(kf)-.2 E F0 1.407 (\(3\) in terms of)1.666 F F3(fcntl)3.907 E F0 1.407 (\(2\) locking, though, so the dif)1.666 F 1.407(fering semantics)-.25 F (shouldn')128 603.6 Q 2.5(tb)-.18 G(ite too man)-2.5 E 2.5(yp)-.15 G (eople.)-2.5 E .183(Note that the)128 621.6 R F3(fcntl)2.683 E F0 .183 (\(2\) emulation of)1.666 F F3(\215oc)2.684 E(k)-.2 E F0 .184 (\(3\) requires that)1.666 F F2(FILEHANDLE)2.684 E F0 .184 (be open with read intent to use)2.684 F F2(LOCK_SH)128 633.6 Q F0 (and requires that it be open with write intent to use)2.5 E F2(LOCK_EX) 2.5 E F0(.)A .763(Note also that some v)128 651.6 R .763(ersions of)-.15 F F1(flock)3.263 E F0 .763(cannot lock things o)3.263 F -.15(ve)-.15 G 3.263(rt).15 G .763(he netw)-3.263 F .763(ork; you w)-.1 F .763 (ould need to use)-.1 F 1.731(the more system-speci\214c)128 663.6 R F1 (fcntl)4.232 E F0 1.732(for that.)4.232 F 1.732(If you lik)6.732 F 4.232 (ey)-.1 G 1.732(ou can force Perl to ignore your system')-4.232 F(s)-.55 E F3(\215oc)128 675.6 Q(k)-.2 E F0 4.473(\(2\) function, and so pro) 1.666 F 4.472(vide its o)-.15 F(wn)-.25 E F3(fcntl)6.972 E F0 4.472 (\(2\)\255based emulation, by passing the switch)1.666 F F1 (\255Ud_flock)128 687.6 Q F0(to the)2.5 E F3(Con\214gur)2.5 E(e)-.37 E F0(program when you con\214gure and b)2.5 E(uild a ne)-.2 E 2.5(wP)-.25 G(erl.)-2.5 E(Here')128 705.6 Q 2.5(sam)-.55 G(ailbox appender for)-2.5 E F2(BSD)2.5 E F0(systems.)2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 25)162.62 F 0 Cg EP %%Page: 26 26 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Fcntl qw\(:flock SEEK_END\); # import LOCK_* and SEEK_END constant\ s)152 84 Q(sub lock {)152 108 Q(my \($fh\) = @_;)176 120 Q (flock\($fh, LOCK_EX\) or die "Cannot lock mailbox \255 $!\\n";)176 132 Q 6(#a)176 156 S(nd, in case someone appended while we were waiting...) -6 E(seek\($fh, 0, SEEK_END\) or die "Cannot seek \255 $!\\n";)176 168 Q (})152 180 Q(sub unlock {)152 204 Q(my \($fh\) = @_;)176 216 Q (flock\($fh, LOCK_UN\) or die "Cannot unlock mailbox \255 $!\\n";)176 228 Q(})152 240 Q (open\(my $mbox, ">>", "/usr/spool/mail/$ENV{\010USER\010}"\))152 264 Q (or die "Can\010t open mailbox: $!";)176 276 Q(lock\($mbox\);)152 300 Q (print $mbox $msg,"\\n\\n";)152 312 Q(unlock\($mbox\);)152 324 Q F0 .212 (On systems that support a real)128 342 R/F2 10/Times-Italic@0 SF (\215oc)2.712 E(k)-.2 E F0 .212(\(2\), locks are inherited across)1.666 F F2(fork\(\))2.712 E F0 .212(calls, whereas those that must)2.712 F 1.471(resort to the more capricious)128 354 R F2(fcntl)3.97 E F0 1.47 (\(2\) function lose their locks, making it seriously harder to write) 1.666 F(serv)128 366 Q(ers.)-.15 E(See also DB_File for other)128 384 Q F2(\215oc)2.5 E(k\(\))-.2 E F0 -.15(ex)2.5 G(amples.).15 E(fork)108 400.8 Q 1.024(Does a)128 412.8 R F2(fork)3.524 E F0 1.024 (\(2\) system call to create a ne)1.666 F 3.525(wp)-.25 G 1.025 (rocess running the same program at the same point.)-3.525 F(It)6.025 E .115(returns the child pid to the parent process,)128 424.8 R F1(0)2.614 E F0 .114(to the child process, or)2.614 F F1(undef)2.614 E F0 .114 (if the fork is unsuccessful.)2.614 F .057(File descriptors \(and somet\ imes locks on those descriptors\) are shared, while e)128 436.8 R -.15 (ve)-.25 G .058(rything else is copied.).15 F 2.695 (On most systems supporting)128 448.8 R F2(fork\(\))5.195 E F0 5.195(,g) C 2.695(reat care has gone into making it e)-5.195 F 2.695(xtremely ef) -.15 F 2.695(\214cient \(for)-.25 F -.15(ex)128 460.8 S 2.738 (ample, using cop).15 F 2.738(y-on-write technology on data pages\), ma\ king it the dominant paradigm for)-.1 F(multitasking o)128 472.8 Q -.15 (ve)-.15 G 2.5(rt).15 G(he last fe)-2.5 E 2.5(wd)-.25 G(ecades.)-2.5 E (Be)128 490.8 Q 2.033(ginning with v5.6.0, Perl attempts to \215ush all\ \214les opened for output before forking the child)-.15 F .324 (process, b)128 502.8 R .324 (ut this may not be supported on some platforms \(see perlport\).)-.2 F 1.925 -.8(To b)5.325 H 2.825(es).8 G .325(afe, you may need to)-2.825 F (set)128 514.8 Q F1($|)2.653 E F0(\($A)2.653 E(UT)-.55 E .152 (OFLUSH in English\) or call the)-.18 F F1(autoflush\(\))2.652 E F0 .152 (method of)2.652 F F1(IO::Handle)2.652 E F0 .152(on an)2.652 F 2.652(yo) -.15 G(pen)-2.652 E(handles to a)128 526.8 Q -.2(vo)-.2 G (id duplicate output.).2 E .402(If you)128 544.8 R F1(fork)2.902 E F0 .402(without e)2.902 F -.15(ve)-.25 G 2.902(rw).15 G .403 (aiting on your children, you will accumulate zombies.)-3.002 F .403 (On some systems,)5.403 F 1.028(you can a)128 556.8 R -.2(vo)-.2 G 1.028 (id this by setting).2 F F1($SIG{CHLD})3.528 E F0(to)3.528 E F1 ("IGNORE")3.528 E F0 6.028(.S)C 1.028(ee also perlipc for more e)-6.028 F 1.028(xamples of)-.15 F(forking and reaping morib)128 568.8 Q (und children.)-.2 E .154(Note that if your fork)128 586.8 R .155 (ed child inherits system \214le descriptors lik)-.1 F(e)-.1 E/F3 9 /Times-Roman@0 SF(STDIN)2.655 E F0(and)2.655 E F3(STDOUT)2.655 E F0 .155 (that are actually)2.655 F .476(connected by a pipe or sock)128 598.8 R .476(et, e)-.1 F -.15(ve)-.25 G 2.976(ni).15 G 2.976(fy)-2.976 G .476 (ou e)-2.976 F .476(xit, then the remote serv)-.15 F .476 (er \(such as, say)-.15 F 2.976(,a)-.65 G F3(CGI)-.001 E F0 .475 (script or a)2.975 F .17 (backgrounded job launched from a remote shell\) w)128 610.8 R(on')-.1 E 2.671(tt)-.18 G .171(hink you')-2.671 F .171(re done.)-.5 F -1.1(Yo) 5.171 G 2.671(us)1.1 G .171(hould reopen those to)-2.671 F F2(/de)128 622.8 Q(v/null)-.15 E F0(if it')2.5 E 2.5(sa)-.55 G .3 -.15(ny i)-2.5 H (ssue.).15 E(format)108 639.6 Q(Declare a picture format for use by the) 128 651.6 Q F1(write)2.5 E F0 2.5(function. F)2.5 F(or e)-.15 E(xample:) -.15 E F1(format Something =)152 669.6 Q(Test: @<<<<<<<< @||||| @>>>>>) 176 681.6 Q 24($str, $%,)212 693.6 R(\010$\010 . int\($num\))24 E(.)152 705.6 Q($str = "widget";)152 729.6 Q F0(perl v5.14.2)72 768 Q 198.17 (2011-10-01 26)162.62 F 0 Cg EP %%Page: 27 27 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($num = $cost/$quantity;)152 84 Q($~ = \010Something\010;)152 96 Q (write;)152 108 Q F0(See perlform for man)128 126 Q 2.5(yd)-.15 G (etails and e)-2.5 E(xamples.)-.15 E(formline)108 142.8 Q/F2 9 /Times-Roman@0 SF(PICTURE)2.5 E F0(,LIST)A .151 (This is an internal function used by)128 154.8 R F1(format)2.651 E F0 .151(s, though you may call it, too.)B .15 (It formats \(see perlform\) a)5.15 F 2.688(list of v)128 166.8 R 2.688 (alues according to the contents of)-.25 F F2(PICTURE)5.188 E F0 5.189 (,p)C 2.689(lacing the output into the format output)-5.189 F (accumulator)128 178.8 Q(,)-.4 E F1($^A)2.835 E F0(\(or)2.835 E F1 ($ACCUMULATOR)2.835 E F0 .335(in English\).)2.835 F(Ev)5.335 E(entually) -.15 E 2.835(,w)-.65 G .335(hen a)-2.835 F F1(write)2.834 E F0 .334 (is done, the contents)2.834 F(of)128 190.8 Q F1($^A)3.066 E F0 .567 (are written to some \214lehandle.)3.066 F -1.1(Yo)5.567 G 3.067(uc)1.1 G .567(ould also read)-3.067 F F1($^A)3.067 E F0 .567(and then set)3.067 F F1($^A)3.067 E F0 .567(back to)3.067 F F1("")3.067 E F0 5.567(.N)C (ote)-5.567 E 1.898(that a format typically does one)128 202.8 R F1 (formline)4.397 E F0 1.897(per line of form, b)4.397 F 1.897(ut the)-.2 F F1(formline)4.397 E F0 1.897(function itself)4.397 F(doesn')128 214.8 Q 2.761(tc)-.18 G .261(are ho)-2.761 F 2.761(wm)-.25 G(an)-2.761 E 2.761 (yn)-.15 G -.25(ew)-2.761 G .261(lines are embedded in the).25 F F2 (PICTURE)2.761 E F0 5.261(.T)C .261(his means that the)-5.261 F F1(~) 2.761 E F0(and)2.761 E F1(~~)2.761 E F0(tok)2.761 E(ens)-.1 E 2.263 (treat the entire)128 226.8 R F2(PICTURE)4.763 E F0 2.263 (as a single line.)4.763 F -1.1(Yo)7.263 G 4.763(um)1.1 G 2.263 (ay therefore need to use multiple formlines to)-4.763 F (implement a single record format, just lik)128 238.8 Q 2.5(et)-.1 G(he) -2.5 E F1(format)2.5 E F0(compiler)2.5 E(.)-.55 E .514 (Be careful if you put double quotes around the picture, because an)128 256.8 R F1(@)3.015 E F0 .515(character may be tak)3.015 F .515 (en to mean)-.1 F(the be)128 268.8 Q(ginning of an array name.)-.15 E F1 (formline)5 E F0(al)2.5 E -.1(wa)-.1 G(ys returns true.).1 E (See perlform for other e)5 E(xamples.)-.15 E .653 (If you are trying to use this instead of)128 286.8 R F1(write)3.153 E F0 .653(to capture the output, you may \214nd it easier to open a)3.153 F(\214lehandle to a scalar \()128 298.8 Q F1(open $fh, ">", \\$output)A F0 2.5(\)a)C(nd write to that instead.)-2.5 E(getc)108 315.6 Q F2 (FILEHANDLE)2.5 E F0(getc)108 327.6 Q .456(Returns the ne)128 339.6 R .457(xt character from the input \214le attached to)-.15 F F2 (FILEHANDLE)2.957 E F0 2.957(,o)C 2.957(rt)-2.957 G .457 (he unde\214ned v)-2.957 F .457(alue at end)-.25 F 1.001 (of \214le or if there w)128 351.6 R 1.001 (as an error \(in the latter case)-.1 F F1($!)3.501 E F0 1.001 (is set\).)3.501 F(If)6.001 E F2(FILEHANDLE)3.501 E F0 1.001 (is omitted, reads from)3.501 F F2(STDIN)128 363.6 Q F0 7.826(.T)C 2.827 (his is not particularly ef)-7.826 F 5.327(\214cient. Ho)-.25 F(we)-.25 E -.15(ve)-.25 G 3.627 -.4(r, i).15 H 5.327(tc).4 G 2.827 (annot be used by itself to fetch single)-5.327 F(characters without w) 128 375.6 Q(aiting for the user to hit enter)-.1 E 5(.F)-.55 G (or that, try something more lik)-5.15 E(e:)-.1 E F1 (if \($BSD_STYLE\) {)152 393.6 Q (system "stty cbreak /dev/tty 2>&1";)176 405.6 Q(})152 417.6 Q(else {)152 429.6 Q (system "stty", \010\255icanon\010, \010eol\010, "\\001";)176 441.6 Q(}) 152 453.6 Q($key = getc\(STDIN\);)152 477.6 Q(if \($BSD_STYLE\) {)152 501.6 Q(system "stty \255cbreak /dev/tty 2>&1";)176 513.6 Q (})152 525.6 Q(else {)152 537.6 Q(system \010stty\010, \010icanon\010, \ \010eol\010, \010^@\010; # ASCII NUL)176 549.6 Q(})152 561.6 Q (print "\\n";)152 573.6 Q F0(Determination of whether)128 591.6 Q F1 ($BSD_STYLE)2.5 E F0(should be set is left as an e)2.5 E -.15(xe)-.15 G (rcise to the reader).15 E(.)-.55 E(The)128 609.6 Q F1(POSIX::getattr) 7.002 E F0 4.502 (function can do this more portably on systems purporting)7.002 F F2 (POSIX)7.001 E F0 3.454(compliance. See)128 621.6 R .954(also the)3.454 F F1(Term::ReadKey)3.454 E F0 .955(module from your nearest)3.454 F F2 (CP)3.455 E(AN)-.828 E F0 .955(site; details on)3.455 F F2(CP)3.455 E (AN)-.828 E F0(can be found under `)128 633.6 Q(`)-.74 E F2(CP)A(AN) -.828 E F0 1.48 -.74('' i)D 2.5(np).74 G(erlmodlib)-2.5 E(.)-.4 E (getlogin)108 650.4 Q .596(This implements the C library function of th\ e same name, which on most systems returns the current)128 662.4 R (login from)128 674.4 Q/F3 10/Times-Italic@0 SF(/etc/utmp)2.5 E F0 2.5 (,i)C 2.5(fa)-2.5 G -.15(ny)-2.5 G 5(.I)-.5 G 2.5(fi)-5 G 2.5(tr)-2.5 G (eturns the empty string, use)-2.5 E F1(getpwuid)2.5 E F0(.)A F1 ($login = getlogin || getpwuid\($<\) || "Kilroy";)152 692.4 Q F0 (Do not consider)128 710.4 Q F1(getlogin)2.5 E F0 (for authentication: it is not as secure as)2.5 E F1(getpwuid)2.5 E F0 (.)A(perl v5.14.2)72 768 Q 198.17(2011-10-01 27)162.62 F 0 Cg EP %%Page: 28 28 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(getpeername)108 84 Q/F1 9/Times-Roman@0 SF(SOCKET)2.5 E F0(Returns the pack)128 96 Q (ed sockaddr address of the other end of the)-.1 E F1(SOCKET)2.5 E F0 (connection.)2.5 E/F2 10/Courier@0 SF(use Socket;)152 114 Q 18 ($hersockaddr =)152 126 R(getpeername\(SOCK\);)6 E (\($port, $iaddr\) = sockaddr_in\($hersockaddr\);)152 138 Q 18 ($herhostname =)152 150 R(gethostbyaddr\($iaddr, AF_INET\);)6 E 24 ($herstraddr =)152 162 R(inet_ntoa\($iaddr\);)6 E F0(getpgrp)108 178.8 Q F1(PID)2.5 E F0 1.319 (Returns the current process group for the speci\214ed)128 190.8 R F1 (PID)3.819 E F0 6.32(.U)C 1.32(se a)-6.32 F F1(PID)3.82 E F0(of)3.82 E F2(0)3.82 E F0 1.32(to get the current process)3.82 F 1.079 (group for the current process.)128 202.8 R -.4(Wi)6.078 G 1.078 (ll raise an e).4 F 1.078(xception if used on a machine that doesn')-.15 F 3.578(ti)-.18 G(mplement)-3.578 E/F3 10/Times-Italic@0 SF -.1(ge)128 214.8 S(tpgrp).1 E F0 3.246(\(2\). If)1.666 F F1(PID)3.246 E F0 .746 (is omitted, returns the process group of the current process.)3.246 F .747(Note that the)5.747 F F1(POSIX)3.247 E F0 -.15(ve)128 226.8 S (rsion of).15 E F2(getpgrp)2.5 E F0(does not accept a)2.5 E F1(PID)2.5 E F0(ar)2.5 E(gument, so only)-.18 E F2(PID==0)2.5 E F0 (is truly portable.)2.5 E(getppid)108 243.6 Q (Returns the process id of the parent process.)128 255.6 Q .456 (Note for Linux users: on Linux, the C functions)128 273.6 R F2 (getpid\(\))2.956 E F0(and)2.956 E F2(getppid\(\))2.955 E F0 .455 (return dif)2.955 F .455(ferent v)-.25 F(alues)-.25 E .495(from dif)128 285.6 R .495(ferent threads. In order to be portable, this beha)-.25 F .496(vior is not re\215ected by the Perl-le)-.2 F -.15(ve)-.25 G 2.996 (lf).15 G(unction)-2.996 E F2(getppid\(\))128 297.6 Q F0 5.125(,t)C 2.625(hat returns a consistent v)-5.125 F 2.624 (alue across threads. If you w)-.25 F 2.624(ant to call the underlying) -.1 F F2(getppid\(\))128 309.6 Q F0 2.5(,y)C(ou may use the)-2.5 E F1 (CP)2.5 E(AN)-.828 E F0(module)2.5 E F2(Linux::Pid)2.5 E F0(.)A (getpriority)108 326.4 Q F1(WHICH)2.5 E F0(,WHO)A .176 (Returns the current priority for a process, a process group, or a user) 128 338.4 R 5.176(.\()-.55 G(See)-5.176 E F2(getpriority\(2\))2.676 E F0 2.676(.\) W)B(ill)-.4 E(raise a f)128 350.4 Q(atal e)-.1 E (xception if used on a machine that doesn')-.15 E 2.5(ti)-.18 G (mplement)-2.5 E F3 -.1(ge)2.5 G(tpriority).1 E F0(\(2\).)1.666 E (getpwnam)108 367.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(getgrnam)108 379.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(gethostbyname)108 391.2 Q F1 -.315(NA) 2.5 G(ME).315 E F0(getnetbyname)108 403.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(getprotobyname)108 415.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(getpwuid) 108 427.2 Q F1(UID)2.5 E F0(getgr)108 439.2 Q(gid)-.18 E F1(GID)2.5 E F0 (getservbyname)108 451.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(,PR)A -1.88 -.4(OT O)-.4 H(gethostbyaddr)108 463.2 Q F1(ADDR)2.5 E F0(,ADDR)A(TYPE) -.6 E(getnetbyaddr)108 475.2 Q F1(ADDR)2.5 E F0(,ADDR)A(TYPE)-.6 E (getprotobynumber)108 487.2 Q F1(NUMBER)2.5 E F0(getservbyport)108 499.2 Q F1(POR)2.5 E(T)-.54 E F0(,PR)A -1.88 -.4(OT O)-.4 H(getpwent)108 511.2 Q(getgrent)108 523.2 Q(gethostent)108 535.2 Q(getnetent)108 547.2 Q (getprotoent)108 559.2 Q(getserv)108 571.2 Q(ent)-.15 E(setpwent)108 583.2 Q(setgrent)108 595.2 Q(sethostent)108 607.2 Q F1(ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(setnetent)108 619.2 Q F1(ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(setprotoent)108 631.2 Q F1(ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(setserv)108 643.2 Q(ent)-.15 E F1 (ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(endpwent)108 655.2 Q (endgrent)108 667.2 Q(endhostent)108 679.2 Q(endnetent)108 691.2 Q (endprotoent)108 703.2 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 28) 162.62 F 0 Cg EP %%Page: 29 29 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(endserv)108 84 Q (ent)-.15 E 1.084(These routines are the same as their counterparts in \ the system C library)128 96 R 6.083(.I)-.65 G 3.583(nl)-6.083 G 1.083 (ist conte)-3.583 F 1.083(xt, the return)-.15 F -.25(va)128 108 S (lues from the v).25 E(arious get routines are as follo)-.25 E(ws:)-.25 E/F1 10/Courier@0 SF(\($name,$passwd,$uid,$gid,)152 126 Q ($quota,$comment,$gcos,$dir,$shell,$expire\) = getpw*)170 138 Q (\($name,$passwd,$gid,$members\) = getgr*)152 150 Q (\($name,$aliases,$addrtype,$length,@addrs\) = gethost*)152 162 Q (\($name,$aliases,$addrtype,$net\) = getnet*)152 174 Q (\($name,$aliases,$proto\) = getproto*)152 186 Q (\($name,$aliases,$port,$proto\) = getserv*)152 198 Q F0 (\(If the entry doesn')128 216 Q 2.5(te)-.18 G (xist you get an empty list.\))-2.65 E 1.444(The e)128 234 R 1.444 (xact meaning of the)-.15 F F1($gcos)3.944 E F0 1.444(\214eld v)3.944 F 1.444(aries b)-.25 F 1.445 (ut it usually contains the real name of the user \(as)-.2 F 1.36(oppos\ ed to the login name\) and other information pertaining to the user)128 246 R 6.36(.B)-.55 G -2.1 -.25(ew a)-6.36 H 1.36(re, ho).25 F(we)-.25 E -.15(ve)-.25 G 2.16 -.4(r, t).15 H 1.36(hat in).4 F(man)128 258 Q 2.813 (ys)-.15 G .314(ystem users are able to change this information and the\ refore it cannot be trusted and therefore)-2.813 F(the)128 270 Q F1 ($gcos)2.659 E F0 .159(is tainted \(see perlsec\).)2.659 F(The)5.159 E F1($passwd)2.659 E F0(and)2.659 E F1($shell)2.658 E F0 2.658(,u)C(ser') -2.658 E 2.658(se)-.55 G .158(ncrypted passw)-2.658 F .158 (ord and login)-.1 F(shell, are also tainted, for the same reason.)128 282 Q .443(In scalar conte)128 300 R .443 (xt, you get the name, unless the function w)-.15 F .444 (as a lookup by name, in which case you get)-.1 F (the other thing, whate)128 312 Q -.15(ve)-.25 G 2.5(ri).15 G 2.5(ti) -2.5 G 2.5(s. \(If)-2.5 F(the entry doesn')2.5 E 2.5(te)-.18 G (xist you get the unde\214ned v)-2.65 E 2.5(alue.\) F)-.25 F(or e)-.15 E (xample:)-.15 E F1 12($uid =)152 330 R(getpwnam\($name\);)6 E 6($name =) 152 342 R(getpwuid\($num\);)6 E 6($name =)152 354 R(getpwent\(\);)6 E 12 ($gid =)152 366 R(getgrnam\($name\);)6 E 6($name =)152 378 R (getgrgid\($num\);)6 E 6($name =)152 390 R(getgrent\(\);)6 E(#etc.)152 402 Q F0(In)128 420 Q/F2 10/Times-Italic@0 SF -.1(ge)3.387 G(tpw*\(\)).1 E F0 .887(the \214elds)3.387 F F1($quota)3.387 E F0(,)A F1($comment) 3.387 E F0 3.387(,a)C(nd)-3.387 E F1($expire)3.386 E F0 .886 (are special in that the)3.386 F 3.386(ya)-.15 G .886(re unsupported) -3.386 F .836(on man)128 432 R 3.336(ys)-.15 G 3.336(ystems. If)-3.336 F (the)3.336 E F1($quota)3.336 E F0 .836 (is unsupported, it is an empty scalar)3.336 F 5.836(.I)-.55 G 3.336(fi) -5.836 G 3.336(ti)-3.336 G 3.336(ss)-3.336 G .837(upported, it usually) -3.336 F .147(encodes the disk quota.)128 444 R .147(If the)5.147 F F1 ($comment)2.647 E F0 .147(\214eld is unsupported, it is an empty scalar) 2.647 F 5.146(.I)-.55 G 2.646(fi)-5.146 G 2.646(ti)-2.646 G 2.646(ss) -2.646 G(upported)-2.646 E .895(it usually encodes some administrati)128 456 R 1.195 -.15(ve c)-.25 H .895(omment about the user).15 F 5.895(.I) -.55 G 3.395(ns)-5.895 G .895(ome systems the)-3.395 F F1($quota)3.395 E F0(\214eld)3.395 E 2.471(may be)128 468 R F1($change)4.971 E F0(or)4.971 E F1($age)4.971 E F0 4.971<2c8c>C 2.471(elds that ha)-4.971 F 2.771 -.15 (ve t)-.2 H 4.971(od).15 G 4.971(ow)-4.971 G 2.47(ith passw)-4.971 F 2.47(ord aging.)-.1 F 2.47(In some systems the)7.47 F F1($comment)128 480 Q F0 .68(\214eld may be)3.18 F F1($class)3.18 E F0 5.681(.T)C(he) -5.681 E F1($expire)3.181 E F0 .681(\214eld, if present, encodes the e) 3.181 F .681(xpiration period of)-.15 F .204(the account or the passw) 128 492 R 2.704(ord. F)-.1 F .204(or the a)-.15 F -.25(va)-.2 G .204 (ilability and the e).25 F .203 (xact meaning of these \214elds in your system,)-.15 F 1.436 (please consult)128 504 R F2 -.1(ge)3.937 G(tpwnam).1 E F0 1.437 (\(3\) and your system')1.666 F(s)-.55 E F2(pwd.h)3.937 E F0 3.937 (\214le. Y)3.937 F 1.437(ou can also \214nd out from within Perl)-1.1 F .741(what your)128 516 R F1($quota)3.241 E F0(and)3.241 E F1($comment) 3.241 E F0 .741(\214elds mean and whether you ha)3.241 F 1.04 -.15(ve t) -.2 H(he).15 E F1($expire)3.24 E F0 .74(\214eld by using)3.24 F(the)128 528 Q F1(Config)3.538 E F0 1.038(module and the v)3.538 F(alues)-.25 E F1(d_pwquota)3.538 E F0(,)A F1(d_pwage)3.538 E F0(,)A F1(d_pwchange) 3.538 E F0(,)A F1(d_pwcomment)3.538 E F0 3.538(,a)C(nd)-3.538 E F1 (d_pwexpire)128 540 Q F0 6.029(.S)C(hado)-6.029 E 3.529(wp)-.25 G(assw) -3.529 E 1.029(ord \214les are supported only if your v)-.1 F 1.028 (endor has implemented them in)-.15 F 1.888(the intuiti)128 552 R 2.188 -.15(ve f)-.25 H 1.888(ashion that calling the re).05 F 1.888 (gular C library routines gets the shado)-.15 F 4.388(wv)-.25 G 1.888 (ersions if you')-4.538 F(re)-.5 E .336(running under pri)128 564 R (vile)-.25 E .336(ge or if there e)-.15 F .335(xists the)-.15 F F2 (shadow)2.835 E F0 .335 (\(3\) functions as found in System V \(this includes)1.666 F .093 (Solaris and Linux\).)128 576 R .093 (Those systems that implement a proprietary shado)5.093 F 2.593(wp)-.25 G(assw)-2.593 E .093(ord f)-.1 F .093(acility are unlik)-.1 F(ely)-.1 E (to be supported.)128 588 Q(The)128 606 Q F1($members)2.534 E F0 -.25 (va)2.534 G .034(lue returned by).25 F F2 -.1(ge)2.534 G(tgr*\(\)).1 E F0 .034(is a space-separated list of the login names of the members) 2.534 F(of the group.)128 618 Q -.15(Fo)128 636 S 2.868(rt).15 G(he) -2.868 E F2 -.1(ge)2.868 G(thost*\(\)).1 E F0 .369(functions, if the) 2.869 F F1(h_errno)2.869 E F0 -.25(va)2.869 G .369 (riable is supported in C, it will be returned to you via).25 F F1($?) 128 648 Q F0 .168(if the function call f)2.668 F 2.668(ails. The)-.1 F F1(@addrs)2.668 E F0 -.25(va)2.668 G .168 (lue returned by a successful call is a list of ra).25 F 2.667(wa)-.15 G (ddresses)-2.667 E .043(returned by the corresponding library call.)128 660 R .043(In the Internet domain, each address is four bytes long; you) 5.043 F(can unpack it by saying something lik)128 672 Q(e:)-.1 E F1 (\($a,$b,$c,$d\) = unpack\(\010W4\010,$addr[0]\);)152 690 Q F0(The Sock) 128 708 Q(et library mak)-.1 E(es this slightly easier:)-.1 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 29)162.62 F 0 Cg EP %%Page: 30 30 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Socket;)152 84 Q ($iaddr = inet_aton\("127.1"\); # or whatever address)152 96 Q 6 ($name =)152 108 R(gethostbyaddr\($iaddr, AF_INET\);)6 E 6(#o)152 132 S 6(rg)-6 G(oing the other way)-6 E($straddr = inet_ntoa\($iaddr\);)152 144 Q F0(In the opposite w)128 162 Q(ay)-.1 E 2.5(,t)-.65 G 2.5(or)-2.5 G(esolv)-2.5 E 2.5(eah)-.15 G(ostname to the)-2.5 E/F2 9/Times-Roman@0 SF(IP)2.5 E F0(address you can write this:)2.5 E F1(use Socket;)152 180 Q($packed_ip = gethostbyname\("www.perl.org"\);)152 192 Q (if \(defined $packed_ip\) {)152 204 Q ($ip_address = inet_ntoa\($packed_ip\);)176 216 Q(})152 228 Q F0(Mak)128 246 Q 3.77(es)-.1 G 1.27(ure <)-3.77 F/F3 10/Times-Italic@0 SF -.1(ge)C (thostbyname\(\)).1 E F0 3.77(>i)C 3.77(sc)-3.77 G 1.27(alled in)-3.77 F F2(SCALAR)3.77 E F0(conte)3.77 E 1.27(xt and that its return v)-.15 F 1.269(alue is check)-.25 F 1.269(ed for)-.1 F(de\214nedness.)128 258 Q .302(If you get tired of remembering which element of the return list c\ ontains which return v)128 276 R .302(alue, by-name)-.25 F(interf)128 288 Q 2.724(aces are pro)-.1 F 2.724(vided in standard modules:)-.15 F F1(File::stat)5.224 E F0(,)A F1(Net::hostent)5.223 E F0(,)A F1 (Net::netent)5.223 E F0(,)A F1(Net::protoent)128 300 Q F0(,)A F1 (Net::servent)18.89 E F0(,)A F1(Time::gmtime)18.89 E F0(,)A F1 (Time::localtime)18.89 E F0 18.89(,a)C(nd)-18.89 E F1(User::grent)128 312 Q F0 5.673(.T)C .673(hese o)-5.673 F -.15(ve)-.15 G .673 (rride the normal b).15 F .673(uilt-ins, supplying v)-.2 F .672 (ersions that return objects with the)-.15 F (appropriate names for each \214eld.)128 324 Q -.15(Fo)5 G 2.5(re).15 G (xample:)-2.65 E F1(use File::stat;)146 342 Q(use User::pwent;)146 354 Q ($is_his = \(stat\($filename\)\255>uid == pwent\($whoever\)\255>uid\);) 146 366 Q F0(Ev)128 384 Q 3.564(en though it looks as though the)-.15 F (y')-.15 E 3.565(re the same method calls \(uid\), the)-.5 F 6.065(ya) -.15 G(ren')-6.065 E 3.565(t, because a)-.18 F F1(File::stat)128 396 Q F0(object is dif)2.5 E(ferent from a)-.25 E F1(User::pwent)2.5 E F0 (object.)2.5 E(getsockname)108 412.8 Q F2(SOCKET)2.5 E F0 .77 (Returns the pack)128 424.8 R .77 (ed sockaddr address of this end of the)-.1 F F2(SOCKET)3.27 E F0 .77 (connection, in case you don')3.27 F 3.269(tk)-.18 G(no)-3.269 E(w)-.25 E(the address because you ha)128 436.8 Q .3 -.15(ve s)-.2 H -2.15 -.25 (ev e).15 H(ral dif).25 E(ferent IPs that the connection might ha)-.25 E .3 -.15(ve c)-.2 H(ome in on.).15 E F1(use Socket;)152 454.8 Q ($mysockaddr = getsockname\(SOCK\);)152 466.8 Q (\($port, $myaddr\) = sockaddr_in\($mysockaddr\);)152 478.8 Q (printf "Connect to %s [%s]\\n",)152 490.8 Q (scalar gethostbyaddr\($myaddr, AF_INET\),)170 502.8 Q (inet_ntoa\($myaddr\);)170 514.8 Q F0(getsock)108 531.6 Q(opt)-.1 E F2 (SOCKET)2.5 E F0(,LEVEL,OPTN)A(AME)-.35 E .004(Queries the option named) 128 543.6 R F2(OPTN)2.505 E(AME)-.315 E F0 .005(associated with)2.505 F F2(SOCKET)2.505 E F0 .005(at a gi)2.505 F -.15(ve)-.25 G(n).15 E F2 (LEVEL)2.505 E F0 5.005(.O)C .005(ptions may e)-5.005 F .005(xist at) -.15 F 2.95(multiple protocol le)128 555.6 R -.15(ve)-.25 G 2.95 (ls depending on the sock).15 F 2.949(et type, b)-.1 F 2.949 (ut at least the uppermost sock)-.2 F 2.949(et le)-.1 F -.15(ve)-.25 G (l).15 E F2(SOL_SOCKET)128 567.6 Q F0 2.185(\(de\214ned in the)4.685 F F1(Socket)4.685 E F0 2.185(module\) will e)4.685 F 2.186(xist. T)-.15 F 4.686(oq)-.8 G 2.186(uery options at another le)-4.686 F -.15(ve)-.25 G 4.686(lt).15 G(he)-4.686 E .127(protocol number of the appropriate prot\ ocol controlling the option should be supplied. F)128 579.6 R .127(or e) -.15 F .127(xample, to)-.15 F .807 (indicate that an option is to be interpreted by the)128 591.6 R F2(TCP) 3.307 E F0(protocol,)3.307 E F2(LEVEL)3.307 E F0 .808 (should be set to the protocol)3.307 F(number of)128 603.6 Q F2(TCP)2.5 E F0 2.5(,w)C(hich you can get using)-2.5 E F1(getprotobyname)2.5 E F0 (.)A .086(The function returns a pack)128 621.6 R .086 (ed string representing the requested sock)-.1 F .086(et option, or)-.1 F F1(undef)2.586 E F0 .086(on error)2.586 F 2.586(,w)-.4 G(ith)-2.586 E 2.145(the reason for the error placed in)128 633.6 R F1($!)4.645 E F0 4.645(.J)C 2.145(ust what is in the pack)-4.645 F 2.146 (ed string depends on)-.1 F F2(LEVEL)4.646 E F0(and)4.646 E F2(OPTN)128 645.6 Q(AME)-.315 E F0 2.61(;c)C(onsult)-2.61 E F3 -.1(ge)2.61 G(tsoc).1 E -.1(ko)-.2 G(pt).1 E F0 .11(\(2\) for details.)1.666 F 2.61(Ac)5.11 G .109(ommon case is that the option is an inte)-2.61 F(ger)-.15 E 2.609 (,i)-.4 G 2.609(nw)-2.609 G(hich)-2.609 E(case the result is a pack)128 657.6 Q(ed inte)-.1 E(ger)-.15 E 2.5(,w)-.4 G(hich you can decode using) -2.5 E F1(unpack)2.5 E F0(with the)2.5 E F1(i)2.5 E F0(\(or)2.5 E F1(I) 2.5 E F0 2.5(\)f)C(ormat.)-2.5 E(Here')128 675.6 Q 2.5(sa)-.55 G 2.5(ne) -2.5 G(xample to test whether Nagle')-2.65 E 2.5(sa)-.55 G (lgorithm is enabled on a sock)-2.5 E(et:)-.1 E F1 (use Socket qw\(:all\);)152 693.6 Q (defined\(my $tcp = getprotobyname\("tcp"\)\))152 717.6 Q (or die "Could not determine the protocol number for tcp";)176 729.6 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 30)162.62 F 0 Cg EP %%Page: 31 31 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#m)152 84 S 6(y$)-6 G(tcp = IPPROTO_TCP; # Alternative)-6 E (my $packed = getsockopt\($socket, $tcp, TCP_NODELAY\))152 96 Q (or die "getsockopt TCP_NODELAY: $!";)176 108 Q (my $nodelay = unpack\("I", $packed\);)152 120 Q(print "Nagle\010s algo\ rithm is turned ", $nodelay ? "off\\n" : "on\\n";)152 132 Q F0(gi)108 148.8 Q -.15(ve)-.25 G(n).15 E/F2 9/Times-Roman@0 SF .25(EXPR BLOCK)2.5 F F0(gi)108 160.8 Q -.15(ve)-.25 G(n).15 E F2(BLOCK)2.5 E F1(given)128 172.8 Q F0 .01(is analogous to the)2.51 F F1(switch)2.51 E F0 -.1(ke) 2.51 G(yw)-.05 E .01(ord in other languages.)-.1 F F1(given)2.51 E F0 (and)2.51 E F1(when)2.51 E F0 .01(are used in Perl to)2.51 F(implement) 128 184.8 Q F1(switch)2.5 E F0(/)A F1(case)A F0(lik)2.5 E 2.5(es)-.1 G 2.5(tatements. Only)-2.5 F -.2(av)2.5 G(ailable after Perl 5.10.)-.05 E -.15(Fo)5 G 2.5(re).15 G(xample:)-2.65 E F1(use v5.10;)152 202.8 Q (given \($fruit\) {)152 214.8 Q(when \(/apples?/\) {)176 226.8 Q (print "I like apples.")200 238.8 Q(})176 250.8 Q(when \(/oranges?/\) {) 176 262.8 Q(print "I don\010t like oranges.")200 274.8 Q(})176 286.8 Q (default {)176 298.8 Q(print "I don\010t like anything")200 310.8 Q(}) 176 322.8 Q(})152 334.8 Q F0(See `)128 352.8 Q(`Switch statements')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlsyn for detailed information.)-2.5 E (glob)108 369.6 Q F2(EXPR)2.5 E F0(glob)108 381.6 Q .24(In list conte) 128 393.6 R .239(xt, returns a \(possibly empty\) list of \214lename e) -.15 F .239(xpansions on the v)-.15 F .239(alue of)-.25 F F2(EXPR)2.739 E F0 .239(such as the)2.739 F 3.36(standard Unix shell)128 405.6 R/F3 10 /Times-Italic@0 SF(/bin/csh)5.86 E F0 -.1(wo)5.86 G 3.36 (uld do. In scalar conte).1 F 3.36 (xt, glob iterates through such \214lename)-.15 F -.15(ex)128 417.6 S .524(pansions, returning undef when the list is e).15 F .523 (xhausted. This is the internal function implementing the)-.15 F F1 (<*.c>)128 429.6 Q F0(operator)3.16 E 3.16(,b)-.4 G .661 (ut you can use it directly)-3.36 F 3.161(.I)-.65 G(f)-3.161 E F2(EXPR) 3.161 E F0 .661(is omitted,)3.161 F F1($_)3.161 E F0 .661(is used.)3.161 F(The)5.661 E F1(<*.c>)3.161 E F0 .661(operator is)3.161 F (discussed in more detail in `)128 441.6 Q(`I/O Operators')-.74 E 2.5 ('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E 1.134(Note that)128 459.6 R F1 (glob)3.634 E F0 1.134(splits its ar)3.634 F 1.134 (guments on whitespace and treats each se)-.18 F 1.134 (gment as separate pattern.)-.15 F(As)6.134 E(such,)128 471.6 Q F1 1.063 (glob\("*.c *.h"\))3.563 F F0 1.063(matches all \214les with a)3.563 F F3(.c)3.564 E F0(or)3.564 E F3(.h)3.564 E F0 -.15(ex)3.564 G 3.564 (tension. The).15 F -.15(ex)3.564 G(pression).15 E F1(glob\(".*)3.564 E (*"\))128 483.6 Q F0(matches all \214les in the current w)2.5 E (orking directory)-.1 E(.)-.65 E .276 (If non-empty braces are the only wildcard characters used in the)128 501.6 R F1(glob)2.775 E F0 2.775(,n)C 2.775<6f8c>-2.775 G .275 (lenames are matched, b)-2.775 F(ut)-.2 E .297(potentially man)128 513.6 R 2.797(ys)-.15 G .297(trings are returned.)-2.797 F -.15(Fo)5.297 G 2.797(re).15 G .298 (xample, this produces nine strings, one for each pairing of)-2.947 F (fruits and colors:)128 525.6 Q F1(@many =)152 543.6 Q (glob "{apple,tomato,cherry}={green,yellow,red}";)12 E F0(Be)128 561.6 Q .263 (ginning with v5.6.0, this operator is implemented using the standard) -.15 F F1(File::Glob)2.762 E F0 -.15(ex)2.762 G 2.762(tension. See).15 F (File::Glob for details, including)128 573.6 Q F1(bsd_glob)2.5 E F0 (which does not treat whitespace as a pattern separator)2.5 E(.)-.55 E (gmtime)108 590.4 Q F2(EXPR)2.5 E F0(gmtime)108 602.4 Q -.8(Wo)128 614.4 S(rks just lik).8 E 2.5(el)-.1 G(ocaltime b)-2.5 E(ut the returned v)-.2 E(alues are localized for the standard Greenwich time zone.)-.25 E .593 (Note: When called in list conte)128 632.4 R(xt,)-.15 E F1($isdst)3.093 E F0 3.093(,t)C .593(he last v)-3.093 F .594 (alue returned by gmtime, is al)-.25 F -.1(wa)-.1 G(ys).1 E F1(0)3.094 E F0 5.594(.T)C .594(here is)-5.594 F(no Daylight Sa)128 644.4 Q(ving T) -.2 E(ime in)-.35 E F2(GMT)2.5 E F0(.)A(See `)128 662.4 Q(`gmtime')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlport for portability concerns.)-2.5 E (goto)108 679.2 Q F2(LABEL)2.5 E F0(goto)108 691.2 Q F2(EXPR)2.5 E F0 (goto &N)108 703.2 Q(AME)-.35 E(The)128 715.2 Q F1(goto\255LABEL)2.654 E F0 .154(form \214nds the statement labeled with)2.654 F F2(LABEL)2.654 E F0 .154(and resumes e)2.654 F -.15(xe)-.15 G .153(cution there. It can') .15 F(t)-.18 E .396(be used to get out of a block or subroutine gi)128 727.2 R -.15(ve)-.25 G 2.897(nt).15 G(o)-2.897 E F1(sort)2.897 E F0 5.397(.I)C 2.897(tc)-5.397 G .397(an be used to go almost an)-2.897 F .397(ywhere else)-.15 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 31) 162.62 F 0 Cg EP %%Page: 32 32 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 2.018 (within the dynamic scope, including out of subroutines, b)128 84 R 2.018(ut it')-.2 F 4.518(su)-.55 G 2.018 (sually better to use some other)-4.518 F .545(construct such as)128 96 R/F1 10/Courier@0 SF(last)3.045 E F0(or)3.045 E F1(die)3.045 E F0 5.545 (.T)C .545(he author of Perl has ne)-5.545 F -.15(ve)-.25 G 3.046(rf).15 G .546(elt the need to use this form of)-3.046 F F1(goto)3.046 E F0 .559 (\(in Perl, that is; C is another matter\).)128 108 R .559(\(The dif) 5.559 F .559(ference is that C does not of)-.25 F .558 (fer named loops combined)-.25 F(with loop control.)128 120 Q (Perl does, and this replaces most structured uses of)5 E F1(goto)2.5 E F0(in other languages.\))2.5 E(The)128 138 Q F1(goto\255EXPR)2.903 E F0 .403(form e)2.903 F .404 (xpects a label name, whose scope will be resolv)-.15 F .404 (ed dynamically)-.15 F 5.404(.T)-.65 G .404(his allo)-5.404 F(ws)-.25 E 2.359(for computed)128 150 R F1(goto)4.859 E F0 4.859(sp)C(er)-4.859 E /F2 9/Times-Roman@0 SF(FOR)4.859 E(TRAN)-.54 E F0 4.859(,b)C 2.359 (ut isn')-5.059 F 4.859(tn)-.18 G 2.359(ecessarily recommended if you') -4.859 F 2.359(re optimizing for)-.5 F(maintainability:)128 162 Q F1 (goto \("FOO", "BAR", "GLARCH"\)[$i];)152 180 Q F0 1.015(As sho)128 198 R 1.016(wn in this e)-.25 F(xample,)-.15 E F1(goto\255EXPR)3.516 E F0 1.016(is e)3.516 F -.15(xe)-.15 G 1.016(mpt from the `).15 F 1.016 (`looks lik)-.74 F 3.516(eaf)-.1 G(unction')-3.516 E 3.516('r)-.74 G 1.016(ule. A pair of)-3.516 F 3.94(parentheses follo)128 210 R 3.94 (wing it does not \(necessarily\) delimit its ar)-.25 F(gument.)-.18 E F1(goto\("NE"\)."XT")6.44 E F0(is)6.44 E(equi)128 222 Q -.25(va)-.25 G (lent to).25 E F1(goto NEXT)2.5 E F0(.)A .075(Use of)128 240 R F1 (goto\255LABEL)2.575 E F0(or)2.575 E F1(goto\255EXPR)2.575 E F0 .075 (to jump into a construct is deprecated and will issue a w)2.575 F (arning.)-.1 E(Ev)128 252 Q .315 (en then, it may not be used to go into an)-.15 F 2.815(yc)-.15 G .315 (onstruct that requires initialization, such as a subroutine)-2.815 F (or a)128 264 Q F1(foreach)2.5 E F0 2.5(loop. It)2.5 F(also can')2.5 E 2.5(tb)-.18 G 2.5(eu)-2.5 G (sed to go into a construct that is optimized a)-2.5 E -.1(wa)-.15 G -.65(y.).1 G(The)128 282 Q F1(goto\255&NAME)2.746 E F0 .247 (form is quite dif)2.746 F .247(ferent from the other forms of)-.25 F F1 (goto)2.747 E F0 5.247(.I)C 2.747(nf)-5.247 G .247(act, it isn')-2.847 F 2.747(tag)-.18 G .247(oto in the)-2.747 F 1.698 (normal sense at all, and doesn')128 294 R 4.198(th)-.18 G -2.25 -.2 (av e)-4.198 H 1.698(the stigma associated with other gotos.)4.398 F 1.698(Instead, it e)6.698 F 1.698(xits the)-.15 F 1.24 (current subroutine \(losing an)128 306 R 3.74(yc)-.15 G 1.24 (hanges set by)-3.74 F/F3 10/Times-Italic@0 SF(local\(\))3.74 E F0 3.74 (\)a)C 1.24(nd immediately calls in its place the named)-3.74 F .941 (subroutine using the current v)128 318 R .941(alue of)-.25 F F1(@_) 3.441 E F0 5.941(.T)C .941(his is used by)-5.941 F F1(AUTOLOAD)3.44 E F0 .94(subroutines that wish to load)3.44 F .313(another subroutine and th\ en pretend that the other subroutine had been called in the \214rst pla\ ce \(e)128 330 R(xcept)-.15 E .777(that an)128 342 R 3.277(ym)-.15 G .777(odi\214cations to)-3.277 F F1(@_)3.277 E F0 .777 (in the current subroutine are propag)3.277 F .776 (ated to the other subroutine.\))-.05 F(After)5.776 E(the)128 354 Q F1 (goto)2.5 E F0 2.5(,n)C(ot e)-2.5 E -.15(ve)-.25 G(n).15 E F1(caller)2.5 E F0(will be able to tell that this routine w)2.5 E(as called \214rst.) -.1 E F2 -.315(NA)128 372 S(ME).315 E F0(needn')2.674 E 2.674(tb)-.18 G 2.674(et)-2.674 G .175(he name of a subroutine; it can be a scalar v) -2.674 F .175(ariable containing a code reference or a)-.25 F (block that e)128 384 Q -.25(va)-.25 G(luates to a code reference.).25 E (grep)108 400.8 Q F2 .25(BLOCK LIST)2.5 F F0(grep)108 412.8 Q F2(EXPR) 2.5 E F0(,LIST)A .322(This is similar in spirit to, b)128 424.8 R .322 (ut not the same as,)-.2 F F3(gr)2.822 E(ep)-.37 E F0 .322 (\(1\) and its relati)1.666 F -.15(ve)-.25 G 2.821(s. In).15 F (particular)2.821 E 2.821(,i)-.4 G 2.821(ti)-2.821 G 2.821(sn)-2.821 G .321(ot limited)-2.821 F(to using re)128 436.8 Q(gular e)-.15 E (xpressions.)-.15 E(Ev)128 454.8 Q 1.599(aluates the)-.25 F F2(BLOCK) 4.099 E F0(or)4.099 E F2(EXPR)4.099 E F0 1.6(for each element of)4.1 F F2(LIST)4.1 E F0 1.6(\(locally setting)4.1 F F1($_)4.1 E F0 1.6 (to each element\) and)4.1 F .255(returns the list v)128 466.8 R .255 (alue consisting of those elements for which the e)-.25 F .255 (xpression e)-.15 F -.25(va)-.25 G .255(luated to true.).25 F .255 (In scalar)5.255 F(conte)128 478.8 Q (xt, returns the number of times the e)-.15 E(xpression w)-.15 E (as true.)-.1 E F1(@foo = grep\(!/^#/, @bar\);)152 496.8 Q 6(#w)24 G (eed out comments)-6 E F0(or equi)128 514.8 Q -.25(va)-.25 G(lently).25 E(,)-.65 E F1(@foo = grep {!/^#/} @bar;)152 532.8 Q 6(#w)24 G (eed out comments)-6 E F0 .475(Note that)128 550.8 R F1($_)2.975 E F0 .475(is an alias to the list v)2.975 F .475 (alue, so it can be used to modify the elements of the)-.25 F F2(LIST) 2.975 E F0 5.476(.W)C(hile)-5.476 E 1.617(this is useful and supported,\ it can cause bizarre results if the elements of)128 562.8 R F2(LIST) 4.117 E F0 1.617(are not v)4.117 F(ariables.)-.25 E(Similarly)128 574.8 Q 2.991(,g)-.65 G .492 (rep returns aliases into the original list, much as a for loop')-2.991 F 2.992(si)-.55 G(nde)-2.992 E 2.992(xv)-.15 G .492 (ariable aliases the list)-3.242 F 2.892(elements. That)128 586.8 R .391 (is, modifying an element of a list returned by grep \(for e)2.892 F .391(xample, in a)-.15 F F1(foreach)2.891 E F0(,)A F1(map)2.891 E F0 .986(or another)128 598.8 R F1(grep)3.486 E F0 3.487(\)a)C .987 (ctually modi\214es the element in the original list.)-3.487 F .987 (This is usually something to be)5.987 F -.2(avo)128 610.8 S (ided when writing clear code.).2 E(If)128 628.8 Q F1($_)2.698 E F0 .198 (is le)2.698 F .198(xical in the scope where the)-.15 F F1(grep)2.697 E F0 .197(appears \(because it has been declared with)2.697 F F1 .197 (my $_)2.697 F F0 2.697(\)t)C(hen,)-2.697 E .354 (in addition to being locally aliased to the list elements,)128 640.8 R F1($_)2.854 E F0 -.1(ke)2.855 G .355(eps being le).1 F .355 (xical inside the block; i.e., it)-.15 F(can')128 652.8 Q 2.5(tb)-.18 G 2.5(es)-2.5 G(een from the outside, a)-2.5 E -.2(vo)-.2 G(iding an).2 E 2.5(yp)-.15 G(otential side-ef)-2.5 E(fects.)-.25 E(See also `)128 670.8 Q(`map')-.74 E 2.5('f)-.74 G(or a list composed of the results of the) -2.5 E F2(BLOCK)2.5 E F0(or)2.5 E F2(EXPR)2.5 E F0(.)A(he)108 687.6 Q(x) -.15 E F2(EXPR)2.5 E F0(he)108 699.6 Q(x)-.15 E(Interprets)128 699.6 Q F2(EXPR)3.647 E F0 1.147(as a he)3.647 F 3.647(xs)-.15 G 1.146 (tring and returns the corresponding v)-3.647 F 3.646(alue. \(T)-.25 F 3.646(oc)-.8 G(on)-3.646 E -.15(ve)-.4 G 1.146(rt strings that might).15 F(start with either)128 711.6 Q F1(0)2.5 E F0(,)A F1(0x)2.5 E F0 2.5(,o) C(r)-2.5 E F1(0b)2.5 E F0 2.5(,s)C(ee `)-2.5 E(`oct')-.74 E 2.5('.\) If) -.74 F F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A (perl v5.14.2)72 768 Q 198.17(2011-10-01 32)162.62 F 0 Cg EP %%Page: 33 33 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (print hex \0100xAf\010; # prints \010175\010)152 84 Q (print hex \010aF\010;)152 96 Q 6(#s)18 G(ame)-6 E F0(He)128 114 Q 2.951 (xs)-.15 G .451(trings may only represent inte)-2.951 F 2.951 (gers. Strings)-.15 F .451(that w)2.951 F .452(ould cause inte)-.1 F .452(ger o)-.15 F -.15(ve)-.15 G(r\215o).15 E 2.952(wt)-.25 G .452 (rigger a w)-2.952 F(arning.)-.1 E 1.637 (Leading whitespace is not stripped, unlik)128 126 R(e)-.1 E/F2 10 /Times-Italic@0 SF(oct\(\))4.137 E F0 4.137(.T)C 4.137(op)-4.937 G 1.637 (resent something as he)-4.137 F 1.637(x, look into `)-.15 F -1.95 (`printf ')-.74 F(',)-.74 E -.74(``)128 138 S -1.95(sprintf ').74 F (', and `)-.74 E(`unpack')-.74 E('.)-.74 E(import)108 154.8 Q/F3 9 /Times-Roman@0 SF(LIST)2.5 E F0 .323(There is no b)128 166.8 R(uiltin) -.2 E F1(import)2.823 E F0 2.823(function. It)2.823 F .324 (is just an ordinary method \(subroutine\) de\214ned \(or inherited\)) 2.823 F 2.12(by modules that wish to e)128 178.8 R 2.119 (xport names to another module.)-.15 F(The)7.119 E F1(use)4.619 E F0 2.119(function calls the)4.619 F F1(import)4.619 E F0 (method for the package used.)128 190.8 Q(See also `)5 E(`use')-.74 E (', perlmod, and Exporter)-.74 E(.)-.55 E(inde)108 207.6 Q(x)-.15 E F3 (STR)2.5 E F0(,SUBSTR,POSITION)A(inde)108 219.6 Q(x)-.15 E F3(STR)2.5 E F0(,SUBSTR)A .467(The inde)128 231.6 R 2.967(xf)-.15 G .467 (unction searches for one string within another)-2.967 F 2.967(,b)-.4 G .468(ut without the wildcard-lik)-3.167 F 2.968(eb)-.1 G(eha)-2.968 E .468(vior of a)-.2 F .304(full re)128 243.6 R(gular)-.15 E(-e)-.2 E .304 (xpression pattern match.)-.15 F .304 (It returns the position of the \214rst occurrence of)5.304 F F3(SUBSTR) 2.803 E F0(in)2.803 E F3(STR)2.803 E F0 2.032(at or after)128 255.6 R F3 (POSITION)4.532 E F0 7.032(.I)C(f)-7.032 E F3(POSITION)4.532 E F0 2.032 (is omitted, starts searching from the be)4.532 F 2.032 (ginning of the string.)-.15 F F3(POSITION)128 267.6 Q F0 .18 (before the be)2.68 F .18 (ginning of the string or after its end is treated as if it were the be) -.15 F .179(ginning or the)-.15 F 1.955(end, respecti)128 279.6 R -.15 (ve)-.25 G(ly).15 E(.)-.65 E F3(POSITION)6.955 E F0 1.955 (and the return v)4.455 F 1.955(alue are based at)-.25 F F1(0)4.455 E F0 1.956(\(or whate)4.455 F -.15(ve)-.25 G 4.456(ry).15 G(ou')-4.456 E 2.256 -.15(ve s)-.5 H 1.956(et the).15 F F1($[)4.456 E F0 -.25(va)128 291.6 S .697(riable to).25 F 1.666<8a62>1.666 G .697(ut don')-1.866 F 3.197(td)-.18 G 3.197(ot)-3.197 G 3.197(hat\). If)-3.197 F .696 (the substring is not found,)3.197 F F1(index)3.196 E F0 .696 (returns one less than the base,)3.196 F(ordinarily)128 303.6 Q F1 2.5 E F0(.)A(int)108 320.4 Q F3(EXPR)2.5 E F0(int)108 332.4 Q .766 (Returns the inte)128 332.4 R .766(ger portion of)-.15 F F3(EXPR)3.266 E F0 5.766(.I)C(f)-5.766 E F3(EXPR)3.266 E F0 .767(is omitted, uses)3.267 F F1($_)3.267 E F0 5.767(.Y)C .767(ou should not use this function) -6.867 F .09(for rounding: one because it truncates to)128 344.4 R -.1 (wa)-.25 G(rds).1 E F1(0)2.59 E F0 2.59(,a)C .09(nd tw)-2.59 F 2.59(ob) -.1 G .09(ecause machine representations of \215oating-)-2.59 F 13.015 (point numbers can sometimes produce counterintuiti)128 356.4 R 13.315 -.15(ve r)-.25 H 15.515(esults. F).15 F 13.015(or e)-.15 F(xample,)-.15 E F1(int\(\2556.725/0.025\))128 368.4 Q F0 .871 (produces \255268 rather than the correct \255269; that')3.371 F 3.371 (sb)-.55 G .871(ecause it')-3.371 F 3.37(sr)-.55 G .87(eally more)-3.37 F(lik)128 380.4 Q 11.487<65ad>-.1 G 8.987 (268.99999999999994315658 instead.)-11.487 F(Usually)13.987 E 11.487(,t) -.65 G(he)-11.487 E F1(sprintf)11.488 E F0(,)A F1(printf)11.488 E F0 11.488(,o)C 11.488(rt)-11.488 G(he)-11.488 E F1(POSIX::floor)128 392.4 Q F0(and)2.5 E F1(POSIX::ceil)2.5 E F0(functions will serv)2.5 E 2.5(ey) -.15 G(ou better than will)-2.5 E F2(int\(\))2.5 E F0(.)A(ioctl)108 409.2 Q F3(FILEHANDLE)2.5 E F0(,FUNCTION,SCALAR)A(Implements the)128 421.2 Q F2(ioctl)2.5 E F0(\(2\) function.)1.666 E -1.1(Yo)5 G(u')1.1 E (ll probably \214rst ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1(require "sys/ioctl.ph";)152 439.2 Q 6(#p)12 G (robably in $Config{archlib}/sys/ioctl.ph)-6 E F0 2.887 (to get the correct function de\214nitions.)128 457.2 R(If)7.887 E F2 (sys/ioctl.ph)5.387 E F0(doesn')5.387 E 5.387(te)-.18 G 2.887 (xist or doesn')-5.537 F 5.387(th)-.18 G -2.25 -.2(av e)-5.387 H 2.887 (the correct)5.587 F .331(de\214nitions you')128 469.2 R .331(ll ha)-.1 F .631 -.15(ve t)-.2 H 2.831(or).15 G .331(oll your o)-2.831 F .331 (wn, based on your C header \214les such as)-.25 F F2() 2.832 E F0 5.332(.\()C .332(There is)-5.332 F 3.579(aP)128 481.2 S 1.079 (erl script called)-3.579 F/F4 10/Times-Bold@0 SF(h2ph)3.579 E F0 1.079 (that comes with the Perl kit that may help you in this, b)3.579 F 1.079 (ut it')-.2 F 3.578(sn)-.55 G(ontri)-3.578 E(vial.\))-.25 E F3(SCALAR) 128 493.2 Q F0 .811(will be read and/or written depending on the)3.311 F F3(FUNCTION)3.311 E F0 3.311(;aCp)C .811(ointer to the string v)-3.311 F .812(alue of)-.25 F F3(SCALAR)128 505.2 Q F0 1.167 (will be passed as the third ar)3.667 F 1.166(gument of the actual)-.18 F F1(ioctl)3.666 E F0 3.666(call. \(If)3.666 F F3(SCALAR)3.666 E F0 1.166(has no string)3.666 F -.25(va)128 517.2 S .234(lue b).25 F .234 (ut does ha)-.2 F .534 -.15(ve a n)-.2 H .235(umeric v).15 F .235 (alue, that v)-.25 F .235 (alue will be passed rather than a pointer to the string v)-.25 F(alue.) -.25 E 2.079 -.8(To g)128 529.2 T .479(uarantee this to be true, add a) .8 F F1(0)2.979 E F0 .478(to the scalar before using it.\))2.978 F(The) 5.478 E F1(pack)2.978 E F0(and)2.978 E F1(unpack)2.978 E F0(functions) 2.978 E(may be needed to manipulate the v)128 541.2 Q (alues of structures used by)-.25 E F1(ioctl)2.5 E F0(.)A(The return v) 128 559.2 Q(alue of)-.25 E F1(ioctl)2.5 E F0(\(and)2.5 E F1(fcntl)2.5 E F0 2.5(\)i)C 2.5(sa)-2.5 G 2.5(sf)-2.5 G(ollo)-2.5 E(ws:)-.25 E F1 (if OS returns:)152 577.2 Q(then Perl returns:)36 E 84(\2551 undefined) 176 589.2 R(value)6 E 84(0s)182 601.2 S(tring "0 but true")-84 E (anything else)152 613.2 Q(that number)66 E F0 1.343 (Thus Perl returns true on success and f)128 631.2 R 1.343(alse on f)-.1 F 1.343(ailure, yet you can still easily determine the actual)-.1 F -.25 (va)128 643.2 S(lue returned by the operating system:).25 E F1 ($retval = ioctl\(...\) || \2551;)152 661.2 Q (printf "System returned %d\\n", $retval;)152 673.2 Q F0 3.284 (The special string)128 691.2 R F1 3.284("0 but true")5.784 F F0 3.284 (is e)5.784 F -.15(xe)-.15 G 3.284(mpt from).15 F F45.784 E F0 3.283(complaints about improper numeric)5.784 F(con)128 703.2 Q -.15(ve) -.4 G(rsions.).15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 33)162.62 F 0 Cg EP %%Page: 34 34 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(join)108 84 Q/F1 9 /Times-Roman@0 SF(EXPR)2.5 E F0(,LIST)A .648 (Joins the separate strings of)128 96 R F1(LIST)3.148 E F0 .649 (into a single string with \214elds separated by the v)3.149 F .649 (alue of)-.25 F F1(EXPR)3.149 E F0 3.149(,a)C(nd)-3.149 E (returns that ne)128 108 Q 2.5(ws)-.25 G 2.5(tring. Example:)-2.5 F/F2 10/Courier@0 SF ($rec = join\(\010:\010, $login,$passwd,$uid,$gid,$gcos,$home,$shell\);) 152 126 Q F0(Be)128 144 Q -.1(wa)-.25 G(re that unlik).1 E(e)-.1 E F2 (split)2.5 E F0(,)A F2(join)2.5 E F0(doesn')2.5 E 2.5(tt)-.18 G(ak)-2.5 E 2.5(eap)-.1 G(attern as its \214rst ar)-2.5 E 2.5(gument. Compare)-.18 F -.74(``)2.5 G(split').74 E('.)-.74 E -.1(ke)108 160.8 S(ys)-.05 E F1 (HASH)2.5 E F0 -.1(ke)108 172.8 S(ys)-.05 E F1(ARRA)2.5 E(Y)-.945 E F0 -.1(ke)108 184.8 S(ys)-.05 E F1(EXPR)2.5 E F0 .059 (Returns a list consisting of all the k)128 196.8 R -.15(ey)-.1 G 2.559 (so).15 G 2.559(ft)-2.559 G .059 (he named hash, or the indices of an array)-2.559 F 2.559(.\()-.65 G .059(In scalar conte)-2.559 F(xt,)-.15 E(returns the number of k)128 208.8 Q -.15(ey)-.1 G 2.5(so).15 G 2.5(ri)-2.5 G(ndices.\))-2.5 E .408 (The k)128 226.8 R -.15(ey)-.1 G 2.908(so).15 G 2.908(fah)-2.908 G .408 (ash are returned in an apparently random order)-2.908 F 5.408(.T)-.55 G .409(he actual random order is subject to)-5.408 F .894 (change in future v)128 238.8 R .894(ersions of Perl, b)-.15 F .894 (ut it is guaranteed to be the same order as either the)-.2 F F2(values) 3.393 E F0(or)3.393 E F2(each)128 250.8 Q F0 .042 (function produces \(gi)2.542 F -.15(ve)-.25 G 2.542(nt).15 G .042 (hat the hash has not been modi\214ed\).)-2.542 F .043 (Since Perl 5.8.1 the ordering can)5.043 F 1.365(be dif)128 262.8 R 1.365(ferent e)-.25 F -.15(ve)-.25 G 3.865(nb).15 G 1.365(etween dif) -3.865 F 1.365(ferent runs of Perl for security reasons \(see `)-.25 F -.8(`A)-.74 G 1.364(lgorithmic Comple).8 F(xity)-.15 E(Attacks')128 274.8 Q 2.5('i)-.74 G 2.5(np)-2.5 G(erlsec\).)-2.5 E .933(As a side ef) 128 292.8 R .933(fect, calling)-.25 F/F3 10/Times-Italic@0 SF -.1(ke) 3.433 G(ys\(\))-.2 E F0 .933(resets the internal interator of the)3.433 F F1(HASH)3.434 E F0(or)3.434 E F1(ARRA)3.434 E(Y)-.945 E F0 .934 (\(see `)3.434 F(`each')-.74 E 3.434('\). In)-.74 F(particular)128 304.8 Q 2.5(,c)-.4 G(alling)-2.5 E F3 -.1(ke)2.5 G(ys\(\))-.2 E F0(in v)2.5 E (oid conte)-.2 E(xt resets the iterator with no other o)-.15 E -.15(ve) -.15 G(rhead.).15 E(Here is yet another w)128 322.8 Q (ay to print your en)-.1 E(vironment:)-.4 E F2(@keys = keys %ENV;)152 340.8 Q(@values = values %ENV;)152 352.8 Q(while \(@keys\) {)152 364.8 Q (print pop\(@keys\), \010=\010, pop\(@values\), "\\n";)176 376.8 Q(})152 388.8 Q F0(or ho)128 406.8 Q 2.5(wa)-.25 G(bout sorted by k)-2.5 E -.15 (ey)-.1 G(:).15 E F2(foreach $key \(sort\(keys %ENV\)\) {)152 424.8 Q (print $key, \010=\010, $ENV{$key}, "\\n";)176 436.8 Q(})152 448.8 Q F0 .604(The returned v)128 466.8 R .604(alues are copies of the original k) -.25 F -.15(ey)-.1 G 3.104(si).15 G 3.104(nt)-3.104 G .604 (he hash, so modifying them will not af)-3.104 F .603(fect the)-.25 F (original hash.)128 478.8 Q(Compare `)5 E(`v)-.74 E(alues')-.25 E('.) -.74 E 2.436 -.8(To s)128 496.8 T .836(ort a hash by v).8 F .836 (alue, you')-.25 F .836(ll need to use a)-.1 F F2(sort)3.336 E F0 3.336 (function. Here')3.336 F 3.337(sad)-.55 G .837 (escending numeric sort of a)-3.337 F(hash by its v)128 508.8 Q(alues:) -.25 E F2 (foreach $key \(sort { $hash{$b} <=> $hash{$a} } keys %hash\) {)152 526.8 Q(printf "%4d %s\\n", $hash{$key}, $key;)176 538.8 Q(})152 550.8 Q F0 1.036(Used as an lv)128 568.8 R(alue,)-.25 E F2(keys)3.536 E F0(allo) 3.536 E 1.036(ws you to increase the number of hash b)-.25 F(uck)-.2 E 1.036(ets allocated for the gi)-.1 F -.15(ve)-.25 G(n).15 E 3.554 (hash. This)128 580.8 R 1.054(can g)3.554 F 1.054 (ain you a measure of ef)-.05 F(\214cienc)-.25 E 3.554(yi)-.15 G 3.554 (fy)-3.554 G 1.054(ou kno)-3.554 F 3.554(wt)-.25 G 1.054 (he hash is going to get big.)-3.554 F 1.054(\(This is)6.054 F (similar to pre-e)128 592.8 Q(xtending an array by assigning a lar)-.15 E(ger number to $#array)-.18 E 2.5(.\) If)-.65 F(you say)2.5 E F2 (keys %hash = 200;)152 610.8 Q F0(then)128 628.8 Q F2(%hash)2.799 E F0 .299(will ha)2.799 F .599 -.15(ve a)-.2 H 2.799(tl).15 G .299 (east 200 b)-2.799 F(uck)-.2 E .299 (ets allocated for it\255\255256 of them, in f)-.1 F .299 (act, since it rounds up to)-.1 F 1.276(the ne)128 640.8 R 1.276(xt po) -.15 F 1.276(wer of tw)-.25 F 3.776(o. These)-.1 F -.2(bu)3.776 G(ck).2 E 1.277(ets will be retained e)-.1 F -.15(ve)-.25 G 3.777(ni).15 G 3.777 (fy)-3.777 G 1.277(ou do)-3.777 F F2 1.277(%hash = \(\))3.777 F F0 3.777 (,u)C(se)-3.777 E F2(undef)3.777 E(%hash)128 652.8 Q F0 .429(if you w) 2.929 F .429(ant to free the storage while)-.1 F F2(%hash)2.929 E F0 .429(is still in scope.)2.929 F -1.1(Yo)5.429 G 2.929(uc)1.1 G(an') -2.929 E 2.929(ts)-.18 G .429(hrink the number of)-2.929 F -.2(bu)128 664.8 S(ck).2 E 1.325(ets allocated for the hash using)-.1 F F2(keys) 3.825 E F0 1.325(in this w)3.825 F 1.325(ay \(b)-.1 F 1.325 (ut you needn')-.2 F 3.826(tw)-.18 G 1.326(orry about doing this by) -3.926 F(accident, as trying has no ef)128 676.8 Q(fect\).)-.25 E F2 (keys @array)2.5 E F0(in an lv)2.5 E(alue conte)-.25 E (xt is a syntax error)-.15 E(.)-.55 E .272(Starting with Perl 5.14,)128 694.8 R F2(keys)2.772 E F0 .272(can tak)2.772 F 2.772(eas)-.1 G(calar) -2.772 E F1(EXPR)2.772 E F0 2.771(,w)C .271 (hich must contain a reference to an unblessed)-2.771 F .842 (hash or array)128 706.8 R 5.843(.T)-.65 G .843(he ar)-5.843 F .843 (gument will be dereferenced automatically)-.18 F 5.843(.T)-.65 G .843 (his aspect of)-5.843 F F2(keys)3.343 E F0 .843(is considered)3.343 F (highly e)128 718.8 Q 2.5(xperimental. The)-.15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 34)162.62 F 0 Cg EP %%Page: 35 35 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (for \(keys $hashref\) { ... })152 84 Q (for \(keys $obj\255>get_arrayref\) { ... })152 96 Q F0(See also)128 114 Q F1(each)2.5 E F0(,)A F1(values)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(sort)2.5 E F0(.)A(kill)108 130.8 Q/F2 9/Times-Roman@0 SF(SIGN)2.5 E(AL)-.315 E F0 (,)A F2(LIST)2.5 E F0 .407(Sends a signal to a list of processes.)128 142.8 R .406 (Returns the number of processes successfully signaled \(which is)5.406 F(not necessarily the same as the number actually killed\).)128 154.8 Q F1($cnt = kill 1, $child1, $child2;)152 172.8 Q(kill 9, @goners;)152 184.8 Q F0(If)128 202.8 Q F2(SIGN)3.45 E(AL)-.315 E F0 .95 (is zero, no signal is sent to the process, b)3.45 F(ut)-.2 E F1(kill) 3.451 E F0 .951(checks whether it')3.451 F(s)-.55 E/F3 10/Times-Italic@0 SF(possible)3.451 E F0 .951(to send a)3.451 F .775 (signal to it \(that means, to be brief, that the process is o)128 214.8 R .774(wned by the same user)-.25 F 3.274(,o)-.4 G 3.274(rw)-3.274 G 3.274(ea)-3.274 G .774(re the super)-3.274 F(-)-.2 E 3.346(user\). This) 128 226.8 R .846(is useful to check that a child process is still ali) 3.346 F 1.147 -.15(ve \()-.25 H -2.15 -.25(ev e).15 H 3.347(ni).25 G 3.347(fo)-3.347 G .847(nly as a zombie\) and hasn')-3.347 F(t)-.18 E (changed its)128 238.8 Q F2(UID)2.5 E F0 5(.S)C (ee perlport for notes on the portability of this construct.)-5 E(Unlik) 128 256.8 Q 2.7(ei)-.1 G 2.7(nt)-2.7 G .2(he shell, if)-2.7 F F2(SIGN) 2.7 E(AL)-.315 E F0 .2(is ne)2.7 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 2.7(,i).15 G 2.699(tk)-2.7 G .199 (ills process groups instead of processes. That means you)-2.699 F (usually w)128 268.8 Q(ant to use positi)-.1 E .3 -.15(ve n)-.25 H (ot ne).15 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve s)-.25 H 2.5(ignals. Y) .15 F(ou may also use a signal name in quotes.)-1.1 E 1.073(The beha)128 286.8 R 1.073(vior of kill when a)-.2 F/F4 9/Times-Italic@0 SF(PR)3.573 E(OCESS)-.36 E F0 1.073(number is zero or ne)3.573 F -.05(ga)-.15 G(ti) .05 E 1.373 -.15(ve d)-.25 H 1.074(epends on the operating system.).15 F -.15(Fo)128 298.8 S 3.416(re).15 G .916(xample, on POSIX-conforming sys\ tems, zero will signal the current process group and \2551 will)-3.566 F (signal all processes.)128 310.8 Q(See `)128 328.8 Q(`Signals')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc for more details.)-2.5 E(last)108 345.6 Q F2(LABEL)2.5 E F0(last)108 357.6 Q(The)128 357.6 Q F1(last)2.588 E F0 .088(command is lik)2.588 F 2.588(et)-.1 G(he)-2.588 E F1(break) 2.588 E F0 .088(statement in C \(as used in loops\); it immediately e) 2.588 F .089(xits the loop)-.15 F 1.943(in question.)128 369.6 R 1.943 (If the)6.943 F F2(LABEL)4.443 E F0 1.943 (is omitted, the command refers to the innermost enclosing loop.)4.443 F (The)6.942 E F1(continue)128 381.6 Q F0(block, if an)2.5 E 1.3 -.65 (y, i)-.15 H 2.5(sn).65 G(ot e)-2.5 E -.15(xe)-.15 G(cuted:).15 E F1 (LINE: while \(\) {)152 399.6 Q(last LINE if /^$/;)176 411.6 Q 6 (#e)12 G(xit when done with header)-6 E(#...)176 423.6 Q(})152 435.6 Q (last)128 453.6 Q F0 .272(cannot be used to e)2.772 F .273 (xit a block that returns a v)-.15 F .273(alue such as)-.25 F F1 .273 (eval {})2.773 F F0(,)A F1 .273(sub {})2.773 F F0 2.773(,o)C(r)-2.773 E F1 .273(do {})2.773 F F0 2.773(,a)C(nd)-2.773 E(should not be used to e) 128 465.6 Q(xit a)-.15 E F3(gr)2.5 E(ep\(\))-.37 E F0(or)2.5 E F3 (map\(\))2.5 E F0(operation.)2.5 E .773 (Note that a block by itself is semantically identical to a loop that e) 128 483.6 R -.15(xe)-.15 G .773(cutes once.).15 F(Thus)5.772 E F1(last) 3.272 E F0 .772(can be)3.272 F(used to ef)128 495.6 Q(fect an early e) -.25 E(xit out of such a block.)-.15 E(See also `)128 513.6 Q (`continue')-.74 E 2.5('f)-.74 G(or an illustration of ho)-2.5 E(w)-.25 E F1(last)2.5 E F0(,)A F1(next)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(redo)2.5 E F0 -.1(wo)2.5 G(rk.).1 E(lc)108 530.4 Q F2(EXPR)2.5 E F0(lc)108 542.4 Q .922(Returns a lo)128 542.4 R .922(wercased v)-.25 F .922(ersion of)-.15 F F2(EXPR)3.422 E F0 5.922(.T)C .922 (his is the internal function implementing the)-5.922 F F1(\\L)3.423 E F0 .923(escape in)3.423 F(double-quoted strings.)128 554.4 Q(If)128 572.4 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A (What gets returned depends on se)128 590.4 Q -.15(ve)-.25 G(ral f).15 E (actors:)-.1 E(If)128 607.2 Q F1(use bytes)2.5 E F0(is in ef)2.5 E (fect:)-.25 E(On)148 619.2 Q F2(EBCDIC)2.5 E F0(platforms)2.5 E (The results are what the C language system call)168 631.2 Q F1 (tolower\(\))2.5 E F0(returns.)2.5 E(On)148 648 Q F2(ASCII)2.5 E F0 (platforms)2.5 E(The results follo)168 660 Q(w)-.25 E F2(ASCII)2.5 E F0 2.5(semantics. Only)2.5 F(characters)2.5 E F1(A\255Z)2.5 E F0 (change, to)2.5 E F1(a\255z)2.5 E F0(respecti)2.5 E -.15(ve)-.25 G(ly) .15 E(.)-.65 E(Otherwise, If)128 676.8 Q F2(EXPR)2.5 E F0(has the)2.5 E F2(UTF8)2.5 E F0(\215ag set)2.5 E .365 (If the current package has a subroutine named)148 688.8 R F1(ToLower) 2.865 E F0 2.865(,i)C 2.865(tw)-2.865 G .364 (ill be used to change the case \(See)-2.865 F -.74(``)148 700.8 S(User) .74 E .888(-De\214ned Case Mappings \(for serious hack)-.2 F .888 (ers only\)')-.1 F 3.388('i)-.74 G 3.388(np)-3.388 G 3.388 (erlunicode.\) Otherwise)-3.388 F(Unicode)3.388 E (semantics are used for the case change.)148 712.8 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 35)162.62 F 0 Cg EP %%Page: 36 36 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(Otherwise, if)128 84 Q/F1 10/Courier@0 SF(use locale)2.5 E F0(is in ef)2.5 E(fect)-.25 E (Respects current)148 96 Q/F2 9/Times-Roman@0 SF(LC_CTYPE)2.5 E F0 2.5 (locale. See)2.5 F(perllocale.)2.5 E(Otherwise, if)128 112.8 Q F1 (use feature \010unicode_strings\010)2.5 E F0(is in ef)2.5 E(fect:)-.25 E 2.176(Unicode semantics are used for the case change.)148 124.8 R(An) 7.175 E 4.675(ys)-.15 G 2.175(ubroutine named)-4.675 F F1(ToLower)4.675 E F0 2.175(will be)4.675 F(ignored.)148 136.8 Q(Otherwise:)128 153.6 Q (On)148 165.6 Q F2(EBCDIC)2.5 E F0(platforms)2.5 E (The results are what the C language system call)168 177.6 Q F1 (tolower\(\))2.5 E F0(returns.)2.5 E(On)148 194.4 Q F2(ASCII)2.5 E F0 (platforms)2.5 E F2(ASCII)168 206.4 Q F0 .961 (semantics are used for the case change.)3.461 F .962(The lo)5.962 F .962(wercase of an)-.25 F 3.462(yc)-.15 G .962(haracter outside the) -3.462 F F2(ASCII)168 218.4 Q F0(range is the character itself.)2.5 E (lc\214rst)108 235.2 Q F2(EXPR)2.5 E F0(lc\214rst)108 247.2 Q 3.461 (Returns the v)128 259.2 R 3.461(alue of)-.25 F F2(EXPR)5.961 E F0 3.46 (with the \214rst character lo)5.961 F 5.96(wercased. This)-.25 F 3.46 (is the internal function)5.96 F(implementing the)128 271.2 Q F1(\\l)2.5 E F0(escape in double-quoted strings.)2.5 E(If)128 289.2 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A(This function beha)128 307.2 Q -.15(ve)-.2 G 2.5(st).15 G(he same w)-2.5 E(ay under v)-.1 E (arious pragmata, such as in a locale, as `)-.25 E(`lc')-.74 E 2.5('d) -.74 G(oes.)-2.5 E(length)108 324 Q F2(EXPR)2.5 E F0(length)108 336 Q .071(Returns the length in)128 348 R/F3 10/Times-Italic@0 SF -.15(ch) 2.571 G(ar).15 E(acter)-.15 E(s)-.1 E F0 .071(of the v)2.571 F .071 (alue of)-.25 F F2(EXPR)2.571 E F0 5.071(.I)C(f)-5.071 E F2(EXPR)2.571 E F0 .071(is omitted, returns the length of)2.571 F F1($_)2.572 E F0 5.072 (.I)C(f)-5.072 E F2(EXPR)128 360 Q F0(is unde\214ned, returns)2.5 E F1 (undef)2.5 E F0(.)A .054(This function cannot be used on an entire arra\ y or hash to \214nd out ho)128 378 R 2.553(wm)-.25 G(an)-2.553 E 2.553 (ye)-.15 G .053(lements these ha)-2.553 F -.15(ve)-.2 G 5.053(.F).15 G (or)-5.203 E(that, use)128 390 Q F1(scalar @array)2.5 E F0(and)2.5 E F1 (scalar keys %hash)2.5 E F0 2.5(,r)C(especti)-2.5 E -.15(ve)-.25 G(ly) .15 E(.)-.65 E(Lik)128 408 Q 3.91(ea)-.1 G 1.41 (ll Perl character operations,)-3.91 F F3(length\(\))3.911 E F0 1.411 (normally deals in logical characters, not ph)3.911 F 1.411 (ysical bytes.)-.05 F -.15(Fo)128 420 S 14.615(rh).15 G 12.615 -.25 (ow m)-14.615 H(an).25 E 14.615(yb)-.15 G 12.115 (ytes a string encoded as)-14.615 F F2(UTF\2558)14.614 E F0 -.1(wo) 14.614 G 12.114(uld tak).1 F 14.614(eu)-.1 G 12.114(p, use)-14.614 F F1 (length\(Encode::encode_utf8\(EXPR\)\))128 432 Q F0(\(you')4.343 E 1.843 (ll ha)-.1 F 2.144 -.15(ve t)-.2 H(o).15 E F1 1.844(use Encode)4.344 F F0 4.344(\214rst\). See)4.344 F(Encode)4.344 E(and perlunicode.)128 444 Q(link)108 460.8 Q F2(OLDFILE)2.5 E F0(,NEWFILE)A(Creates a ne)128 472.8 Q 2.5<778c>-.25 G(lename link)-2.5 E(ed to the old \214lename.)-.1 E (Returns true for success, f)5 E(alse otherwise.)-.1 E(listen)108 489.6 Q F2(SOCKET)2.5 E F0(,Q)A(UEUESIZE)-.1 E .517 (Does the same thing that the)128 501.6 R F3(listen)3.017 E F0 .517 (\(2\) system call does.)1.666 F .517(Returns true if it succeeded, f) 5.517 F .517(alse otherwise.)-.1 F(See the e)128 513.6 Q(xample in `) -.15 E(`Sock)-.74 E(ets: Client/Serv)-.1 E(er Communication')-.15 E 2.5 ('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E(local)108 530.4 Q F2(EXPR)2.5 E F0 -1.1(Yo)128 542.4 S 3.204(ur)1.1 G .704(eally probably w)-3.204 F .704(ant to be using)-.1 F F1(my)3.205 E F0 .705(instead, because)3.205 F F1(local)3.205 E F0(isn')3.205 E 3.205(tw)-.18 G .705 (hat most people think of as)-3.205 F -.74(``)128 554.4 S(local').74 E 2.5('. See)-.74 F -.74(``)2.5 G(Pri).74 E -.25(va)-.25 G(te V).25 E (ariables via)-1.11 E F3(my\(\))2.5 E F0 1.48 -.74('' i)D 2.5(np).74 G (erlsub for details.)-2.5 E 3.043(Al)128 572.4 S .542 (ocal modi\214es the listed v)-3.043 F .542 (ariables to be local to the enclosing block, \214le, or e)-.25 F -.25 (va)-.25 G 3.042(l. If).25 F .542(more than one)3.042 F -.25(va)128 584.4 S .507(lue is listed, the list must be placed in parentheses.).25 F .507(See `)5.507 F(`T)-.74 E .507(emporary V)-.7 F .507(alues via) -1.11 F F3(local\(\))3.007 E F0 1.987 -.74('' i)D 3.007(np).74 G(erlsub) -3.007 E(for details, including issues with tied arrays and hashes.)128 596.4 Q(The)128 614.4 Q F1 2.624(delete local EXPR)5.124 F F0 2.623 (construct can also be used to localize the deletion of array/hash)5.124 F(elements to the current block.)128 626.4 Q(See `)5 E (`Localized deletion of elements of composite types')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlsub)-2.5 E(.)-.4 E(localtime)108 643.2 Q F2(EXPR)2.5 E F0(localtime)108 655.2 Q(Con)128 667.2 Q -.15(ve)-.4 G 1.127(rts a ti\ me as returned by the time function to a 9\255element list with the tim\ e analyzed for the).15 F(local time zone.)128 679.2 Q -.8(Ty)5 G (pically used as follo).8 E(ws:)-.25 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 36)162.62 F 0 Cg EP %%Page: 37 37 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF -6 12(#0 1 2)152 84 T 30(34)18 G 30(5678)-6 G (\($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst\) =)152 96 Q (localtime\(time\);)416 108 Q F0 .071(All list elements are numeric and\ come straight out of the C `struct tm'.)128 126 R F1($sec)5.07 E F0(,)A F1($min)2.57 E F0 2.57(,a)C(nd)-2.57 E F1($hour)2.57 E F0(are)2.57 E (the seconds, minutes, and hours of the speci\214ed time.)128 138 Q F1 ($mday)128 156 Q F0 .708(is the day of the month and)3.208 F F1($mon) 3.208 E F0 .708(the month in the range)3.208 F F1(0..11)3.209 E F0 3.209 (,w)C .709(ith 0 indicating January)-3.209 F(and 11 indicating December) 128 168 Q 5(.T)-.55 G(his mak)-5 E (es it easy to get a month name from a list:)-.1 E F1 (my @abbr = qw\( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec \);)152 186 Q(print "$abbr[$mon] $mday";)152 198 Q 6(#$)152 210 S (mon=9, $mday=18 gives "Oct 18")-6 E($year)128 228 Q F0 .606 (is the number of years since 1900,)3.106 F/F2 10/Times-Bold@0 SF(not) 3.106 E F0 .606(just the last tw)3.106 F 3.106(od)-.1 G .606 (igits of the year)-3.106 F 5.606(.T)-.55 G .606(hat is,)-5.606 F F1 ($year)3.106 E F0(is)3.106 E F1(123)128 240 Q F0(in year 2023.)2.5 E (The proper w)5 E(ay to get a 4\255digit year is simply:)-.1 E F1 ($year += 1900;)152 258 Q F0 (Otherwise you create non\255Y2K\255compliant programs)128 276 Q 1.666 <8a61>1.666 G(nd you w)-1.666 E(ouldn')-.1 E 2.5(tw)-.18 G (ant to do that, w)-2.6 E(ould you?)-.1 E 1.6 -.8(To g)128 294 T (et the last tw).8 E 2.5(od)-.1 G(igits of the year \(e.g., `)-2.5 E (`01')-.74 E 2.5('i)-.74 G 2.5(n2)-2.5 G(001\) do:)-2.5 E F1 ($year = sprintf\("%02d", $year % 100\);)152 312 Q($wday)128 330 Q F0 .63(is the day of the week, with 0 indicating Sunday and 3 indicating W) 3.13 F(ednesday)-.8 E(.)-.65 E F1($yday)5.63 E F0 .63(is the)3.13 F (day of the year)128 342 Q 2.5(,i)-.4 G 2.5(nt)-2.5 G(he range)-2.5 E F1 (0..364)2.5 E F0(\(or)2.5 E F1(0..365)2.5 E F0(in leap years.\))2.5 E F1 ($isdst)128 360 Q F0 (is true if the speci\214ed time occurs during Daylight Sa)2.5 E(ving T) -.2 E(ime, f)-.35 E(alse otherwise.)-.1 E(If)128 378 Q/F3 9 /Times-Roman@0 SF(EXPR)2.5 E F0(is omitted,)2.5 E F1(localtime\(\))2.5 E F0(uses the current time \(as returned by)2.5 E/F4 10/Times-Italic@0 SF (time)2.5 E F0(\(3\)\).)1.666 E(In scalar conte)128 396 Q(xt,)-.15 E F1 (localtime\(\))2.5 E F0(returns the)2.5 E F4(ctime)2.5 E F0(\(3\) v) 1.666 E(alue:)-.25 E F1($now_string = localtime;)152 414 Q 6(#e)12 G (.g., "Thu Oct 13 04:54:34 1994")-6 E F0 .791(This scalar v)128 432 R .791(alue is)-.25 F F2(not)3.291 E F0 .791(locale-dependent b)3.291 F .791(ut is a Perl b)-.2 F .791(uiltin. F)-.2 F(or)-.15 E F3(GMT)3.291 E F0 .79(instead of local time use the)3.29 F -.74(``)128 444 S(gmtime') .74 E 3.142('b)-.74 G .642(uiltin. See also the)-3.342 F F1(Time::Local) 3.142 E F0 .643(module \(for con)3.142 F -.15(ve)-.4 G .643 (rting seconds, minutes, hours, and).15 F .358(such back to the inte)128 456 R .358(ger v)-.15 F .358(alue returned by)-.25 F F4(time\(\))2.858 E F0 .358(\), and the)B F3(POSIX)2.858 E F0(module')2.858 E(s)-.55 E F4 (strftime)2.857 E F0 .357(\(3\) and)1.666 F F4(mktime)2.857 E F0(\(3\)) 1.666 E(functions.)128 468 Q 2.588 -.8(To g)128 486 T .988(et some).8 F .988(what similar b)-.25 F .989 (ut locale-dependent date strings, set up your locale en)-.2 F .989 (vironment v)-.4 F(ariables)-.25 E (appropriately \(please see perllocale\) and try for e)128 498 Q (xample:)-.15 E F1(use POSIX qw\(strftime\);)152 516 Q ($now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;)152 528 Q 6 (#o)152 540 S 6(rf)-6 G(or GMT formatted appropriately for your locale:) -6 E($now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime;)152 552 Q F0 .688(Note that the)128 570 R F1(%a)3.188 E F0(and)3.188 E F1(%b)3.188 E F0 3.188(,t)C .688 (he short forms of the day of the week and the month of the year)-3.188 F 3.187(,m)-.4 G .687(ay not)-3.187 F (necessarily be three characters wide.)128 582 Q(See `)128 600 Q (`localtime')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlport for portability concerns.)-2.5 E .515(The T)128 618 R .515 (ime::gmtime and T)-.35 F .515(ime::localtime modules pro)-.35 F .515 (vide a con)-.15 F -.15(ve)-.4 G .516 (nient, by-name access mechanism to).15 F(the)128 630 Q F4(gmtime\(\)) 2.5 E F0(and)2.5 E F4(localtime\(\))2.5 E F0(functions, respecti)2.5 E -.15(ve)-.25 G(ly).15 E(.)-.65 E -.15(Fo)128 648 S 2.5(rac).15 G (omprehensi)-2.5 E .3 -.15(ve d)-.25 H (ate and time representation look at the DateT).15 E(ime module on)-.35 E F3(CP)2.5 E(AN)-.828 E F0(.)A(lock)108 664.8 Q F3(THING)2.5 E F0 1.079 (This function places an advisory lock on a shared v)128 676.8 R 1.078 (ariable or referenced object contained in)-.25 F/F5 9/Times-Italic@0 SF (THING)3.578 E F0(until the lock goes out of scope.)128 688.8 Q F4(loc) 128 706.8 Q(k\(\))-.2 E F0 .983(is a `)3.483 F .983(`weak k)-.74 F -.15 (ey)-.1 G -.1(wo).15 G(rd').1 E 3.483(':t)-.74 G .983 (his means that if you')-3.483 F 1.283 -.15(ve d)-.5 H .984 (e\214ned a function by this name \(before an).15 F(y)-.15 E .537 (calls to it\), that function will be called instead.)128 718.8 R .537 (If you are not under)5.537 F F1 .536(use threads::shared)3.037 F F0 (this)3.036 E(does nothing.)128 730.8 Q(See threads::shared.)5 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 37)162.62 F 0 Cg EP %%Page: 38 38 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(log)108 84 Q/F1 9 /Times-Roman@0 SF(EXPR)2.5 E F0(log)108 96 Q .374 (Returns the natural log)128 96 R .374(arithm \(base)-.05 F/F2 10 /Times-Italic@0 SF(e)2.874 E F0 2.874(\)o)C(f)-2.874 E F1(EXPR)2.874 E F0 5.374(.I)C(f)-5.374 E F1(EXPR)2.874 E F0 .374 (is omitted, returns the log of)2.874 F/F3 10/Courier@0 SF($_)2.875 E F0 5.375(.T)C 2.875(og)-6.175 G .375(et the)-2.875 F .618(log of another b\ ase, use basic algebra: The base-N log of a number is equal to the natu\ ral log of that)128 108 R(number di)128 120 Q (vided by the natural log of N.)-.25 E -.15(Fo)5 G 2.5(re).15 G(xample:) -2.65 E F3(sub log10 {)152 138 Q(my $n = shift;)176 150 Q (return log\($n\)/log\(10\);)176 162 Q(})152 174 Q F0(See also `)128 192 Q(`e)-.74 E(xp')-.15 E 2.5('f)-.74 G(or the in)-2.5 E -.15(ve)-.4 G (rse operation.).15 E(lstat)108 208.8 Q F1(EXPR)2.5 E F0(lstat)108 220.8 Q 1.806(Does the same thing as the)128 232.8 R F3(stat)4.306 E F0 1.806 (function \(including setting the special)4.306 F F3(_)4.306 E F0 1.807 (\214lehandle\) b)4.307 F 1.807(ut stats a)-.2 F .576 (symbolic link instead of the \214le the symbolic link points to.)128 244.8 R .576(If symbolic links are unimplemented on)5.576 F 3.76 (your system, a normal)128 256.8 R F3(stat)6.26 E F0 3.76(is done.)6.26 F -.15(Fo)8.76 G 6.26(rm).15 G 3.76 (uch more detailed information, please see the)-6.26 F (documentation for)128 268.8 Q F3(stat)2.5 E F0(.)A(If)128 286.8 Q F1 (EXPR)2.5 E F0(is omitted, stats)2.5 E F3($_)2.5 E F0(.)A(m//)108 303.6 Q(The match operator)128 303.6 Q 5(.S)-.55 G(ee `)-5 E(`Re)-.74 E(ge) -.15 E(xp Quote-Lik)-.15 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E(map)108 320.4 Q F1 .25(BLOCK LIST)2.5 F F0 (map)108 332.4 Q F1(EXPR)2.5 E F0(,LIST)A(Ev)128 344.4 Q 1.6 (aluates the)-.25 F F1(BLOCK)4.1 E F0(or)4.1 E F1(EXPR)4.1 E F0 1.6 (for each element of)4.1 F F1(LIST)4.1 E F0 1.6(\(locally setting)4.1 F F3($_)4.1 E F0 1.599(to each element\) and)4.099 F 1.036 (returns the list v)128 356.4 R 1.037 (alue composed of the results of each such e)-.25 F -.25(va)-.25 G 3.537 (luation. In).25 F 1.037(scalar conte)3.537 F 1.037(xt, returns the)-.15 F .473(total number of elements so generated.)128 368.4 R(Ev)5.473 E (aluates)-.25 E F1(BLOCK)2.973 E F0(or)2.973 E F1(EXPR)2.973 E F0 .473 (in list conte)2.973 F .472(xt, so each element of)-.15 F F1(LIST)128 380.4 Q F0(may produce zero, one, or more elements in the returned v)2.5 E(alue.)-.25 E F3(@chars = map\(chr, @numbers\);)152 398.4 Q F0 (translates a list of numbers to the corresponding characters.)128 416.4 Q F3(my @squares = map { $_ * $_ } @numbers;)152 434.4 Q F0 (translates a list of numbers to their squared v)128 452.4 Q(alues.)-.25 E F3(my @squares = map { $_ > 5 ? \($_ * $_\) : \(\) } @numbers;)152 470.4 Q F0(sho)128 488.4 Q 1.338 (ws that number of returned elements can dif)-.25 F 1.339 (fer from the number of input elements. T)-.25 F 3.839(oo)-.8 G 1.339 (mit an)-3.839 F(element, return an empty list \(\).)128 500.4 Q (This could also be achie)5 E -.15(ve)-.25 G 2.5(db).15 G 2.5(yw)-2.5 G (riting)-2.5 E F3 (my @squares = map { $_ * $_ } grep { $_ > 5 } @numbers;)152 518.4 Q F0 (which mak)128 536.4 Q(es the intention more clear)-.1 E(.)-.55 E .785 (Map al)128 554.4 R -.1(wa)-.1 G .784(ys returns a list, which can be a\ ssigned to a hash such that the elements become k).1 F -.15(ey)-.1 G(/v) .15 E(alue)-.25 E(pairs. See perldata for more details.)128 566.4 Q F3 (%hash = map { get_a_key_for\($_\) => $_ } @array;)152 584.4 Q F0 (is just a funn)128 602.4 Q 2.5(yw)-.15 G(ay to write)-2.6 E F3 (%hash = \(\);)152 620.4 Q(foreach \(@array\) {)152 632.4 Q ($hash{get_a_key_for\($_\)} = $_;)176 644.4 Q(})152 656.4 Q F0 .475 (Note that)128 674.4 R F3($_)2.975 E F0 .475(is an alias to the list v) 2.975 F .475(alue, so it can be used to modify the elements of the)-.25 F F1(LIST)2.975 E F0 5.476(.W)C(hile)-5.476 E 1.617(this is useful and \ supported, it can cause bizarre results if the elements of)128 686.4 R F1(LIST)4.117 E F0 1.617(are not v)4.117 F(ariables.)-.25 E .515 (Using a re)128 698.4 R(gular)-.15 E F3(foreach)3.015 E F0 .515 (loop for this purpose w)3.015 F .515(ould be clearer in most cases.)-.1 F .516(See also `)5.516 F(`grep')-.74 E 3.016('f)-.74 G(or)-3.016 E (an array composed of those items of the original list for which the)128 710.4 Q F1(BLOCK)2.5 E F0(or)2.5 E F1(EXPR)2.5 E F0 -.25(eva)2.5 G (luates to true.).25 E(If)128 728.4 Q F3($_)2.882 E F0 .382(is le)2.882 F .382(xical in the scope where the)-.15 F F3(map)2.882 E F0 .381 (appears \(because it has been declared with)2.882 F F3 .381(my $_)2.881 F F0 .381(\), then,)B(perl v5.14.2)72 768 Q 198.17(2011-10-01 38)162.62 F 0 Cg EP %%Page: 39 39 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .138 (in addition to being locally aliased to the list elements,)128 84 R/F1 10/Courier@0 SF($_)2.638 E F0 -.1(ke)2.638 G .138(eps being le).1 F .139 (xical inside the block; that is,)-.15 F(it can')128 96 Q 2.5(tb)-.18 G 2.5(es)-2.5 G(een from the outside, a)-2.5 E -.2(vo)-.2 G(iding an).2 E 2.5(yp)-.15 G(otential side-ef)-2.5 E(fects.)-.25 E F1({)128 114 Q F0 .018(starts both hash references and blocks, so)2.518 F F1 .018 (map { ...)2.518 F F0 .018(could be either the start of map)2.518 F/F2 9 /Times-Roman@0 SF .267(BLOCK LIST)2.517 F F0 .466(or map)128 126 R F2 (EXPR)2.966 E F0(,)A F2(LIST)2.966 E F0 2.967(.B)C .467 (ecause Perl doesn')-2.967 F 2.967(tl)-.18 G .467 (ook ahead for the closing)-2.967 F F1(})2.967 E F0 .467(it has to tak) 2.967 F 2.967(eag)-.1 G .467(uess at which)-2.967 F(it')128 138 Q 2.727 (sd)-.55 G .227(ealing with based on what it \214nds just after the) -2.727 F F1({)2.727 E F0 2.727(.U)C .227(sually it gets it right, b) -2.727 F .226(ut if it doesn')-.2 F 2.726(ti)-.18 G 2.726(tw)-2.726 G (on')-2.826 E(t)-.18 E .752 (realize something is wrong until it gets to the)128 150 R F1(})3.252 E F0 .752(and encounters the missing \(or une)3.252 F .752 (xpected\) comma.)-.15 F .488 (The syntax error will be reported close to the)128 162 R F1(})2.987 E F0 2.987(,b)C .487(ut you')-3.187 F .487 (ll need to change something near the)-.1 F F1({)2.987 E F0(such)2.987 E (as using a unary)128 174 Q F1(+)2.5 E F0(to gi)2.5 E .3 -.15(ve P)-.25 H(erl some help:).15 E F1(%hash = map {)152 192 Q("\\L$_" => 1)12 E 6 (}@)12 G 6(array #)-6 F(perl guesses EXPR.)6 E(wrong)12 E (%hash = map { +"\\L$_" => 1)152 204 Q 6(}@)12 G 6(array #)-6 F (perl guesses BLOCK. right)6 E(%hash = map { \("\\L$_" => 1\) } @array) 152 216 Q 6(#t)12 G(his also works)-6 E(%hash = map {)152 228 Q (lc\($_\) => 1)12 E 6(}@)12 G 6(array #)-6 F(as does this.)6 E (%hash = map +\( lc\($_\) => 1 \), @array)152 240 Q 6(#t)12 G (his is EXPR and works!)-6 E(%hash = map)152 264 Q 6(\(l)12 G (c\($_\), 1 \),)-6 E 6(@array #)18 F(evaluates to \(1, @array\))6 E F0 (or to force an anon hash constructor use)128 282 Q F1(+{)2.5 E F0(:)A F1 (@hashes = map +{ lc\($_\) => 1 }, @array # EXPR, so needs comma at end) 146 300 Q F0(to get a list of anon)128 318 Q (ymous hashes each with only one entry apiece.)-.15 E(mkdir)108 334.8 Q F2(FILEN)2.5 E(AME)-.315 E F0(,MASK)A(mkdir)108 346.8 Q F2(FILEN)2.5 E (AME)-.315 E F0(mkdir)108 358.8 Q 1.048 (Creates the directory speci\214ed by)128 370.8 R F2(FILEN)3.548 E(AME) -.315 E F0 3.548(,w)C 1.048(ith permissions speci\214ed by)-3.548 F F2 (MASK)3.549 E F0 1.049(\(as modi\214ed by)3.549 F F1(umask)128 382.8 Q F0 2.572(\). If)B .072 (it succeeds it returns true; otherwise it returns f)2.572 F .072 (alse and sets)-.1 F F1($!)2.571 E F0(\(errno\).)2.571 E F2(MASK)5.071 E F0(def)2.571 E .071(aults to)-.1 F(0777 if omitted, and)128 394.8 Q F2 (FILEN)2.5 E(AME)-.315 E F0(def)2.5 E(aults to)-.1 E F1($_)2.5 E F0 (if omitted.)2.5 E .652 (In general, it is better to create directories with a permissi)128 412.8 R -.15(ve)-.25 G F2(MASK)3.302 E F0 .652 (and let the user modify that with)3.152 F(their)128 424.8 Q F1(umask) 3.15 E F0 .65(than it is to supply a restricti)3.15 F -.15(ve)-.25 G F2 (MASK)3.299 E F0 .649(and gi)3.149 F .949 -.15(ve t)-.25 H .649 (he user no w).15 F .649(ay to be more permissi)-.1 F -.15(ve)-.25 G(.) .15 E 2.224(The e)128 436.8 R 2.224 (xceptions to this rule are when the \214le or directory should be k) -.15 F 2.224(ept pri)-.1 F -.25(va)-.25 G 2.225(te \(mail \214les, for) .25 F 2.5(instance\). The)128 448.8 R/F3 10/Times-Italic@0 SF(perlfunc) 2.5 E F0(\(1\) entry on)1.666 E F1(umask)2.5 E F0 (discusses the choice of)2.5 E F2(MASK)2.5 E F0(in more detail.)2.5 E 2.056(Note that according to the)128 466.8 R F2(POSIX)4.556 E F0 2.056 (1003.1\2551996 the)4.556 F F2(FILEN)4.556 E(AME)-.315 E F0 2.055 (may ha)4.556 F 2.355 -.15(ve a)-.2 H 2.355 -.15(ny n).15 H 2.055 (umber of trailing).15 F 4.669(slashes. Some)128 478.8 R 2.169(operatin\ g and \214lesystems do not get this right, so Perl automatically remo) 4.669 F -.15(ve)-.15 G 4.67(sa).15 G(ll)-4.67 E(trailing slashes to k) 128 490.8 Q(eep e)-.1 E -.15(ve)-.25 G(ryone happ).15 E -.65(y.)-.1 G 1.6 -.8(To r)128 508.8 T(ecursi).8 E -.15(ve)-.25 G (ly create a directory structure, look at the).15 E F1(mkpath)2.5 E F0 (function of the File::P)2.5 E(ath module.)-.15 E(msgctl)108 525.6 Q F2 (ID)2.5 E F0(,CMD,ARG)A(Calls the System V)128 537.6 Q F2(IPC)2.5 E F0 (function)2.5 E F3(msgctl)2.5 E F0 2.5(\(2\). Y)1.666 F(ou')-1.1 E (ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1 (use IPC::SysV;)152 555.6 Q F0 .739 (\214rst to get the correct constant de\214nitions.)128 573.6 R(If)5.739 E F2(CMD)3.239 E F0(is)3.239 E F1(IPC_STAT)3.239 E F0 3.239(,t)C(hen) -3.239 E F2(ARG)3.239 E F0 .738(must be a v)3.239 F .738(ariable that) -.25 F .934(will hold the returned)128 585.6 R F1(msqid_ds)3.434 E F0 3.434(structure. Returns)3.434 F(lik)3.434 E(e)-.1 E F1(ioctl)3.434 E F0 3.434(:t)C .934(he unde\214ned v)-3.434 F .935(alue for error)-.25 F(,) -.4 E F1("0)3.435 E .751(but true")128 597.6 R F0 .751 (for zero, or the actual return v)3.251 F .75(alue otherwise.)-.25 F .75 (See also `)5.75 F(`SysV)-.74 E F2(IPC)3.25 E F0 2.23 -.74('' i)D 3.25 (np).74 G .75(erlipc and the)-3.25 F(documentation for)128 609.6 Q F1 (IPC::SysV)2.5 E F0(and)2.5 E F1(IPC::Semaphore)2.5 E F0(.)A(msgget)108 626.4 Q F2(KEY)2.5 E F0(,FLA)A(GS)-.4 E .671(Calls the System V)128 638.4 R F2(IPC)3.171 E F0(function)3.171 E F3(msg)3.171 E -.1(ge)-.1 G (t).1 E F0 3.171(\(2\). Returns)1.666 F .671(the message queue id, or) 3.171 F F1(undef)3.172 E F0 .672(on error)3.172 F 5.672(.S)-.55 G(ee) -5.672 E(also `)128 650.4 Q(`SysV)-.74 E F2(IPC)2.5 E F0 1.48 -.74('' i) D 2.5(np).74 G(erlipc and the documentation for)-2.5 E F1(IPC::SysV)2.5 E F0(and)2.5 E F1(IPC::Msg)2.5 E F0(.)A(msgrcv)108 667.2 Q F2(ID)2.5 E F0(,V)A(AR,SIZE,TYPE,FLA)-1.35 E(GS)-.4 E 1.062(Calls the System V)128 679.2 R F2(IPC)3.562 E F0 1.062(function msgrcv to recei)3.562 F 1.362 -.15(ve a m)-.25 H 1.062(essage from message queue).15 F F2(ID)3.562 E F0 1.061(into v)3.562 F(ariable)-.25 E F2 -1.215(VA)128 691.2 S(R)1.215 E F0 .4(with a maximum message size of)2.899 F F2(SIZE)2.9 E F0 5.4(.N)C .4(ote that when a message is recei)-5.4 F -.15(ve)-.25 G .4 (d, the message type).15 F .76(as a nati)128 703.2 R 1.06 -.15(ve l)-.25 H .76(ong inte).15 F .759(ger will be the \214rst thing in)-.15 F F2 -1.215(VA)3.259 G(R)1.215 E F0 3.259(,f)C(ollo)-3.259 E .759 (wed by the actual message.)-.25 F .759(This packing)5.759 F .903 (may be opened with)128 715.2 R F1 .903(unpack\("l! a*"\))3.403 F F0 5.903(.T)C .904(aints the v)-6.703 F 3.404(ariable. Returns)-.25 F .904 (true if successful, f)3.404 F .904(alse on)-.1 F(error)128 727.2 Q 11.526(.S)-.55 G 6.526(ee also `)-11.526 F(`SysV)-.74 E F2(IPC)9.026 E F0 8.006 -.74('' i)D 9.026(np).74 G 6.525 (erlipc and the documentation for)-9.026 F F1(IPC::SysV)9.025 E F0(and) 9.025 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 39)162.62 F 0 Cg EP %%Page: 40 40 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (IPC::SysV::Msg)128 84 Q F0(.)A(msgsnd)108 100.8 Q/F2 9/Times-Roman@0 SF (ID)2.5 E F0(,MSG,FLA)A(GS)-.4 E 1.099(Calls the System V)128 112.8 R F2 (IPC)3.599 E F0 1.099(function msgsnd to send the message)3.599 F F2 (MSG)3.599 E F0 1.099(to the message queue)3.599 F F2(ID)3.6 E F0(.)A F2 (MSG)6.1 E F0 .128(must be)128 124.8 R .128(gin with the nati)-.15 F .428 -.15(ve l)-.25 H .128(ong inte).15 F .128 (ger message type, be follo)-.15 F .127 (wed by the length of the actual message,)-.25 F 1.259 (and then \214nally the message itself.)128 136.8 R 1.259 (This kind of packing can be achie)6.259 F -.15(ve)-.25 G 3.76(dw).15 G (ith)-3.76 E F1 1.26(pack\("l! a*",)3.76 F 1.597($type, $message\))128 148.8 R F0 6.597(.R)C 1.597(eturns true if successful, f)-6.597 F 1.597 (alse on error)-.1 F 6.597(.S)-.55 G 1.597(ee also the)-6.597 F F1 (IPC::SysV)4.097 E F0(and)4.096 E F1(IPC::SysV::Msg)128 160.8 Q F0 (documentation.)2.5 E(my)108 177.6 Q F2(EXPR)2.5 E F0(my)108 189.6 Q F2 .25(TYPE EXPR)2.5 F F0(my)108 201.6 Q F2(EXPR)2.5 E F0(:)2.5 E F2 -.999 (AT)2.5 G(TRS).999 E F0(my)108 213.6 Q F2 .25(TYPE EXPR)2.5 F F0(:)2.5 E F2 -.999(AT)2.5 G(TRS).999 E F0(A)128 225.6 Q F1(my)2.766 E F0 .266 (declares the listed v)2.766 F .267(ariables to be local \(le)-.25 F .267(xically\) to the enclosing block, \214le, or)-.15 F F1(eval)2.767 E F0 5.267(.I)C 2.767(fm)-5.267 G(ore)-2.767 E(than one v)128 237.6 Q (alue is listed, the list must be placed in parentheses.)-.25 E .572 (The e)128 255.6 R .572(xact semantics and interf)-.15 F .572(ace of)-.1 F F2(TYPE)3.072 E F0(and)3.072 E F2 -.999(AT)3.072 G(TRS).999 E F0 .572 (are still e)3.072 F -.2(vo)-.25 G(lving.).2 E F2(TYPE)5.571 E F0 .571 (is currently bound to)3.071 F 2.312(the use of the)128 267.6 R F1 (fields)4.812 E F0 2.312(pragma, and attrib)4.812 F 2.312 (utes are handled using the)-.2 F F1(attributes)4.812 E F0 2.313 (pragma, or)4.813 F .774(starting from Perl 5.8.0 also via the)128 279.6 R F1(Attribute::Handlers)3.273 E F0 3.273(module. See)3.273 F -.74(``) 3.273 G(Pri).74 E -.25(va)-.25 G .773(te V).25 F .773(ariables via)-1.11 F/F3 10/Times-Italic@0 SF(my\(\))128 291.6 Q F0 1.48 -.74('' i)D 2.5(np) .74 G(erlsub for details, and \214elds, attrib)-2.5 E(utes, and Attrib) -.2 E(ute::Handlers.)-.2 E(ne)108 308.4 Q(xt)-.15 E F2(LABEL)2.5 E F0 (ne)108 320.4 Q(xt)-.15 E(The)128 332.4 Q F1(next)2.5 E F0 (command is lik)2.5 E 2.5(et)-.1 G(he)-2.5 E F1(continue)2.5 E F0 (statement in C; it starts the ne)2.5 E(xt iteration of the loop:)-.15 E F1(LINE: while \(\) {)152 350.4 Q(next LINE if /^#/;)176 362.4 Q 6(#d)12 G(iscard comments)-6 E(#...)176 374.4 Q(})152 386.4 Q F0 1.285 (Note that if there were a)128 404.4 R F1(continue)3.785 E F0 1.285 (block on the abo)3.785 F -.15(ve)-.15 G 3.785(,i).15 G 3.785(tw)-3.785 G 1.286(ould get e)-3.885 F -.15(xe)-.15 G 1.286(cuted e).15 F -.15(ve) -.25 G 3.786(no).15 G 3.786(nd)-3.786 G(iscarded)-3.786 E 2.5(lines. If) 128 416.4 R F2(LABEL)2.5 E F0 (is omitted, the command refers to the innermost enclosing loop.)2.5 E F1(next)128 434.4 Q F0 .662(cannot be used to e)3.162 F .662 (xit a block which returns a v)-.15 F .661(alue such as)-.25 F F1 .661 (eval {})3.161 F F0(,)A F1 .661(sub {})3.161 F F0 3.161(,o)C(r)-3.161 E F1 .661(do {})3.161 F F0(,)A(and should not be used to e)128 446.4 Q (xit a)-.15 E F3(gr)2.5 E(ep\(\))-.37 E F0(or)2.5 E F3(map\(\))2.5 E F0 (operation.)2.5 E .379 (Note that a block by itself is semantically identical to a loop that e) 128 464.4 R -.15(xe)-.15 G .379(cutes once.).15 F(Thus)5.379 E F1(next) 2.879 E F0 .379(will e)2.879 F(xit)-.15 E(such a block early)128 476.4 Q (.)-.65 E(See also `)128 494.4 Q(`continue')-.74 E 2.5('f)-.74 G (or an illustration of ho)-2.5 E(w)-.25 E F1(last)2.5 E F0(,)A F1(next) 2.5 E F0 2.5(,a)C(nd)-2.5 E F1(redo)2.5 E F0 -.1(wo)2.5 G(rk.).1 E(no) 108 511.2 Q F2 .25(MODULE VERSION LIST)2.5 F F0(no)108 523.2 Q F2 .25 (MODULE VERSION)2.5 F F0(no)108 535.2 Q F2 .25(MODULE LIST)2.5 F F0(no) 108 547.2 Q F2(MODULE)2.5 E F0(no)108 559.2 Q F2(VERSION)2.5 E F0 (See the)128 571.2 Q F1(use)2.5 E F0(function, of which)2.5 E F1(no)2.5 E F0(is the opposite.)2.5 E(oct)108 588 Q F2(EXPR)2.5 E F0(oct)108 600 Q (Interprets)128 600 Q F2(EXPR)3.154 E F0 .654 (as an octal string and returns the corresponding v)3.154 F 3.154 (alue. \(If)-.25 F F2(EXPR)3.154 E F0 .653(happens to start of)3.154 F (f)-.25 E(with)128 612 Q F1(0x)3.396 E F0 3.396(,i)C .896 (nterprets it as a he)-3.396 F 3.397(xs)-.15 G 3.397(tring. If)-3.397 F F2(EXPR)3.397 E F0 .897(starts of)3.397 F 3.397(fw)-.25 G(ith)-3.397 E F1(0b)3.397 E F0 3.397(,i)C 3.397(ti)-3.397 G 3.397(si)-3.397 G .897 (nterpreted as a binary string.)-3.397 F 1.105 (Leading whitespace is ignored in all three cases.\))128 624 R 1.105 (The follo)6.105 F 1.105(wing will handle decimal, binary)-.25 F 3.605 (,o)-.65 G(ctal,)-3.605 E(and he)128 636 Q 2.5(xi)-.15 G 2.5(ns)-2.5 G (tandard Perl notation:)-2.5 E F1($val = oct\($val\) if $val =~ /^0/;) 152 654 Q F0(If)128 672 Q F2(EXPR)4.345 E F0 1.846(is omitted, uses) 4.345 F F1($_)4.346 E F0 9.346(.T)C 4.346(og)-10.146 G 4.346(ot)-4.346 G 1.846(he other w)-4.346 F 1.846(ay \(produce a number in octal\), use) -.1 F F3(sprintf\(\))4.346 E F0(or)4.346 E F3(printf\(\))128 684 Q F0(:) A F1($dec_perms = \(stat\("filename"\)\)[2] & 07777;)152 702 Q ($oct_perm_str = sprintf "%o", $perms;)152 714 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 40)162.62 F 0 Cg EP %%Page: 41 41 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(The)128 84 Q/F1 10 /Times-Italic@0 SF(oct\(\))3.96 E F0 1.46 (function is commonly used when a string such as)3.96 F/F2 10/Courier@0 SF(644)3.959 E F0 1.459(needs to be con)3.959 F -.15(ve)-.4 G 1.459 (rted into a \214le).15 F 2.913(mode, for e)128 96 R 5.413 (xample. Although)-.15 F 2.913(Perl automatically con)5.413 F -.15(ve) -.4 G 2.914(rts strings into numbers as needed, this).15 F (automatic con)128 108 Q -.15(ve)-.4 G(rsion assumes base 10.).15 E .596 (Leading white space is ignored without w)128 126 R .596 (arning, as too are an)-.1 F 3.095(yt)-.15 G .595 (railing non-digits, such as a decimal)-3.095 F(point \()128 138 Q F2 (oct)A F0(only handles non-ne)2.5 E -.05(ga)-.15 G(ti).05 E .3 -.15 (ve i)-.25 H(nte).15 E(gers, not ne)-.15 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve i)-.25 H(nte).15 E(gers or \215oating point\).)-.15 E(open)108 154.8 Q/F3 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(,EXPR)A(open)108 166.8 Q F3(FILEHANDLE)2.5 E F0(,MODE,EXPR)A(open)108 178.8 Q F3(FILEHANDLE)2.5 E F0(,MODE,EXPR,LIST)A(open)108 190.8 Q F3(FILEHANDLE)2.5 E F0 (,MODE,REFERENCE)A(open)108 202.8 Q F3(FILEHANDLE)2.5 E F0 (Opens the \214le whose \214lename is gi)128 214.8 Q -.15(ve)-.25 G 2.5 (nb).15 G(y)-2.5 E F3(EXPR)2.5 E F0 2.5(,a)C(nd associates it with)-2.5 E F3(FILEHANDLE)2.5 E F0(.)A(Simple e)128 232.8 Q (xamples to open a \214le for reading:)-.15 E F2 (open\(my $fh, "<", "input.txt"\))152 250.8 Q (or die "cannot open < input.txt: $!";)176 262.8 Q F0(and for writing:) 128 280.8 Q F2(open\(my $fh, ">", "output.txt"\))152 298.8 Q (or die "cannot open > output.txt: $!";)176 310.8 Q F0 1.108 (\(The follo)128 328.8 R 1.108(wing is a comprehensi)-.25 F 1.408 -.15 (ve r)-.25 H 1.108(eference to).15 F F1(open\(\))3.609 E F0 3.609(:f)C 1.109(or a gentler introduction you may consider)-3.609 F (perlopentut.\))128 340.8 Q(If)128 358.8 Q F3(FILEHANDLE)5.015 E F0 2.514(is an unde\214ned scalar v)5.014 F 2.514 (ariable \(or array or hash element\), a ne)-.25 F 5.014<778c>-.25 G 2.514(lehandle is)-5.014 F(auto)128 370.8 Q(vi)-.15 E 2.676 (vi\214ed, meaning that the v)-.25 F 2.676 (ariable is assigned a reference to a ne)-.25 F 2.677 (wly allocated anon)-.25 F(ymous)-.15 E 4.727(\214lehandle. Otherwise) 128 382.8 R(if)4.727 E F3(FILEHANDLE)4.727 E F0 2.227(is an e)4.727 F 2.227(xpression, its v)-.15 F 2.226(alue is the real \214lehandle.)-.25 F 2.226(\(This is)7.226 F(considered a symbolic reference, so)128 394.8 Q F2(use strict "refs")2.5 E F0(should)2.5 E F1(not)2.5 E F0(be in ef) 2.5 E(fect.\))-.25 E(If)128 412.8 Q F3(EXPR)4.759 E F0 2.259 (is omitted, the global \(package\) scalar v)4.759 F 2.259 (ariable of the same name as the)-.25 F F3(FILEHANDLE)4.76 E F0 1.737 (contains the \214lename.)128 424.8 R 1.737(\(Note that le)6.737 F 1.737 (xical v)-.15 F -.834(ariables \212 those)-.25 F 1.736(declared with) 4.236 F F2(my)4.236 E F0(or)4.236 E F2(state)4.236 E F0 1.736 (\255\255will not)B -.1(wo)128 436.8 S(rk for this purpose; so if you') .1 E(re using)-.5 E F2(my)2.5 E F0(or)2.5 E F2(state)2.5 E F0 2.5(,s)C (pecify)-2.5 E F3(EXPR)2.5 E F0(in your call to open.\))2.5 E .336 (If three \(or more\) ar)128 454.8 R .336(guments are speci\214ed, the \ open mode \(including optional encoding\) in the second)-.18 F(ar)128 466.8 Q .834(gument are distinct from the \214lename in the third.)-.18 F(If)5.833 E F3(MODE)3.333 E F0(is)3.333 E F2(<)3.333 E F0 .833 (or nothing, the \214le is opened for)3.333 F 6.055(input. If)128 478.8 R F3(MODE)6.055 E F0(is)6.055 E F2(>)6.055 E F0 6.055(,t)C 3.555 (he \214le is opened for output, with e)-6.055 F 3.556 (xisting \214les \214rst being truncated)-.15 F(\(`)128 490.8 Q (`clobbered')-.74 E .679('\) and none)-.74 F .679(xisting \214les ne) -.15 F .679(wly created.)-.25 F(If)5.679 E F3(MODE)3.179 E F0(is)3.179 E F2(>>)3.179 E F0 3.179(,t)C .679(he \214le is opened for appending,) -3.179 F(ag)128 502.8 Q(ain being created if necessary)-.05 E(.)-.65 E -1.1(Yo)128 520.8 S 2.95(uc)1.1 G .45(an put a)-2.95 F F2(+)2.95 E F0 .451(in front of the)2.951 F F2(>)2.951 E F0(or)2.951 E F2(<)2.951 E F0 .451(to indicate that you w)2.951 F .451 (ant both read and write access to the \214le;)-.1 F(thus)128 532.8 Q F2 (+<)3.021 E F0 .521(is almost al)3.021 F -.1(wa)-.1 G .521 (ys preferred for read/write updates).1 F 1.666<8a74>1.666 G(he)-1.666 E F2(+>)3.02 E F0 .52(mode w)3.02 F .52(ould clobber the \214le \214rst.) -.1 F -1.1(Yo)128 544.8 S 4.138(uc)1.1 G 1.638 (ant usually use either read-write mode for updating te)-4.138 F 1.639 (xt\214les, since the)-.15 F 4.139(yh)-.15 G -2.25 -.2(av e)-4.139 H -.25(va)4.339 G(riable-length).25 E 3.611(records. See)128 556.8 R(the) 3.611 E/F4 10/Times-Bold@0 SF3.611 E F0 1.111 (switch in perlrun for a better approach.)3.611 F 1.11 (The \214le is created with permissions of)6.11 F F2(0666)128 568.8 Q F0 (modi\214ed by the process')2.5 E(s)-.55 E F2(umask)2.5 E F0 -.25(va)2.5 G(lue.).25 E(These v)128 586.8 Q(arious pre\214x)-.25 E (es correspond to the)-.15 E F1(fopen)2.5 E F0(\(3\) modes of)1.666 E F2 (r)2.5 E F0(,)A F2(r+)2.5 E F0(,)A F2(w)2.5 E F0(,)A F2(w+)2.5 E F0(,)A F2(a)2.5 E F0 2.5(,a)C(nd)-2.5 E F2(a+)2.5 E F0(.)A .003 (In the one\255 and tw)128 604.8 R(o-ar)-.1 E .003(gument forms of the \ call, the mode and \214lename should be concatenated \(in that)-.18 F .232(order\), preferably separated by white space.)128 616.8 R -1.1(Yo) 5.231 G 2.731(uc)1.1 G -.834(an \212 b)-2.731 F .231(ut shouldn')-.2 F 1.666(t\212o)-.18 G .231(mit the mode in these forms)-1.666 F .011 (when that mode is)128 628.8 R F2(<)2.511 E F0 5.011(.I)C 2.511(ti) -5.011 G 2.511(sa)-2.511 G -.1(lwa)-2.511 G .012(ys safe to use the tw) .1 F(o-ar)-.1 E .012(gument form of)-.18 F F2(open)2.512 E F0 .012 (if the \214lename ar)2.512 F(gument)-.18 E(is a kno)128 640.8 Q (wn literal.)-.25 E -.15(Fo)128 658.8 S 2.639(rt).15 G .139 (hree or more ar)-2.639 F .139(guments if)-.18 F F3(MODE)2.639 E F0(is) 2.639 E F2<7cad>2.639 E F0 2.639(,t)C .138 (he \214lename is interpreted as a command to which output)-2.639 F .102 (is to be piped, and if)128 670.8 R F3(MODE)2.602 E F0(is)2.602 E F2 2.602 E F0 2.602(,t)C .102 (he \214lename is interpreted as a command that pipes output to us.) -2.602 F(In)5.103 E 1.786(the tw)128 682.8 R(o-ar)-.1 E 1.786 (gument \(and one-ar)-.18 F 1.785 (gument\) form, one should replace dash \()-.18 F F2A F0 4.285(\)w)C 1.785(ith the command.)-4.285 F(See)6.785 E -.74(``)128 694.8 S(Using) .74 E F1(open\(\))3.972 E F0(for)3.972 E F3(IPC)3.972 E F0 2.952 -.74 ('' i)D 3.972(np).74 G 1.472(erlipc for more e)-3.972 F 1.472 (xamples of this.)-.15 F(\(Y)6.472 E 1.472(ou are not allo)-1.1 F 1.472 (wed to)-.25 F F2(open)3.972 E F0 1.472(to a)3.972 F 4.344 (command that pipes both in)128 706.8 R F1(and)6.843 E F0 4.343(out, b) 6.843 F 4.343(ut see IPC::Open2, IPC::Open3, and `)-.2 F(`Bidirectional) -.74 E(Communication with Another Process')128 718.8 Q 2.5('i)-.74 G 2.5 (np)-2.5 G(erlipc for alternati)-2.5 E -.15(ve)-.25 G(s.\)).15 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 41)162.62 F 0 Cg EP %%Page: 42 42 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .734 (In the form of pipe opens taking three or more ar)128 84 R .734 (guments, if)-.18 F/F1 9/Times-Roman@0 SF(LIST)3.234 E F0 .734 (is speci\214ed \(e)3.234 F .735(xtra ar)-.15 F .735(guments after)-.18 F .718(the command name\) then)128 96 R F1(LIST)3.217 E F0 .717 (becomes ar)3.217 F .717(guments to the command in)-.18 F -.2(vo)-.4 G -.1(ke).2 G 3.217(di).1 G 3.217(ft)-3.217 G .717(he platform supports) -3.217 F 3.093(it. The)128 108 R .593(meaning of)3.093 F/F2 10/Courier@0 SF(open)3.093 E F0 .593(with more than three ar)3.093 F .594 (guments for non-pipe modes is not yet de\214ned, b)-.18 F(ut)-.2 E -.15 (ex)128 120 S(perimental `).15 E(`layers')-.74 E 2.5('m)-.74 G(ay gi) -2.5 E .3 -.15(ve ex)-.25 H(tra).15 E F1(LIST)2.5 E F0(ar)2.5 E (guments meaning.)-.18 E .625(In the tw)128 138 R(o-ar)-.1 E .625 (gument \(and one-ar)-.18 F .624(gument\) form, opening)-.18 F F2<3cad> 3.124 E F0(or)3.124 E F23.124 E F0(opens)3.124 E F1(STDIN)3.124 E F0 .624(and opening)3.124 F F2<3ead>3.124 E F0(opens)3.124 E F1(STDOUT)128 150 Q F0(.)A -1.1(Yo)128 168 S 3.223(um)1.1 G .723 (ay \(and usually should\) use the three-ar)-3.223 F .724 (gument form of open to specify I/O layers \(sometimes)-.18 F .485 (referred to as `)128 180 R(`disciplines')-.74 E .485 ('\) to apply to the handle that af)-.74 F .485(fect ho)-.25 F 2.985(wt) -.25 G .484(he input and output are processed)-2.985 F (\(see open and PerlIO for more details\). F)128 192 Q(or e)-.15 E (xample:)-.15 E F2(open\(my $fh, "<:encoding\(UTF\2558\)", "filename"\)) 140 210 Q(|| die "can\010t open UTF\2558 encoded filename: $!";)152 222 Q F0 .752(opens the UTF8\255encoded \214le containing Unicode character\ s; see perluniintro. Note that if layers are)128 240 R .473 (speci\214ed in the three-ar)128 252 R .473(gument form, then def)-.18 F .473(ault layers stored in ${^OPEN} \(see perlv)-.1 F .472 (ar; usually set)-.25 F(by the)128 264 Q/F3 10/Times-Bold@0 SF(open)2.5 E F0(pragma or the switch)2.5 E F3(\255CioD)2.5 E F0 2.5(\)a)C (re ignored.)-2.5 E 1.327 (Open returns nonzero on success, the unde\214ned v)128 282 R 1.327 (alue otherwise.)-.25 F 1.327(If the)6.327 F F2(open)3.828 E F0(in)3.828 E -.2(vo)-.4 G(lv).2 E 1.328(ed a pipe, the)-.15 F(return v)128 294 Q (alue happens to be the pid of the subprocess.)-.25 E 1.679(If you')128 312 R 1.678(re running Perl on a system that distinguishes between te) -.5 F 1.678(xt \214les and binary \214les, then you)-.15 F .566 (should check out `)128 324 R(`binmode')-.74 E 3.066('f)-.74 G .566 (or tips for dealing with this.)-3.066 F .566(The k)5.566 F .866 -.15 (ey d)-.1 H .566(istinction between systems that).15 F(need)128 336 Q F2 (binmode)2.735 E F0 .235(and those that don')2.735 F 2.735(ti)-.18 G 2.735(st)-2.735 G .235(heir te)-2.735 F .235(xt \214le formats.)-.15 F .235(Systems lik)5.235 F 2.735(eU)-.1 G .235(nix, Mac)-2.735 F F1(OS) 2.735 E F0 2.735(,a)C .234(nd Plan 9,)-2.735 F .477(that end lines with\ a single character and encode that character in C as)128 348 R F2 ("\\n")2.977 E F0 .477(do not need)2.977 F F2(binmode)2.977 E F0(.)A (The rest need it.)128 360 Q .762(When opening a \214le, it')128 378 R 3.261(ss)-.55 G .761(eldom a good idea to continue if the request f) -3.261 F .761(ailed, so)-.1 F F2(open)3.261 E F0 .761(is frequently) 3.261 F .021(used with)128 390 R F2(die)2.521 E F0 5.021(.E)C -.15(ve) -5.021 G 2.521(ni).15 G(f)-2.521 E F2(die)2.521 E F0 -.1(wo)2.521 G(n') .1 E 2.521(td)-.18 G 2.521(ow)-2.521 G .021(hat you w)-2.521 F .022 (ant \(say)-.1 F 2.522(,i)-.65 G 2.522(na)-2.522 G F1(CGI)A F0 .022 (script, where you w)2.522 F .022(ant to format a)-.1 F 1.74 (suitable error message \(b)128 402 R 1.74 (ut there are modules that can help with that problem\)\) al)-.2 F -.1 (wa)-.1 G 1.74(ys check the).1 F(return v)128 414 Q (alue from opening a \214le.)-.25 E 2.07(As a special case the three-ar) 128 432 R 2.071(gument form with a read/write mode and the third ar)-.18 F 2.071(gument being)-.18 F F2(undef)128 444 Q F0(:)A F2 (open\(my $tmp, "+>", undef\) or die ...)152 462 Q F0 .123 (opens a \214lehandle to an anon)128 480 R .123(ymous temporary \214le.) -.15 F .123(Also using)5.123 F F2(+<)2.623 E F0 -.1(wo)2.623 G .123 (rks for symmetry).1 F 2.623(,b)-.65 G .123(ut you really)-2.823 F 2.14 (should consider writing something to the temporary \214le \214rst.)128 492 R -1.1(Yo)7.14 G 4.64(uw)1.1 G 2.14(ill need to)-4.64 F/F4 10 /Times-Italic@0 SF(seek\(\))4.64 E F0 2.14(to do the)4.64 F(reading.)128 504 Q .147(Since v5.8.0, Perl has b)128 522 R .147 (uilt using PerlIO by def)-.2 F 2.647(ault. Unless)-.1 F(you')2.647 E .447 -.15(ve c)-.5 H .147(hanged this \(such as b).15 F .146 (uilding Perl)-.2 F(with)128 534 Q F2(Configure \255Uuseperlio)2.5 E F0 (\), you can open \214lehandles directly to Perl scalars via:)A F2 (open\($fh, ">", \\$variable\) || ..)152 552 Q F0 1.6 -.8(To \()128 570 T(re\)open).8 E F2(STDOUT)2.5 E F0(or)2.5 E F2(STDERR)2.5 E F0 (as an in-memory \214le, close it \214rst:)2.5 E F2(close STDOUT;)152 588 Q(open\(STDOUT, ">", \\$variable\))152 600 Q (or die "Can\010t open STDOUT: $!";)176 612 Q F0(General e)128 630 Q (xamples:)-.15 E F2($ARTICLE = 100;)152 648 Q (open\(ARTICLE\) or die "Can\010t find article $ARTICLE: $!\\n";)152 660 Q(while \(
\) {...)152 672 Q (open\(LOG, ">>/usr/spool/news/twitlog"\);)152 696 Q 6(#\()12 G (log is reserved\))-6 E 6(#i)152 708 S 6(ft)-6 G (he open fails, output is discarded)-6 E F0(perl v5.14.2)72 768 Q 198.17 (2011-10-01 42)162.62 F 0 Cg EP %%Page: 43 43 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (open\(my $dbase, "+<", "dbase.mine"\))152 84 Q 6(#o)36 G (pen for update)-6 E (or die "Can\010t open \010dbase.mine\010 for update: $!";)176 96 Q (open\(my $dbase, "+Tmp$$"\))152 228 Q 6(#$)72 G 6($i)-6 G 6(so)-6 G (ur process id)-6 E(or die "Can\010t start sort: $!";)176 240 Q 6(#i)152 264 S(n\255memory files)-6 E(open\(MEMORY, ">", \\$var\))152 276 Q (or die "Can\010t open memory file: $!";)176 288 Q (print MEMORY "foo!\\n";)152 300 Q 6(#o)114 G(utput will appear in $var) -6 E 6(#p)152 324 S (rocess argument list of files along with any includes)-6 E (foreach $file \(@ARGV\) {)152 348 Q(process\($file, "fh00"\);)176 360 Q (})152 372 Q(sub process {)152 396 Q(my\($filename, $input\) = @_;)176 408 Q 18($input++; #)176 420 R(this is a string increment)6 E (unless \(open\($input, "<", $filename\)\) {)176 432 Q (print STDERR "Can\010t open $filename: $!\\n";)200 444 Q(return;)200 456 Q(})176 468 Q(local $_;)176 492 Q(while \(<$input>\) {)176 504 Q 6 (#n)24 G(ote use of indirection)-6 E(if \(/^#include "\(.*\)"/\) {)200 516 Q(process\($1, $input\);)224 528 Q(next;)224 540 Q(})200 552 Q 54 (#... #)200 564 R(whatever)6 E(})176 576 Q(})152 588 Q F0 (See perliol for detailed info on PerlIO.)128 606 Q -1.1(Yo)128 624 S 2.543(um)1.1 G .043(ay also, in the Bourne shell tradition, specify an) -2.543 F/F2 9/Times-Roman@0 SF(EXPR)2.544 E F0(be)2.544 E .044 (ginning with)-.15 F F1(>&)2.544 E F0 2.544(,i)C 2.544(nw)-2.544 G .044 (hich case the rest)-2.544 F .774(of the string is interpreted as the n\ ame of a \214lehandle \(or \214le descriptor)128 636 R 3.273(,i)-.4 G 3.273(fn)-3.273 G .773(umeric\) to be duped \(as)-3.273 F F1(dup\(2\)) 128 648 Q F0 4.098(\)a)C 1.598(nd opened.)-4.098 F -1.1(Yo)6.598 G 4.098 (um)1.1 G 1.598(ay use)-4.098 F F1(&)4.098 E F0(after)4.098 E F1(>)4.098 E F0(,)A F1(>>)4.098 E F0(,)A F1(<)4.098 E F0(,)A F1(+>)4.098 E F0(,)A F1(+>>)4.098 E F0 4.099(,a)C(nd)-4.099 E F1(+<)4.099 E F0 6.599(.T)C 1.599(he mode you specify)-6.599 F .283 (should match the mode of the original \214lehandle.)128 660 R .282 (\(Duping a \214lehandle does not tak)5.283 F 2.782(ei)-.1 G .282 (nto account an)-2.782 F(y)-.15 E -.15(ex)128 672 S 2.189 (isting contents of).15 F F2(IO)4.689 E F0 -.2(bu)4.689 G -.25(ff).2 G 2.19(ers.\) If you use the three-ar).25 F 2.19 (gument form, then you can pass either a)-.18 F(number)128 684 Q 2.5(,t) -.4 G(he name of a \214lehandle, or the normal `)-2.5 E (`reference to a glob')-.74 E('.)-.74 E(Here is a script that sa)128 702 Q -.15(ve)-.2 G(s, redirects, and restores).15 E F1(STDOUT)2.5 E F0(and) 2.5 E F1(STDERR)2.5 E F0(using v)2.5 E(arious methods:)-.25 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 43)162.62 F 0 Cg EP %%Page: 44 44 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (#!/usr/bin/perl)152 84 Q(open\(my $oldout, ">&STDOUT"\))152 96 Q (or die "Can\010t dup STDOUT: $!";)30 E 24(open\(OLDERR, ">&",)152 108 R (\\*STDERR\) or die "Can\010t dup STDERR: $!";)6 E(open\(STDOUT, \010>\ \010, "foo.out"\) or die "Can\010t redirect STDOUT: $!";)152 132 Q (open\(STDERR, ">&STDOUT"\))152 144 Q(or die "Can\010t dup STDOUT: $!";) 30 E(select STDERR; $| = 1;)152 168 Q 6(#m)12 G(ake unbuffered)-6 E (select STDOUT; $| = 1;)152 180 Q 6(#m)12 G(ake unbuffered)-6 E (print STDOUT "stdout 1\\n";)152 204 Q 6(#t)12 G(his works for)-6 E (print STDERR "stderr 1\\n";)152 216 Q 6(#s)12 G(ubprocesses too)-6 E (open\(STDOUT, ">&", $oldout\) or die "Can\010t dup \\$oldout: $!";)152 240 Q(open\(STDERR, ">&OLDERR"\))152 252 Q (or die "Can\010t dup OLDERR: $!";)24 E(print STDOUT "stdout 2\\n";)152 276 Q(print STDERR "stderr 2\\n";)152 288 Q F0 1.67(If you specify)128 306 R F1(\010<&=X\010)4.17 E F0 4.17(,w)C(here)-4.17 E F1(X)4.17 E F0 1.67 (is a \214le descriptor number or a \214lehandle, then Perl will do an) 4.17 F(equi)128 318 Q -.25(va)-.25 G .38(lent of C').25 F(s)-.55 E F1 (fdopen)2.88 E F0 .38(of that \214le descriptor \(and not call)2.88 F F1 (dup\(2\))2.88 E F0 .38(\); this is more parsimonious of)B (\214le descriptors.)128 330 Q -.15(Fo)5 G 2.5(re).15 G(xample:)-2.65 E F1 6(#o)152 348 S(pen for input, reusing the fileno of $fd)-6 E (open\(FILEHANDLE, "<&=$fd"\))152 360 Q F0(or)128 378 Q F1 (open\(FILEHANDLE, "<&=", $fd\))152 396 Q F0(or)128 414 Q F1 6(#o)152 432 S(pen for append, using the fileno of OLDFH)-6 E (open\(FH, ">>&=", OLDFH\))152 444 Q F0(or)128 462 Q F1 (open\(FH, ">>&=OLDFH"\))152 480 Q F0 2.034(Being parsimonious on \214l\ ehandles is also useful \(besides being parsimonious\) for e)128 498 R 2.034(xample when)-.15 F 1.832 (something is dependent on \214le descriptors, lik)128 510 R 4.333(ef) -.1 G 1.833(or e)-4.333 F 1.833(xample locking using)-.15 F/F2 10 /Times-Italic@0 SF(\215oc)4.333 E(k\(\))-.2 E F0 6.833(.I)C 4.333(fy) -6.833 G 1.833(ou do just)-4.333 F F1 1.679(open\(A, ">>&B"\))128 522 R F0 4.179(,t)C 1.679(he \214lehandle A will not ha)-4.179 F 1.979 -.15 (ve t)-.2 H 1.678(he same \214le descriptor as B, and therefore).15 F .362(\215ock\(A\) will not \215ock\(B\) nor vice v)128 534 R 2.862 (ersa. But)-.15 F(with)2.862 E F1 .362(open\(A, ">>&=B"\))2.862 F F0 2.862(,t)C .363(he \214lehandles will share)-2.862 F (the same underlying system \214le descriptor)128 546 Q(.)-.55 E .388(N\ ote that under Perls older than 5.8.0, Perl uses the standard C library\ ')128 564 R(s')-.55 E F2(fdopen\(\))2.888 E F0 .388(to implement the) 2.888 F F1(=)2.888 E F0(functionality)128 576 Q 6.776(.O)-.65 G 4.276 (nm)-6.776 G(an)-4.276 E 4.276(yU)-.15 G 1.776(nix systems,)-4.276 F F2 (fdopen\(\))4.276 E F0 -.1(fa)4.276 G 1.776 (ils when \214le descriptors e).1 F 1.777(xceed a certain v)-.15 F (alue,)-.25 E(typically 255.)128 588 Q -.15(Fo)5 G 2.5(rP).15 G (erls 5.8.0 and later)-2.5 E 2.5(,P)-.4 G (erlIO is \(most often\) the def)-2.5 E(ault.)-.1 E -1.1(Yo)128 606 S 4.416(uc)1.1 G 1.916(an see whether your Perl w)-4.416 F 1.915(as b)-.1 F 1.915(uilt with PerlIO by running)-.2 F F1 1.915(perl \255V)4.415 F F0 1.915(and looking for the)4.415 F F1(useperlio=)128 618 Q F0 2.5 (line. If)2.5 F F1(useperlio)2.5 E F0(is)2.5 E F1(define)2.5 E F0 2.5 (,y)C(ou ha)-2.5 E .3 -.15(ve P)-.2 H(erlIO; otherwise you don').15 E (t.)-.18 E .293(If you open a pipe on the command)128 636 R F12.793 E F0 .294(\(that is, specify either)2.793 F F1<7cad>2.794 E F0(or)2.794 E F12.794 E F0 .294(with the one\255 or tw)2.794 F(o-ar)-.1 E (gument)-.18 E .373(forms of)128 648 R F1(open)2.873 E F0 .373 (\), an implicit)B F1(fork)2.873 E F0 .373(is done, so)2.873 F F1(open) 2.873 E F0 .373(returns twice: in the parent process it returns the) 2.873 F .735(pid of the child process, and in the child process it retu\ rns \(a de\214ned\))128 660 R F1(0)3.236 E F0 5.736(.U)C(se)-5.736 E F1 (defined\($pid\))3.236 E F0(or)3.236 E F1(//)128 672 Q F0 (to determine whether the open w)2.5 E(as successful.)-.1 E -.15(Fo)128 690 S 2.5(re).15 G(xample, use either)-2.65 E F1 ($child_pid = open\(FROM_KID, "|\255"\))152 708 Q (// die "can\010t fork: $!";)18 E F0(or)128 726 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 44)162.62 F 0 Cg EP %%Page: 45 45 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($child_pid)138 84 Q F0 2.5(=o)2.5 G(pen\()-2.5 E/F2 9/Times-Roman@0 SF -.162(TO)C(_KID).162 E F0 7.5(,`)C(`|\255')-8.24 E 8.952('\) //)-.74 F (die `)2.5 E(`can')-.74 E 2.5(tf)-.18 G(ork: $!')-2.5 E(';)-.74 E(follo) 128 102 Q(wed by)-.25 E F1(if \($child_pid\) {)152 120 Q 6(#a)176 132 S 6(mt)-6 G(he parent:)-6 E 6(#e)176 144 S (ither write TO_KID or else read FROM_KID)-6 E(...)176 156 Q (wait $child_pid;)176 168 Q 6(}e)152 180 S(lse {)-6 E 6(#a)176 192 S 6 (mt)-6 G(he child; use STDIN/STDOUT normally)-6 E(...)176 204 Q(exit;) 176 216 Q(})152 228 Q F0 2.729(The \214lehandle beha)128 246 R -.15(ve) -.2 G 5.229(sn).15 G 2.729(ormally for the parent, b)-5.229 F 2.728 (ut I/O to that \214lehandle is piped from/to the)-.2 F F2(STDOUT/STDIN) 128 258 Q F0 .681(of the child process.)3.181 F .681 (In the child process, the \214lehandle isn')5.681 F 3.181(to)-.18 G -.834(pened \212 I/O)-3.181 F(happens)3.182 E .376(from/to the ne)128 270 R(w)-.25 E F2(STDOUT/STDIN)2.876 E F0 5.376(.T)C .376 (ypically this is used lik)-6.176 F 2.875(et)-.1 G .375 (he normal piped open when you w)-2.875 F .375(ant to)-.1 F -.15(exe)128 282 S .08(rcise more control o).15 F -.15(ve)-.15 G 2.58(rj).15 G .08 (ust ho)-2.58 F 2.58(wt)-.25 G .08(he pipe command gets e)-2.58 F -.15 (xe)-.15 G .08(cuted, such as when running setuid and).15 F(you don')128 294 Q 2.5(tw)-.18 G(ant to ha)-2.6 E .3 -.15(ve t)-.2 H 2.5(os).15 G (can shell commands for metacharacters.)-2.5 E(The follo)128 312 Q (wing blocks are more or less equi)-.25 E -.25(va)-.25 G(lent:).25 E F1 (open\(FOO, "|tr \010[a\255z]\010 \010[A\255Z]\010"\);)152 330 Q (open\(FOO, "|\255", "tr \010[a\255z]\010 \010[A\255Z]\010"\);)152 342 Q (open\(FOO, "|\255"\) || exec \010tr\010, \010[a\255z]\010, \010[A\255Z\ ]\010;)152 354 Q (open\(FOO, "|\255", "tr", \010[a\255z]\010, \010[A\255Z]\010\);)152 366 Q(open\(FOO, "cat \255n \010$file\010|"\);)152 390 Q (open\(FOO, "\255|", "cat \255n \010$file\010"\);)152 402 Q (open\(FOO, "\255|"\) || exec "cat", "\255n", $file;)152 414 Q (open\(FOO, "\255|", "cat", "\255n", $file\);)152 426 Q F0 .739 (The last tw)128 444 R 3.239(oe)-.1 G .739(xamples in each block sho) -3.389 F 3.239(wt)-.25 G .738(he pipe as `)-3.239 F .738(`list form') -.74 F .738(', which is not yet supported on all)-.74 F 3.145 (platforms. A)128 456 R .645 (good rule of thumb is that if your platform has a real)3.145 F F1 (fork\(\))3.145 E F0 .646(\(in other w)3.146 F .646(ords, if your)-.1 F .617(platform is Unix, including Linux and MacOS X\), you can use the l\ ist form.)128 468 R -1.1(Yo)5.617 G 3.117(uw)1.1 G .617(ould w)-3.217 F .617(ant to use)-.1 F .979 (the list form of the pipe so you can pass literal ar)128 480 R .979 (guments to the command without risk of the shell)-.18 F 1.682 (interpreting an)128 492 R 4.182(ys)-.15 G 1.682 (hell metacharacters in them.)-4.182 F(Ho)6.682 E(we)-.25 E -.15(ve)-.25 G 2.481 -.4(r, t).15 H 1.681(his also bars you from opening pipes to).4 F(commands that intentionally contain shell metacharacters, such as:)128 504 Q F1(open\(FOO, "|cat \255n | expand \2554 | lpr"\))152 522 Q (// die "Can\010t open pipeline to lpr: $!";)176 534 Q F0(See `)128 552 Q(`Safe Pipe Opens')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlipc for more e)-2.5 E(xamples of this.)-.15 E(Be)128 570 Q .683(gin\ ning with v5.6.0, Perl will attempt to \215ush all \214les opened for o\ utput before an)-.15 F 3.184(yo)-.15 G .684(peration that)-3.184 F .615 (may do a fork, b)128 582 R .614 (ut this may not be supported on some platforms \(see perlport\).)-.2 F 2.214 -.8(To b)5.614 H 3.114(es).8 G .614(afe, you may)-3.114 F .657 (need to set)128 594 R F1($|)3.157 E F0(\($A)3.157 E(UT)-.55 E .657 (OFLUSH in English\) or call the)-.18 F F1(autoflush\(\))3.157 E F0 .657 (method of)3.157 F F1(IO::Handle)3.158 E F0(on)3.158 E(an)128 606 Q 2.5 (yo)-.15 G(pen handles.)-2.5 E 1.179 (On systems that support a close-on-e)128 624 R -.15(xe)-.15 G 3.679 <638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.679 F 1.178(wly opened \214le)-.25 F (descriptor as determined by the v)128 636 Q(alue of)-.25 E F1($^F)2.5 E F0 5(.S)C(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E (ar)-.25 E(.)-.55 E .625(Closing an)128 654 R 3.125(yp)-.15 G .625 (iped \214lehandle causes the parent process to w)-3.125 F .626 (ait for the child to \214nish, then returns the)-.1 F(status v)128 666 Q(alue in)-.25 E F1($?)2.5 E F0(and)2.5 E F1(${^CHILD_ERROR_NATIVE})2.5 E F0(.)A 1.526(The \214lename passed to the one\255 and tw)128 684 R (o-ar)-.1 E 1.526(gument forms of)-.18 F/F3 10/Times-Italic@0 SF (open\(\))4.026 E F0 1.526(will ha)4.026 F 1.826 -.15(ve l)-.2 H 1.526 (eading and trailing).15 F 2.512 (whitespace deleted and normal redirection characters honored.)128 696 R 2.512(This property)7.512 F 5.012(,k)-.65 G(no)-5.012 E 2.512(wn as `) -.25 F(`magic)-.74 E(open')128 708 Q .883 (', can often be used to good ef)-.74 F 3.383(fect. A)-.25 F .883 (user could specify a \214lename of)3.383 F F3 -1.11(``)3.383 G -.1(rs) 1.11 G 3.383(hc).1 G .883(at \214le |')-3.383 F(')-1.11 E F0 3.383(,o)C 3.383(ry)-3.383 G(ou)-3.383 E (could change certain \214lenames as needed:)128 720 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 45)162.62 F 0 Cg EP %%Page: 46 46 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($filename =~ s/\(.*\\.gz\)\\s*$/gzip \255dc < $1|/;)152 84 Q (open\(FH, $filename\) or die "Can\010t open $filename: $!";)152 96 Q F0 (Use the three-ar)128 114 Q (gument form to open a \214le with arbitrary weird characters in it,) -.18 E F1(open\(FOO, "<", $file\))152 132 Q (|| die "can\010t open < $file: $!";)176 144 Q F0(otherwise it')128 162 Q 2.5(sn)-.55 G(ecessary to protect an)-2.5 E 2.5(yl)-.15 G (eading and trailing whitespace:)-2.5 E F1($file =~ s#^\(\\s\)#./$1#;) 152 180 Q(open\(FOO, "< $file\\0"\))152 192 Q(|| die "open failed: $!";) 176 204 Q F0 1.597(\(this may not w)128 222 R 1.597 (ork on some bizarre \214lesystems\).)-.1 F 1.597 (One should conscientiously choose between the)6.597 F/F2 10 /Times-Italic@0 SF(ma)128 234 Q(gic)-.1 E F0(and)2.5 E F2(thr)2.5 E (ee-ar)-.37 E(gument)-.37 E F0(form of)2.5 E F2(open\(\))2.5 E F0(:)A F1 (open\(IN, $ARGV[0]\) || die "can\010t open $ARGV[0]: $!";)152 252 Q F0 .255(will allo)128 270 R 2.755(wt)-.25 G .255(he user to specify an ar) -2.755 F .255(gument of the form)-.18 F F1 .255("rsh cat file |")2.755 F F0 2.755(,b)C .255(ut will not w)-2.955 F .255(ork on a)-.1 F (\214lename that happens to ha)128 282 Q .3 -.15(ve a t)-.2 H (railing space, while).15 E F1(open\(IN, "<", $ARGV[0]\))152 300 Q (|| die "can\010t open < $ARGV[0]: $!";)176 312 Q F0(will ha)128 330 Q .3 -.15(ve ex)-.2 H(actly the opposite restrictions.).15 E 1.181 (If you w)128 348 R 1.181(ant a `)-.1 F(`real')-.74 E 3.681('C)-.74 G F1 (open)A F0(\(see)3.681 E F1(open\(2\))3.681 E F0 1.181 (on your system\), then you should use the)3.681 F F1(sysopen)3.682 E F0 1.78(function, which in)128 360 R -.2(vo)-.4 G(lv).2 E 1.78 (es no such magic \(b)-.15 F 1.779(ut may use subtly dif)-.2 F 1.779 (ferent \214lemodes than Perl)-.25 F F2(open\(\))4.279 E F0(,)A .143 (which is mapped to C)128 372 R F2(fopen\(\))2.644 E F0 2.644(\). This)B .144(is another w)2.644 F .144 (ay to protect your \214lenames from interpretation.)-.1 F -.15(Fo)5.144 G(r).15 E -.15(ex)128 384 S(ample:).15 E F1(use IO::Handle;)152 402 Q (sysopen\(HANDLE, $path, O_RDWR|O_CREAT|O_EXCL\))152 414 Q (or die "sysopen $path: $!";)176 426 Q ($oldfh = select\(HANDLE\); $| = 1; select\($oldfh\);)152 438 Q (print HANDLE "stuff $$\\n";)152 450 Q(seek\(HANDLE, 0, 0\);)152 462 Q (print "File contains: ", ;)152 474 Q F0 .628 (Using the constructor from the)128 492 R F1(IO::Handle)3.127 E F0 .627 (package \(or one of its subclasses, such as)3.127 F F1(IO::File)3.127 E F0(or)128 504 Q F1(IO::Socket)3.039 E F0 .539(\), you can generate anon) B .539(ymous \214lehandles that ha)-.15 F .839 -.15(ve t)-.2 H .54 (he scope of the v).15 F .54(ariables used)-.25 F .123 (to hold them, then automatically \(b)128 516 R .123 (ut silently\) close once their reference counts become zero, typically) -.2 F(at scope e)128 528 Q(xit:)-.15 E F1(use IO::File;)152 546 Q(#...) 152 558 Q(sub read_myfile_munged {)152 570 Q(my $ALL = shift;)176 582 Q 6(#o)176 594 S 6(rj)-6 G(ust leave it undef to autoviv)-6 E (my $handle = IO::File\255>new;)176 606 Q (open\($handle, "<", "myfile"\) or die "myfile: $!";)176 618 Q ($first = <$handle>)176 630 Q(or return \(\);)200 642 Q 6(#A)30 G (utomatically closed here.)-6 E(mung\($first\) or die "mung failed";)176 654 Q 6(#O)12 G 6(rh)-6 G(ere.)-6 E (return \(first, <$handle>\) if $ALL;)176 666 Q 6(#O)12 G 6(rh)-6 G (ere.)-6 E(return $first;)176 678 Q 6(#O)132 G 6(rh)-6 G(ere.)-6 E(})152 690 Q/F3 9/Times-Bold@0 SF -1.08(WA)128 708 S(RNING:)1.08 E F0 2.002 (The pre)4.502 F 2.002(vious e)-.25 F 2.003(xample has a b)-.15 F 2.003 (ug because the automatic close that happens when the)-.2 F 1.037 (refcount on)128 720 R F1(handle)3.537 E F0 1.037 (does not properly detect and report f)3.537 F(ailures.)-.1 E F2(Always) 6.036 E F0 1.036(close the handle yourself)3.536 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 46)162.62 F 0 Cg EP %%Page: 47 47 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (and inspect the return v)128 84 Q(alue.)-.25 E/F1 10/Courier@0 SF (close\($handle\))152 102 Q(|| warn "close failed: $!";)176 114 Q F0 (See `)128 132 Q(`seek')-.74 E 2.5('f)-.74 G (or some details about mixing reading and writing.)-2.5 E(opendir)108 148.8 Q/F2 9/Times-Roman@0 SF(DIRHANDLE)2.5 E F0(,EXPR)A 1.301 (Opens a directory named)128 160.8 R F2(EXPR)3.801 E F0 1.301 (for processing by)3.801 F F1(readdir)3.802 E F0(,)A F1(telldir)3.802 E F0(,)A F1(seekdir)3.802 E F0(,)A F1(rewinddir)3.802 E F0(,)A(and)128 172.8 Q F1(closedir)3.158 E F0 5.658(.R)C .658 (eturns true if successful.)-5.658 F F2(DIRHANDLE)5.657 E F0 .657 (may be an e)3.157 F .657(xpression whose v)-.15 F .657(alue can be)-.25 F .602(used as an indirect dirhandle, usually the real dirhandle name.) 128 184.8 R(If)5.602 E F2(DIRHANDLE)3.102 E F0 .603 (is an unde\214ned scalar)3.102 F -.25(va)128 196.8 S .102 (riable \(or array or hash element\), the v).25 F .102 (ariable is assigned a reference to a ne)-.25 F 2.601(wa)-.25 G(non) -2.601 E .101(ymous dirhandle;)-.15 F(that is, it')128 208.8 Q 2.5(sa) -.55 G(uto)-2.5 E(vi)-.15 E 2.5(vi\214ed. DIRHANDLEs)-.25 F(ha)2.5 E .3 -.15(ve t)-.2 H(heir o).15 E(wn namespace separate from FILEHANDLEs.) -.25 E(See the e)128 226.8 Q(xample at)-.15 E F1(readdir)2.5 E F0(.)A (ord)108 243.6 Q F2(EXPR)2.5 E F0(ord)108 255.6 Q .666 (Returns the numeric \(the nati)128 255.6 R .966 -.15(ve 8)-.25 H .666 (\255bit encoding, lik).15 F(e)-.1 E F2(ASCII)3.166 E F0(or)3.166 E F2 (EBCDIC)3.166 E F0 3.166(,o)C 3.166(rU)-3.166 G .666(nicode\) v)-3.166 F .667(alue of the \214rst)-.25 F 2.137(character of)128 267.6 R F2(EXPR) 4.637 E F0 7.137(.I)C(f)-7.137 E F2(EXPR)4.637 E F0 2.136 (is an empty string, returns 0.)4.637 F(If)7.136 E F2(EXPR)4.636 E F0 2.136(is omitted, uses)4.636 F F1($_)4.636 E F0 7.136(.\()C(Note)-7.136 E/F3 10/Times-Italic@0 SF -.15(ch)128 279.6 S(ar).15 E(acter)-.15 E F0 2.5(,n)C(ot byte.\))-2.5 E -.15(Fo)128 297.6 S 2.5(rt).15 G(he re)-2.5 E -.15(ve)-.25 G(rse, see `).15 E(`chr')-.74 E 2.5('. See)-.74 F (perlunicode for more about Unicode.)2.5 E(our)108 314.4 Q F2(EXPR)2.5 E F0(our)108 326.4 Q F2 .25(TYPE EXPR)2.5 F F0(our)108 338.4 Q F2(EXPR)2.5 E F0(:)2.5 E F2 -.999(AT)2.5 G(TRS).999 E F0(our)108 350.4 Q F2 .25 (TYPE EXPR)2.5 F F0(:)2.5 E F2 -.999(AT)2.5 G(TRS).999 E F1(our)128 362.4 Q F0 1.903(associates a simple name with a package v)4.403 F 1.903 (ariable in the current package for use within the)-.25 F .209 (current scope.)128 374.4 R(When)5.209 E F1 .209 (use strict \010vars\010)2.709 F F0 .209(is in ef)2.709 F(fect,)-.25 E F1(our)2.709 E F0 .208(lets you use declared global v)2.709 F(ariables) -.25 E .428(without qualifying them with package names, within the le) 128 386.4 R .428(xical scope of the)-.15 F F1(our)2.928 E F0 2.928 (declaration. In)2.928 F(this)2.928 E -.1(wa)128 398.4 S(y).1 E F1(our) 2.5 E F0(dif)2.5 E(fers from)-.25 E F1(use vars)2.5 E F0 2.5(,w)C (hich is package-scoped.)-2.5 E(Unlik)128 416.4 Q(e)-.1 E F1(my)3.482 E F0(or)3.482 E F1(state)3.482 E F0 3.482(,w)C .981 (hich allocates storage for a v)-3.482 F .981 (ariable and associates a simple name with that)-.25 F .585 (storage for use within the current scope,)128 428.4 R F1(our)3.086 E F0 .586(associates a simple name with a package \(read: global\))3.086 F -.25(va)128 440.4 S .548 (riable in the current package, for use within the current le).25 F .548 (xical scope.)-.15 F .548(In other w)5.548 F(ords,)-.1 E F1(our)3.048 E F0 .548(has the)3.048 F(same scoping rules as)128 452.4 Q F1(my)2.5 E F0 (or)2.5 E F1(state)2.5 E F0 2.5(,b)C(ut does not necessarily create a v) -2.7 E(ariable.)-.25 E(If more than one v)128 470.4 Q (alue is listed, the list must be placed in parentheses.)-.25 E F1 (our $foo;)152 488.4 Q(our\($bar, $baz\);)152 500.4 Q F0(An)128 518.4 Q F1(our)3.065 E F0 .565(declaration declares a global v)3.065 F .566 (ariable that will be visible across its entire le)-.25 F .566 (xical scope, e)-.15 F -.15(ve)-.25 G(n).15 E .286 (across package boundaries.)128 530.4 R .286(The package in which the v) 5.286 F .285(ariable is entered is determined at the point of)-.25 F (the declaration, not at the point of use.)128 542.4 Q (This means the follo)5 E(wing beha)-.25 E(vior holds:)-.2 E F1 (package Foo;)152 560.4 Q(our $bar;)152 572.4 Q 6(#d)36 G (eclares $Foo::bar for rest of lexical scope)-6 E($bar = 20;)152 584.4 Q (package Bar;)152 608.4 Q(print $bar;)152 620.4 Q 6(#p)24 G (rints 20, as it refers to $Foo::bar)-6 E F0(Multiple)128 638.4 Q F1 (our)3.67 E F0 1.17(declarations with the same name in the same le)3.67 F 1.171(xical scope are allo)-.15 F 1.171(wed if the)-.25 F 3.671(ya) -.15 G 1.171(re in)-3.671 F(dif)128 650.4 Q 1.317(ferent packages.)-.25 F 1.317(If the)6.317 F 3.817(yh)-.15 G 1.316 (appen to be in the same package, Perl will emit w)-3.817 F 1.316 (arnings if you ha)-.1 F -.15(ve)-.2 G(ask)128 662.4 Q .908 (ed for them, just lik)-.1 F 3.408(em)-.1 G(ultiple)-3.408 E F1(my)3.408 E F0 3.408(declarations. Unlik)3.408 F 3.408(eas)-.1 G(econd)-3.408 E F1 (my)3.408 E F0 .908(declaration, which will bind)3.408 F 1.306 (the name to a fresh v)128 674.4 R 1.306(ariable, a second)-.25 F F1 (our)3.806 E F0 1.306 (declaration in the same package, in the same scope, is)3.806 F (merely redundant.)128 686.4 Q(perl v5.14.2)72 768 Q 198.17 (2011-10-01 47)162.62 F 0 Cg EP %%Page: 48 48 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use warnings;)152 84 Q(package Foo;)152 96 Q(our $bar;)152 108 Q 6(#d) 36 G(eclares $Foo::bar for rest of lexical scope)-6 E($bar = 20;)152 120 Q(package Bar;)152 144 Q (our $bar = 30; # declares $Bar::bar for rest of lexical scope)152 156 Q (print $bar;)152 168 Q 6(#p)24 G(rints 30)-6 E(our $bar;)152 192 Q 6(#e) 36 G(mits warning but has no other effect)-6 E(print $bar;)152 204 Q 6 (#s)24 G(till prints 30)-6 E F0(An)128 222 Q F1(our)2.5 E F0 (declaration may also ha)2.5 E .3 -.15(ve a l)-.2 H(ist of attrib).15 E (utes associated with it.)-.2 E .571(The e)128 240 R .571 (xact semantics and interf)-.15 F .571(ace of)-.1 F/F2 9/Times-Roman@0 SF(TYPE)3.071 E F0(and)3.072 E F2 -.999(AT)3.072 G(TRS).999 E F0 .572 (are still e)3.072 F -.2(vo)-.25 G(lving.).2 E F2(TYPE)5.572 E F0 .572 (is currently bound to)3.072 F 1.043(the use of)128 252 R F1(fields) 3.542 E F0 1.042(pragma, and attrib)3.542 F 1.042 (utes are handled using the)-.2 F F1(attributes)3.542 E F0 1.042 (pragma, or starting)3.542 F .366(from Perl 5.8.0 also via the)128 264 R F1(Attribute::Handlers)2.866 E F0 2.866(module. See)2.866 F -.74(``) 2.866 G(Pri).74 E -.25(va)-.25 G .366(te V).25 F .366(ariables via)-1.11 F/F3 10/Times-Italic@0 SF(my\(\))2.867 E F0 1.847 -.74('' i)D(n).74 E (perlsub for details, and \214elds, attrib)128 276 Q(utes, and Attrib) -.2 E(ute::Handlers.)-.2 E(pack)108 292.8 Q F2(TEMPLA)2.5 E(TE)-.999 E F0(,LIST)A -.8(Ta)128 304.8 S -.1(ke).8 G 3.996(sa).1 G F2(LIST)A F0 1.496(of v)3.996 F 1.496(alues and con)-.25 F -.15(ve)-.4 G 1.496 (rts it into a string using the rules gi).15 F -.15(ve)-.25 G 3.995(nb) .15 G 3.995(yt)-3.995 G(he)-3.995 E F2(TEMPLA)3.995 E(TE)-.999 E F0 6.495(.T)C(he)-6.495 E .035 (resulting string is the concatenation of the con)128 316.8 R -.15(ve) -.4 G .036(rted v).15 F 2.536(alues. T)-.25 F(ypically)-.8 E 2.536(,e) -.65 G .036(ach con)-2.536 F -.15(ve)-.4 G .036(rted v).15 F .036 (alue looks lik)-.25 F(e)-.1 E .105(its machine-le)128 328.8 R -.15(ve) -.25 G 2.605(lr).15 G 2.605(epresentation. F)-2.605 F .105(or e)-.15 F .104(xample, on 32\255bit machines an inte)-.15 F .104 (ger may be represented by a)-.15 F(sequence of 4 bytes, which)128 340.8 Q(will in Perl be presented as a string that')5 E 2.5(s4c)-.55 G (haracters long.)-2.5 E (See perlpacktut for an introduction to this function.)128 358.8 Q(The) 128 376.8 Q F2(TEMPLA)2.5 E(TE)-.999 E F0 (is a sequence of characters that gi)2.5 E .3 -.15(ve t)-.25 H (he order and type of v).15 E(alues, as follo)-.25 E(ws:)-.25 E F1 12 (aA)152 394.8 S(string with arbitrary binary data, will be null padded.) -6 E 12(AA)152 406.8 S(text \(ASCII\) string, will be space padded.)-6 E 12(ZA)152 418.8 S (null\255terminated \(ASCIZ\) string, will be null padded.)-6 E 12(bA) 152 442.8 S (bit string \(ascending bit order inside each byte, like vec\(\)\).)-6 E 12(BA)152 454.8 S(bit string \(descending bit order inside each byte\).) -6 E 12(hA)152 466.8 S(hex string \(low nybble first\).)-6 E 12(HA)152 478.8 S(hex string \(high nybble first\).)-6 E 12(cA)152 502.8 S (signed char \(8\255bit\) value.)-6 E 12(CA)152 514.8 S 6(nu)-12 G (nsigned char \(octet\) value.)-6 E 12(WA)152 526.8 S 6(nu)-12 G (nsigned char value \(can be greater than 255\).)-6 E 12(sA)152 550.8 S (signed short \(16\255bit\) value.)-6 E 12(SA)152 562.8 S 6(nu)-12 G (nsigned short value.)-6 E 12(lA)152 586.8 S (signed long \(32\255bit\) value.)-6 E 12(LA)152 598.8 S 6(nu)-12 G (nsigned long value.)-6 E 12(qA)152 622.8 S (signed quad \(64\255bit\) value.)-6 E 12(QA)152 634.8 S 6(nu)-12 G (nsigned quad value.)-6 E (\(Quads are available only if your system supports 64\255bit)164 646.8 Q(integer values _and_ if Perl has been compiled to support those.)170 658.8 Q(Raises an exception otherwise.\))194 670.8 Q 12(iA)152 694.8 S (signed integer value.)-6 E 12(IA)152 706.8 S(unsigned integer value.)-6 E(\(This \010integer\010 is _at_least_ 32 bits wide.)164 718.8 Q (Its exact)12 E (size depends on what a local C compiler calls \010int\010.\))194 730.8 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 48)162.62 F 0 Cg EP %%Page: 49 49 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 12(nA)152 96 S 6(nu)-12 G (nsigned short \(16\255bit\) in "network" \(big\255endian\) order.)-6 E 12(NA)152 108 S 6(nu)-12 G (nsigned long \(32\255bit\) in "network" \(big\255endian\) order.)-6 E 12(vA)152 120 S 6(nu)-12 G (nsigned short \(16\255bit\) in "VAX" \(little\255endian\) order.)-6 E 12(VA)152 132 S 6(nu)-12 G (nsigned long \(32\255bit\) in "VAX" \(little\255endian\) order.)-6 E 18 (jA)152 156 S(Perl internal signed integer value \(IV\).)-12 E 18(JA)152 168 S(Perl internal unsigned integer value \(UV\).)-12 E 12(fA)152 192 S (single\255precision float in native format.)-6 E 12(dA)152 204 S (double\255precision float in native format.)-6 E 12(FA)152 228 S (Perl internal floating\255point value \(NV\) in native format)-6 E 12 (DA)152 240 S(float of long\255double precision in native format.)-6 E (\(Long doubles are available only if your system supports long)164 252 Q(double values _and_ if Perl has been compiled to support those.)170 264 Q(Raises an exception otherwise.\))194 276 Q 12(pA)152 300 S (pointer to a null\255terminated string.)-6 E 12(PA)152 312 S (pointer to a structure \(fixed\255length string\).)-6 E 12(uA)152 336 S (uuencoded string.)-6 E 12(UA)152 348 S(Unicode character number.)-6 E (Encodes to a character in character mode)12 E (and UTF\2558 \(or UTF\255EBCDIC in EBCDIC platforms\) in byte mode.)176 360 Q 12(wA)152 384 S (BER compressed integer \(not an ASN.1 BER, see perlpacktut for)-6 E 6 (details\). Its)170 396 R (bytes represent an unsigned integer in base 128,)6 E (most significant digit first, with as few digits as possible.)170 408 Q (Bit)12 E(eight \(the high bit\) is set on each byte except the last.) 170 420 Q 12(xA)152 444 S (null byte \(a.k.a ASCII NUL, "\\000", chr\(0\)\))-6 E 12(XB)152 456 S (ack up a byte.)-12 E 12(@N)152 468 S (ull\255fill or truncate to absolute position, counted from the)-12 E (start of the innermost \(\)\255group.)170 480 Q 12(.N)152 492 S (ull\255fill or truncate to absolute position specified by the value.) -12 E 12(\(S)152 504 S(tart of a \(\)\255group.)-12 E F0 1.777 (One or more modi\214ers belo)128 522 R 4.277(wm)-.25 G 1.777 (ay optionally follo)-4.277 F 4.277(wc)-.25 G 1.777 (ertain letters in the)-4.277 F/F2 9/Times-Roman@0 SF(TEMPLA)4.278 E(TE) -.999 E F0 1.778(\(the second)4.278 F (column lists letters for which the modi\214er is v)128 534 Q(alid\):) -.25 E F1 18(!s)152 552 S 24(SlLiI Forces)-18 F (native \(short, long, int\) sizes instead)6 E (of fixed \(16\255/32\255bit\) sizes.)242 564 Q 48(xX Make)176 588 R 6 (xa)6 G(nd X act as alignment commands.)-6 E 36(nNvV Treat)176 612 R (integers as signed instead of unsigned.)6 E 48(@. Specify)176 636 R (position as byte offset in the internal)6 E (representation of the packed string. Efficient but)242 648 Q (dangerous.)242 660 Q 18(>s)152 684 S 12(SiIlLqQ Force)-18 F (big\255endian byte\255order on the type.)6 E 12(jJfFdDpP \(The)176 696 R("big end" touches the construct.\))6 E 18()5.14 E F0(and)5.14 E F1(<)5.14 E F0 2.64 (modi\214ers can also be used on)5.14 F F1(\(\))5.14 E F0 2.64 (groups to force a particular byte-order on all)5.14 F (components in that group, including all its subgroups.)128 114 Q (The follo)128 132 Q(wing rules apply:)-.25 E<83>128 148.8 Q 1.792 (Each letter may optionally be follo)148 148.8 R 1.792 (wed by a number indicating the repeat count.)-.25 F 4.293(An)6.793 G (umeric)-4.293 E 1.79(repeat count may optionally be enclosed in brack) 148 160.8 R 1.79(ets, as in)-.1 F F1 1.79(pack\("C[80]", @arr\))4.29 F F0 6.79(.T)C(he)-6.79 E .493(repeat count gobbles that man)148 172.8 R 2.994(yv)-.15 G .494(alues from the)-3.244 F/F2 9/Times-Roman@0 SF(LIST) 2.994 E F0 .494(when used with all format types other than)2.994 F F1(a) 148 184.8 Q F0(,)A F1(A)2.838 E F0(,)A F1(Z)2.838 E F0(,)A F1(b)2.838 E F0(,)A F1(B)2.838 E F0(,)A F1(h)2.838 E F0(,)A F1(H)2.838 E F0(,)A F1(@) 2.838 E F0(,)A F1(.)2.838 E F0(,)A F1(x)2.838 E F0(,)A F1(X)2.838 E F0 2.838(,a)C(nd)-2.838 E F1(P)2.838 E F0 2.838(,w)C .338 (here it means something else, dscribed belo)-2.838 F 4.138 -.65(w. S) -.25 H(upplying).65 E(a)148 196.8 Q F1(*)3.4 E F0 .9 (for the repeat count instead of a number means to use ho)3.4 F(we)-.25 E -.15(ve)-.25 G 3.401(rm).15 G(an)-3.401 E 3.401(yi)-.15 G .901 (tems are left, e)-3.401 F(xcept)-.15 E(for:)148 208.8 Q<83>148 225.6 Q F1(@)168 225.6 Q F0(,)A F1(x)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(X)2.5 E F0 2.5(,w)C(here it is equi)-2.5 E -.25(va)-.25 G(lent to).25 E F1(0)2.5 E F0(.)A<83>148 242.4 Q(<.>, where it means relati)168 242.4 Q .3 -.15 (ve t)-.25 H 2.5(ot).15 G(he start of the string.)-2.5 E<83>148 259.2 Q F1(u)168 259.2 Q F0 2.5(,w)C(here it is equi)-2.5 E -.25(va)-.25 G (lent to 1 \(or 45, which here is equi).25 E -.25(va)-.25 G(lent\).).25 E 1.388(One can replace a numeric repeat count with a template letter e\ nclosed in brack)148 277.2 R 1.387(ets to use the)-.1 F(pack)148 289.2 Q (ed byte length of the brack)-.1 E(eted template for the repeat count.) -.1 E -.15(Fo)148 307.2 S 3.008(re).15 G .508(xample, the template) -3.158 F F1(x[L])3.009 E F0 .509(skips as man)3.009 F 3.009(yb)-.15 G .509(ytes as in a pack)-3.009 F .509(ed long, and the template)-.1 F F1 ("$t)3.009 E .598(X[$t] $t")148 319.2 R F0 .598(unpacks twice whate) 3.098 F -.15(ve)-.25 G(r).15 E F1($t)3.098 E F0 .597(\(when v)3.098 F (ariable-e)-.25 E .597(xpanded\) unpacks.)-.15 F .597 (If the template in)5.597 F(brack)148 331.2 Q .34 (ets contains alignment commands \(such as)-.1 F F1(x![d])2.84 E F0 .34 (\), its pack)B .34(ed length is calculated as if the)-.1 F (start of the template had the maximal possible alignment.)148 343.2 Q 1.889(When used with)148 361.2 R F1(Z)4.389 E F0 4.389(,a)C F1(*)A F0 1.889 (as the repeat count is guaranteed to add a trailing null byte, so the) 4.389 F(resulting string is al)148 373.2 Q -.1(wa)-.1 G (ys one byte longer than the byte length of the item itself.).1 E (When used with)148 391.2 Q F1(@)2.5 E F0 2.5(,t)C (he repeat count represents an of)-2.5 E (fset from the start of the innermost)-.25 E F1(\(\))2.5 E F0(group.)2.5 E .622(When used with)148 409.2 R F1(.)3.122 E F0 3.122(,t)C .623 (he repeat count determines the starting position to calculate the v) -3.122 F .623(alue of)-.25 F(fset)-.25 E(as follo)148 421.2 Q(ws:)-.25 E <83>148 438 Q(If the repeat count is)168 438 Q F1(0)2.5 E F0 2.5(,i)C (t')-2.5 E 2.5(sr)-.55 G(elati)-2.5 E .3 -.15(ve t)-.25 H 2.5(ot).15 G (he current position.)-2.5 E<83>148 454.8 Q(If the repeat count is)168 454.8 Q F1(*)2.5 E F0 2.5(,t)C(he of)-2.5 E(fset is relati)-.25 E .3 -.15(ve t)-.25 H 2.5(ot).15 G(he start of the pack)-2.5 E(ed string.)-.1 E<83>148 471.6 Q .019(And if it')168 471.6 R 2.519(sa)-.55 G 2.519(ni) -2.519 G(nte)-2.519 E(ger)-.15 E/F3 10/Times-Italic@0 SF(n)2.519 E F0 2.519(,t)C .019(he of)-2.519 F .019(fset is relati)-.25 F .319 -.15 (ve t)-.25 H 2.519(ot).15 G .018(he start of the)-2.519 F F3(n)2.518 E F0 .018(th innermost)B F1 6.018(\(\))2.518 G F0 .018(group, or to)-3.5 F (the start of the string if)168 483.6 Q F3(n)2.5 E F0 (is bigger then the group le)2.5 E -.15(ve)-.25 G(l.).15 E .075 (The repeat count for)148 501.6 R F1(u)2.575 E F0 .075(is interpreted a\ s the maximal number of bytes to encode per line of output,)2.575 F(wit\ h 0, 1 and 2 replaced by 45. The repeat count should not be more than 6\ 5.)148 513.6 Q<83>128 530.4 Q(The)148 530.4 Q F1(a)2.863 E F0(,)A F1(A) 2.863 E F0 2.863(,a)C(nd)-2.863 E F1(Z)2.863 E F0 .363 (types gobble just one v)2.863 F .363(alue, b)-.25 F .363 (ut pack it as a string of length count, padding with)-.2 F 2.027 (nulls or spaces as needed.)148 542.4 R 2.027(When unpacking,)7.027 F F1 (A)4.527 E F0 2.027(strips trailing whitespace and nulls,)4.527 F F1(Z) 4.528 E F0(strips)4.528 E -2.15 -.25(ev e)148 554.4 T (rything after the \214rst null, and).25 E F1(a)2.5 E F0 (returns data with no stripping at all.)2.5 E .997(If the v)148 572.4 R .997(alue to pack is too long, the result is truncated.)-.25 F .996 (If it')5.996 F 3.496(st)-.55 G .996(oo long and an e)-3.496 F .996 (xplicit count is)-.15 F(pro)148 584.4 Q(vided,)-.15 E F1(Z)4.509 E F0 2.009(packs only)4.509 F F1($count\2551)4.509 E F0 2.009(bytes, follo) 4.509 F 2.009(wed by a null byte.)-.25 F(Thus)7.01 E F1(Z)4.51 E F0(al) 4.51 E -.1(wa)-.1 G 2.01(ys packs a).1 F(trailing null, e)148 596.4 Q (xcept when the count is 0.)-.15 E<83>128 613.2 Q(Lik)148 613.2 Q -.25 (ew)-.1 G 2.309(ise, the).25 F F1(b)4.809 E F0(and)4.808 E F1(B)4.808 E F0 2.308(formats pack a string that')4.808 F 4.808(st)-.55 G 2.308 (hat man)-4.808 F 4.808(yb)-.15 G 2.308(its long.)-4.808 F 2.308 (Each such format)7.308 F(generates 1 bit of the result.)148 625.2 Q (These are typically follo)5 E(wed by a repeat count lik)-.25 E(e)-.1 E F1(B8)2.5 E F0(or)2.5 E F1(B64)2.5 E F0(.)A .96(Each result bit is base\ d on the least-signi\214cant bit of the corresponding input character) 148 643.2 R 3.46(,i)-.4 G .96(.e., on)-3.46 F F1(ord\($char\)%2)148 655.2 Q F0 5.44(.I)C 2.94(np)-5.44 G(articular)-2.94 E 2.94(,c)-.4 G (haracters)-2.94 E F1("0")2.94 E F0(and)2.94 E F1("1")2.94 E F0 .44 (generate bits 0 and 1, as do characters)2.94 F F1("\\000")148 667.2 Q F0(and)2.5 E F1("\\001")2.5 E F0(.)A 1.918(Starting from the be)148 685.2 R 1.919 (ginning of the input string, each 8\255tuple of characters is con)-.15 F -.15(ve)-.4 G 1.919(rted to 1).15 F 2.382(character of output.)148 697.2 R -.4(Wi)7.382 G 2.382(th format).4 F F1(b)4.882 E F0 4.882(,t)C 2.381(he \214rst character of the 8\255tuple determines the least-) -4.882 F(signi\214cant bit of a character; with format)148 709.2 Q F1(B) 2.5 E F0 2.5(,i)C 2.5(td)-2.5 G (etermines the most-signi\214cant bit of a character)-2.5 E(.)-.55 E .097(If the length of the input string is not e)148 727.2 R -.15(ve)-.25 G .097(nly di).15 F .098(visible by 8, the remainder is pack)-.25 F .098 (ed as if the input)-.1 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 50) 162.62 F 0 Cg EP %%Page: 51 51 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.079 (string were padded by null characters at the end.)148 84 R 1.078 (Similarly during unpacking, `)6.078 F(`e)-.74 E(xtra')-.15 E 3.578('b) -.74 G 1.078(its are)-3.578 F(ignored.)148 96 Q(If the input string is \ longer than needed, remaining characters are ignored.)148 114 Q(A)148 132 Q/F1 10/Courier@0 SF(*)2.606 E F0 .106 (for the repeat count uses all characters of the input \214eld.)2.606 F .106(On unpacking, bits are con)5.106 F -.15(ve)-.4 G .107(rted to).15 F 2.5(as)148 144 S(tring of)-2.5 E F1(0)2.5 E F0 2.5(sa)C(nd)-2.5 E F1(1) 2.5 E F0(s.)A<83>128 160.8 Q(The)148 160.8 Q F1(h)2.604 E F0(and)2.604 E F1(H)2.604 E F0 .103(formats pack a string that man)2.604 F 2.603(yn) -.15 G .103(ybbles \(4\255bit groups, representable as he)-2.753 F (xadecimal)-.15 E(digits,)148 172.8 Q F1 -3.5("0".."9" "a".."f")2.5 F F0 2.5(\)l)C(ong.)-2.5 E -.15(Fo)148 190.8 S 4.065(re).15 G 1.565 (ach such format,)-4.065 F/F2 10/Times-Italic@0 SF(pac)4.065 E(k\(\))-.2 E F0 1.565(generates 4 bits of result.)4.065 F -.4(Wi)6.566 G 1.566 (th non-alphabetical characters, the).4 F .129(result is based on the 4\ least-signi\214cant bits of the input character)148 202.8 R 2.629(,i) -.4 G .129(.e., on)-2.629 F F1(ord\($char\)%16)2.629 E F0 5.129(.I)C(n) -5.129 E(particular)148 214.8 Q 2.697(,c)-.4 G(haracters)-2.697 E F1 ("0")2.697 E F0(and)2.697 E F1("1")2.697 E F0 .197(generate n)2.697 F .197(ybbles 0 and 1, as do bytes)-.15 F F1("\\000")2.698 E F0(and)2.698 E F1("\\001")2.698 E F0(.)A -.15(Fo)148 226.8 S 3.145(rc).15 G (haracters)-3.145 E F1("a".."f")3.145 E F0(and)3.145 E F1("A".."F")3.145 E F0 3.145(,t)C .645(he result is compatible with the usual he)-3.145 F (xadecimal)-.15 E 1.252(digits, so that)148 238.8 R F1("a")3.752 E F0 (and)3.752 E F1("A")3.752 E F0 1.252(both generate the n)3.752 F(ybble) -.15 E F1(0xA==10)3.752 E F0 6.252(.U)C 1.252 (se only these speci\214c he)-6.252 F(x)-.15 E (characters with this format.)148 250.8 Q 1.072(Starting from the be)148 268.8 R 1.072(ginning of the template to)-.15 F F2(pac)3.572 E(k\(\))-.2 E F0 3.572(,e)C 1.072(ach pair of characters is con)-3.572 F -.15(ve)-.4 G 1.071(rted to 1).15 F .482(character of output.)148 280.8 R -.4(Wi) 5.483 G .483(th format).4 F F1(h)2.983 E F0 2.983(,t)C .483 (he \214rst character of the pair determines the least-signi\214cant) -2.983 F -.15(ny)148 292.8 S(bble of the output character; with format) .15 E F1(H)2.5 E F0 2.5(,i)C 2.5(td)-2.5 G (etermines the most-signi\214cant n)-2.5 E(ybble.)-.15 E .359 (If the length of the input string is not e)148 310.8 R -.15(ve)-.25 G .359(n, it beha).15 F -.15(ve)-.2 G 2.859(sa).15 G 2.859(si)-2.859 G 2.859(fp)-2.859 G .359(added by a null character at the end.)-2.859 F (Similarly)148 322.8 Q 2.5(,`)-.65 G(`e)-3.24 E(xtra')-.15 E 2.5('n)-.74 G(ybbles are ignored during unpacking.)-2.65 E (If the input string is longer than needed, e)148 340.8 Q (xtra characters are ignored.)-.15 E(A)148 358.8 Q F1(*)2.528 E F0 .028 (for the repeat count uses all characters of the input \214eld.)2.528 F -.15(Fo)5.028 G(r).15 E F2(unpac)2.529 E(k\(\))-.2 E F0 2.529(,n)C .029 (ybbles are con)-2.679 F -.15(ve)-.4 G(rted).15 E(to a string of he)148 370.8 Q(xadecimal digits.)-.15 E<83>128 387.6 Q(The)148 387.6 Q F1(p) 3.441 E F0 .941(format packs a pointer to a null-terminated string.) 3.441 F -1.1(Yo)5.941 G 3.44(ua)1.1 G .94 (re responsible for ensuring that)-3.44 F .057 (the string is not a temporary v)148 399.6 R .058 (alue, as that could potentially get deallocated before you got around) -.25 F .077(to using the pack)148 411.6 R .077(ed result.)-.1 F(The) 5.077 E F1(P)2.577 E F0 .076 (format packs a pointer to a structure of the size indicated by the) 2.576 F 3.154(length. A)148 423.6 R .654 (null pointer is created if the corresponding v)3.154 F .654(alue for) -.25 F F1(p)3.154 E F0(or)3.154 E F1(P)3.154 E F0(is)3.154 E F1(undef) 3.154 E F0 3.155(;s)C .655(imilarly with)-3.155 F F2(unpac)148 435.6 Q (k\(\))-.2 E F0 2.5(,w)C(here a null pointer unpacks into)-2.5 E F1 (undef)2.5 E F0(.)A .123(If your system has a strange pointer size)148 453.6 R 1.666<8a6d>1.666 G .123 (eaning a pointer is neither as big as an int nor as big)-1.666 F .506 (as a long)148 465.6 R 1.666<8a69>1.666 G 3.007(tm)-1.666 G .507(ay not\ be possible to pack or unpack pointers in big\255 or little-endian byt\ e order)-3.007 F(.)-.55 E(Attempting to do so raises an e)148 477.6 Q (xception.)-.15 E<83>128 494.4 Q(The)148 494.4 Q F1(/)2.764 E F0 .264 (template character allo)2.764 F .264 (ws packing and unpacking of a sequence of items where the pack)-.25 F (ed)-.1 E .745(structure contains a pack)148 506.4 R .745 (ed item count follo)-.1 F .745(wed by the pack)-.25 F .745 (ed items themselv)-.1 F 3.245(es. This)-.15 F .745(is useful)3.245 F .405(when the structure you')148 518.4 R .404(re unpacking has encoded \ the sizes or repeat counts for some of its \214elds)-.5 F (within the structure itself as separate \214elds.)148 530.4 Q -.15(Fo) 148 548.4 S(r).15 E F1(pack)3.759 E F0 3.759(,y)C 1.259(ou write)-3.759 F F2(length-item)3.759 E F1(/)A F2(sequence-item)A F0 3.759(,a)C 1.259 (nd the)-3.759 F F2(length-item)3.759 E F0 1.259(describes ho)3.759 F 3.759(wt)-.25 G 1.26(he length)-3.759 F -.25(va)148 560.4 S .298 (lue is pack).25 F .298(ed. F)-.1 F .298(ormats lik)-.15 F .298 (ely to be of most use are inte)-.1 F(ger)-.15 E .297(-packing ones lik) -.2 F(e)-.1 E F1(n)2.797 E F0 .297(for Ja)2.797 F .797 -.25(va s)-.2 H (trings,).25 E F1(w)148 572.4 Q F0(for)2.5 E/F3 9/Times-Roman@0 SF(ASN) 2.5 E F0(.1 or)A F3(SNMP)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(N)2.5 E F0 (for Sun)2.5 E F3(XDR)2.5 E F0(.)A -.15(Fo)148 590.4 S(r).15 E F1(pack) 3.417 E F0(,)A F2(sequence-item)3.417 E F0 .917(may ha)3.417 F 1.217 -.15(ve a r)-.2 H .918 (epeat count, in which case the minimum of that and the).15 F .012 (number of a)148 602.4 R -.25(va)-.2 G .011 (ilable items is used as the ar).25 F .011(gument for)-.18 F F2 (length-item)2.511 E F0 2.511(.I)C 2.511(fi)-2.511 G 2.511(th)-2.511 G .011(as no repeat count or uses)-2.511 F 2.5(a')148 614.4 S (*', the number of a)-2.5 E -.25(va)-.2 G(ilable items is used.).25 E -.15(Fo)148 632.4 S(r).15 E F1(unpack)5.679 E F0 5.679(,a)C 5.679(ni) -5.679 G 3.179(nternal stack of inte)-5.679 F 3.179(ger ar)-.15 F 3.179 (guments unpack)-.18 F 3.179(ed so f)-.1 F 3.18(ar is used. Y)-.1 F 3.18 (ou write)-1.1 F F1(/)148 644.4 Q F2(sequence-item)A F0 .681 (and the repeat count is obtained by popping of)3.181 F 3.181(ft)-.25 G .68(he last element from the stack.)-3.181 F(The)148 656.4 Q F2 (sequence-item)2.5 E F0(must not ha)2.5 E .3 -.15(ve a r)-.2 H (epeat count.).15 E(If)148 674.4 Q F2(sequence-item)3.108 E F0 .608 (refers to a string type \()3.108 F F1("A")A F0(,)A F1("a")3.108 E F0 3.108(,o)C(r)-3.108 E F1("Z")3.108 E F0 .608(\), the)B F2(length-item) 3.108 E F0 .609(is the string length,)3.108 F .257 (not the number of strings.)148 686.4 R -.4(Wi)5.257 G .257(th an e).4 F .257(xplicit repeat count for pack, the pack)-.15 F .257 (ed string is adjusted to)-.1 F(that length.)148 698.4 Q -.15(Fo)5 G 2.5 (re).15 G(xample:)-2.65 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 51) 162.62 F 0 Cg EP %%Page: 52 52 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (unpack\("W/a", "\\004Gurusamy"\))172 84 Q(gives \("Guru"\))66 E (unpack\("a3/A A*", "007 Bond)172 96 Q 6(J")12 G 42(\)g)-6 G (ives \(" Bond", "J"\))-42 E(unpack\("a3 x2 /A A*", "007: Bond, J."\)) 172 108 Q(gives \("Bond, J", "."\))12 E (pack\("n/a* w/a","hello,","world"\))172 132 Q (gives "\\000\\006hello,\\005world")42 E (pack\("a/W2", ord\("a"\) .. ord\("z"\)\))172 144 Q(gives "2ab")36 E F0 (The)148 162 Q/F2 10/Times-Italic@0 SF(length-item)2.5 E F0 (is not returned e)2.5 E(xplicitly from)-.15 E F1(unpack)2.5 E F0(.)A .509(Supplying a count to the)148 180 R F2(length-item)3.009 E F0 .509 (format letter is only useful with)3.009 F F1(A)3.01 E F0(,)A F1(a)3.01 E F0 3.01(,o)C(r)-3.01 E F1(Z)3.01 E F0 5.51(.P)C .51(acking with a) -5.66 F F2(length-item)148 192 Q F0(of)3.214 E F1(a)3.214 E F0(or)3.214 E F1(Z)3.214 E F0 .714(may introduce)3.214 F F1("\\000")3.214 E F0 .714 (characters, which Perl does not re)3.214 F -.05(ga)-.15 G .713 (rd as le).05 F -.05(ga)-.15 G 3.213(li).05 G(n)-3.213 E (numeric strings.)148 204 Q<83>128 220.8 Q 1.319(The inte)148 220.8 R 1.319(ger types)-.15 F F1(s)3.819 E F0(,)A F1(S)3.819 E F0(,)A F1(l) 3.819 E F0 3.819(,a)C(nd)-3.819 E F1(L)3.819 E F0 1.319(may be follo) 3.819 F 1.32(wed by a)-.25 F F1(!)3.82 E F0 1.32 (modi\214er to specify nati)3.82 F 1.62 -.15(ve s)-.25 H 1.32(horts or) .15 F 2.613(longs. As)148 232.8 R(sho)2.613 E .113(wn in the e)-.25 F .113(xample abo)-.15 F -.15(ve)-.15 G 2.612(,ab).15 G(are)-2.612 E F1(l) 2.612 E F0 .112(means e)2.612 F .112(xactly 32 bits, although the nati) -.15 F -.15(ve)-.25 G F1(long)2.762 E F0 .303 (as seen by the local C compiler may be lar)148 244.8 R(ger)-.18 E 5.303 (.T)-.55 G .303(his is mainly an issue on 64\255bit platforms.)-5.303 F -1.1(Yo)5.303 G(u)1.1 E(can see whether using)148 256.8 Q F1(!)2.5 E F0 (mak)2.5 E(es an)-.1 E 2.5(yd)-.15 G(if)-2.5 E(ference this w)-.25 E (ay:)-.1 E F1(printf "format s is %d, s! is %d\\n",)172 274.8 Q (length pack\("s"\), length pack\("s!"\);)196 286.8 Q (printf "format l is %d, l! is %d\\n",)172 310.8 Q (length pack\("l"\), length pack\("l!"\);)196 322.8 Q(i!)148 340.8 Q F0 (and)2.5 E F1(I!)2.5 E F0(are also allo)2.5 E(wed, b)-.25 E (ut only for completeness' sak)-.2 E(e: the)-.1 E 2.5(ya)-.15 G (re identical to)-2.5 E F1(i)2.5 E F0(and)2.5 E F1(I)2.5 E F0(.)A .242 (The actual sizes \(in bytes\) of nati)148 358.8 R .542 -.15(ve s)-.25 H .242(horts, ints, longs, and long longs on the platform where Perl).15 F -.1(wa)148 370.8 S 2.5(sb).1 G(uilt are also a)-2.7 E -.25(va)-.2 G (ilable from the command line:).25 E F1 6($p)172 388.8 S (erl \255V:{short,int,long{,long}}size)-6 E(shortsize=\0102\010;)172 400.8 Q(intsize=\0104\010;)172 412.8 Q(longsize=\0104\010;)172 424.8 Q (longlongsize=\0108\010;)172 436.8 Q F0(or programmatically via the)148 454.8 Q F1(Config)2.5 E F0(module:)2.5 E F1(use Config;)190 472.8 Q (print $Config{shortsize},)190 484.8 Q("\\n";)24 E (print $Config{intsize},)190 496.8 Q("\\n";)36 E (print $Config{longsize},)190 508.8 Q("\\n";)30 E (print $Config{longlongsize}, "\\n";)190 520.8 Q($Config{longlongsize}) 148 538.8 Q F0(is unde\214ned on systems without long long support.)2.5 E<83>128 555.6 Q .118(The inte)148 555.6 R .118(ger formats)-.15 F F1(s) 2.618 E F0(,)A F1(S)2.618 E F0(,)A F1(i)2.618 E F0(,)A F1(I)2.618 E F0 (,)A F1(l)2.618 E F0(,)A F1(L)2.618 E F0(,)A F1(j)2.618 E F0 2.618(,a)C (nd)-2.618 E F1(J)2.618 E F0 .119 (are inherently non-portable between processors and)2.618 F 1.384 (operating systems because the)148 567.6 R 3.884(yo)-.15 G(be)-3.884 E 3.883(yn)-.15 G(ati)-3.883 E 1.683 -.15(ve b)-.25 H 1.383 (yteorder and endianness.).15 F -.15(Fo)6.383 G 3.883(re).15 G 1.383 (xample, a 4\255byte)-4.033 F(inte)148 579.6 Q .18 (ger 0x12345678 \(305419896 decimal\) w)-.15 F .181 (ould be ordered nati)-.1 F -.15(ve)-.25 G .181 (ly \(arranged in and handled by).15 F(the)148 591.6 Q/F3 9 /Times-Roman@0 SF(CPU)2.5 E F0(re)2.5 E(gisters\) into bytes as)-.15 E F1(0x12 0x34 0x56 0x78)172 609.6 Q 6(#b)12 G(ig\255endian)-6 E (0x78 0x56 0x34 0x12)172 621.6 Q 6(#l)12 G(ittle\255endian)-6 E F0 (Basically)148 639.6 Q 5.311(,I)-.65 G 2.811(ntel and)-5.311 F F3 -1.215 (VA)5.311 G(X)1.215 E F0 2.811(CPUs are little-endian, while e)5.311 F -.15(ve)-.25 G 2.811(rybody else, including Motorola).15 F(m68k/88k,)148 651.6 Q F3(PPC)3.241 E F0 3.241(,S)C(parc,)-3.241 E F3 .991(HP P)3.241 F (A)-.828 E F0 3.241(,P)C -.25(ow)-3.241 G(er).25 E 3.241(,a)-.4 G .741 (nd Cray)-3.241 F 3.241(,a)-.65 G .741(re big-endian.)-3.241 F .741 (Alpha and)5.741 F F3(MIPS)3.241 E F0 .742(can be either:)3.241 F 1.559 (Digital/Compaq uses \(well, used\) them in little-endian mode, b)148 663.6 R 1.559(ut SGI/Cray uses them in big-)-.2 F(endian mode.)148 675.6 Q .238(The names)148 693.6 R F2(big-endian)2.738 E F0(and)2.738 E F2 (little-endian)2.738 E F0 .239(are comic references to the e)2.738 F .239(gg-eating habits of the little-)-.15 F 2.357(endian Lilliputians a\ nd the big-endian Blefuscudians from the classic Jonathan Swift satire,) 148 705.6 R F2(Gulliver')148 717.6 Q 3.944(sT)-.4 G -.15(ra)-4.494 G (vels).15 E F0 6.444(.T)C 1.444 (his entered computer lingo via the paper `)-6.444 F 1.444(`On Holy W) -.74 F 1.444(ars and a Plea for)-.8 F(Peace')148 729.6 Q 2.5('b)-.74 G 2.5(yD)-2.5 G(ann)-2.5 E 2.5(yC)-.15 G(ohen,)-2.5 E F3 .25(USC/ISI IEN) 2.5 F F0(137, April 1, 1980.)2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 52)162.62 F 0 Cg EP %%Page: 53 53 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (Some systems may ha)148 84 Q .3 -.15(ve e)-.2 H -.15(ve)-.1 G 2.5(nw) .15 G(eirder byte orders such as)-2.5 E/F1 10/Courier@0 SF (0x56 0x78 0x12 0x34)166 102 Q(0x34 0x12 0x78 0x56)166 114 Q F0 -1.1(Yo) 148 132 S 2.5(uc)1.1 G (an determine your system endianness with this incantation:)-2.5 E F1 (printf\("%#02x ", $_\) for unpack\("W*", pack L=>0x12345678\);)166 150 Q F0(The byteorder on the platform where Perl w)148 168 Q(as b)-.1 E (uilt is also a)-.2 E -.25(va)-.2 G(ilable via Con\214g:).25 E F1 (use Config;)172 186 Q(print "$Config{byteorder}\\n";)172 198 Q F0 (or from the command line:)148 216 Q F1 6($p)172 234 S (erl \255V:byteorder)-6 E F0(Byteorders)148 252 Q F1("1234")3.56 E F0 (and)3.56 E F1("12345678")3.56 E F0 1.06(are little-endian;)3.56 F F1 ("4321")3.56 E F0(and)3.56 E F1("87654321")3.56 E F0 1.06(are big-)3.56 F(endian.)148 264 Q -.15(Fo)148 282 S 4.316(rp).15 G 1.816(ortably pack) -4.316 F 1.816(ed inte)-.1 F 1.817(gers, either use the formats)-.15 F F1(n)4.317 E F0(,)A F1(N)4.317 E F0(,)A F1(v)4.317 E F0 4.317(,a)C(nd) -4.317 E F1(V)4.317 E F0 1.817(or else use the)4.317 F F1(>)4.317 E F0 (and)4.317 E F1(<)4.317 E F0(modi\214ers described immediately belo)148 294 Q 3.8 -.65(w. S)-.25 H(ee also perlport.).65 E<83>128 310.8 Q .882 (Starting with Perl 5.9.2, inte)148 310.8 R .882 (ger and \215oating-point formats, along with the)-.15 F F1(p)3.382 E F0 (and)3.382 E F1(P)3.382 E F0 .882(formats and)3.382 F F1(\(\))148 322.8 Q F0 .625(groups, may all be follo)3.125 F .625(wed by the)-.25 F F1(>) 3.126 E F0(or)3.126 E F1(<)3.126 E F0 .626 (endianness modi\214ers to respecti)3.126 F -.15(ve)-.25 G .626 (ly enforce big\255).15 F .519(or little-endian byte-order)148 334.8 R 5.519(.T)-.55 G .519(hese modi\214ers are especially useful gi)-5.519 F -.15(ve)-.25 G 3.019(nh).15 G -.25(ow)-3.019 G F1(n)3.269 E F0(,)A F1(N) 3.018 E F0(,)A F1(v)3.018 E F0 3.018(,a)C(nd)-3.018 E F1(V)3.018 E F0 (don')3.018 E(t)-.18 E(co)148 346.8 Q -.15(ve)-.15 G 2.5(rs).15 G (igned inte)-2.5 E(gers, 64\255bit inte)-.15 E (gers, or \215oating-point v)-.15 E(alues.)-.25 E (Here are some concerns to k)148 364.8 Q (eep in mind when using an endianness modi\214er:)-.1 E<83>148 381.6 Q .157(Exchanging signed inte)168 381.6 R .157(gers between dif)-.15 F .157(ferent platforms w)-.25 F .158(orks only when all platforms store) -.1 F 3.111(them in the same format.)168 393.6 R 3.111 (Most platforms store signed inte)8.111 F 3.111(gers in tw)-.15 F(o')-.1 E(s-complement)-.55 E(notation, so usually this is not an issue.)168 405.6 Q<83>148 422.4 Q(The)168 422.4 Q F1(>)3.922 E F0(or)3.922 E F1(<) 3.922 E F0 1.422(modi\214ers can only be used on \215oating-point forma\ ts on big\255 or little-endian)3.922 F 2.5(machines. Otherwise,)168 434.4 R(attempting to use them raises an e)2.5 E(xception.)-.15 E<83>148 451.2 Q -.15(Fo)168 451.2 S .359 (rcing big\255 or little-endian byte-order on \215oating-point v).15 F .358(alues for data e)-.25 F .358(xchange can w)-.15 F(ork)-.1 E .312 (only if all platforms use the same binary representation such as)168 463.2 R/F2 9/Times-Roman@0 SF(IEEE)2.812 E F0 2.812 (\215oating-point. Ev)2.812 F .312(en if)-.15 F .505 (all platforms are using)168 475.2 R F2(IEEE)3.005 E F0 3.005(,t)C .505 (here may still be subtle dif)-3.005 F 3.005(ferences. Being)-.25 F .505 (able to use)3.005 F F1(>)3.005 E F0(or)3.005 E F1(<)3.005 E F0 1.072 (on \215oating-point v)168 487.2 R 1.073(alues can be useful, b)-.25 F 1.073(ut also dangerous if you don')-.2 F 3.573(tk)-.18 G(no)-3.573 E 3.573(we)-.25 G 1.073(xactly what)-3.723 F(you')168 499.2 Q(re doing.) -.5 E(It is not a general w)5 E(ay to portably store \215oating-point v) -.1 E(alues.)-.25 E<83>148 516 Q .909(When using)168 516 R F1(>)3.409 E F0(or)3.409 E F1(<)3.409 E F0 .909(on a)3.409 F F1(\(\))3.409 E F0 .909 (group, this af)3.409 F .909 (fects all types inside the group that accept byte-)-.25 F .878 (order modi\214ers, including all subgroups.)168 528 R .879 (It is silently ignored for all other types.)5.878 F -1.1(Yo)5.879 G 3.379(ua)1.1 G(re)-3.379 E .505(not allo)168 540 R .505(wed to o)-.25 F -.15(ve)-.15 G .505(rride the byte-order within a group that already ha\ s a byte-order modi\214er).15 F(suf)168 552 Q(\214x.)-.25 E<83>128 568.8 Q .632(Real numbers \(\215oats and doubles\) are in nati)148 568.8 R .932 -.15(ve m)-.25 H .632(achine format only).15 F 5.632(.D)-.65 G .632 (ue to the multiplicity of)-5.632 F .845 (\215oating-point formats and the lack of a standard `)148 580.8 R (`netw)-.74 E(ork')-.1 E 3.344('r)-.74 G .844 (epresentation for them, no f)-3.344 F(acility)-.1 E 2.453 (for interchange has been made.)148 592.8 R 2.453(This means that pack) 7.453 F 2.453(ed \215oating-point data written on one)-.1 F .182 (machine may not be readable on another)148 604.8 R 2.682(,e)-.4 G -.15 (ve)-2.932 G 2.682(ni).15 G 2.682(fb)-2.682 G .182(oth use)-2.682 F F2 (IEEE)2.682 E F0 .181(\215oating-point arithmetic \(because)2.682 F (the endianness of the memory representation is not part of the)148 616.8 Q F2(IEEE)2.5 E F0 2.5(spec\). See)2.5 F(also perlport.)2.5 E .692 (If you kno)148 634.8 R(w)-.25 E/F3 10/Times-Italic@0 SF -.2(ex)3.192 G (actly).2 E F0 .692(what you')3.192 F .692(re doing, you can use the)-.5 F F1(>)3.192 E F0(or)3.192 E F1(<)3.192 E F0 .692 (modi\214ers to force big\255 or little-)3.192 F (endian byte-order on \215oating-point v)148 646.8 Q(alues.)-.25 E .565 (Because Perl uses doubles \(or long doubles, if con\214gured\) interna\ lly for all numeric calculation,)148 664.8 R(con)148 676.8 Q -.15(ve)-.4 G .468(rting from double into \215oat and thence to double ag).15 F .468 (ain loses precision, so)-.05 F F1(unpack\("f",)2.968 E (pack\("f", $foo\))148 688.8 Q F0 2.5(\)w)C(ill not in general equal) -2.5 E F1($foo)2.5 E F0(.)A<83>128 705.6 Q -.15(Pa)148 705.6 S .028 (ck and unpack can operate in tw).15 F 2.528(om)-.1 G .028 (odes: character mode \()-2.528 F F1(C0)A F0 .028(mode\) where the pack) 2.528 F .028(ed string is)-.1 F .564(processed per character)148 717.6 R 3.064(,a)-.4 G(nd)-3.064 E F2(UTF\2558)3.064 E F0 .564(mode \()3.064 F F1(U0)A F0 .564(mode\) where the pack)3.064 F .565 (ed string is processed in its)-.1 F .368(UTF\2558\255encoded Unicode f\ orm on a byte-by-byte basis. Character mode is the def)148 729.6 R .367 (ault unless the)-.1 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 53)162.62 F 0 Cg EP %%Page: 54 54 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .237 (format string starts with)148 84 R/F1 10/Courier@0 SF(U)2.737 E F0 2.737(.Y)C .237(ou can al)-3.837 F -.1(wa)-.1 G .238 (ys switch mode mid-format with an e).1 F(xplicit)-.15 E F1(C0)2.738 E F0(or)2.738 E F1(U0)2.738 E F0(in)2.738 E .813(the format.)148 96 R .813 (This mode remains in ef)5.813 F .812(fect until the ne)-.25 F .812 (xt mode change, or until the end of the)-.15 F F1(\(\))3.312 E F0 (group it \(directly\) applies to.)148 108 Q(Using)148 126 Q F1(C0)3.086 E F0 .586(to get Unicode characters while using)3.086 F F1(U0)3.087 E F0 .587(to get)3.087 F/F2 10/Times-Italic@0 SF(non)3.087 E F0 .587 (\255Unicode bytes is not necessarily)B(ob)148 138 Q 5(vious. Probably) -.15 F(only the \214rst of these is what you w)2.5 E(ant:)-.1 E F1 6($p) 172 156 S(erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \ \255CS \255ne \010printf "%v04X\\n", $_ for unpack\("C0A*", $_\)\010)184 168 Q(03B1.03C9)172 180 Q 6($p)172 192 S (erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \255CS \ \255ne \010printf "%v02X\\n", $_ for unpack\("U0A*", $_\)\010)184 204 Q (CE.B1.CF.89)172 216 Q 6($p)172 228 S (erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \255C0 \ \255ne \010printf "%v02X\\n", $_ for unpack\("C0A*", $_\)\010)184 240 Q (CE.B1.CF.89)172 252 Q 6($p)172 264 S (erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \255C0 \ \255ne \010printf "%v02X\\n", $_ for unpack\("U0A*", $_\)\010)184 276 Q (C3.8E.C2.B1.C3.8F.C2.89)172 288 Q F0 .941(Those e)148 306 R .941 (xamples also illustrate that you should not try to use)-.15 F F1(pack) 3.44 E F0(/)A F1(unpack)A F0 .94(as a substitute for)3.44 F (the Encode module.)148 318 Q<83>128 334.8 Q -1.1(Yo)148 334.8 S 3.245 (um)1.1 G .745(ust yourself do an)-3.245 F 3.246(ya)-.15 G .746 (lignment or padding by inserting, for e)-3.246 F .746(xample, enough) -.15 F F1("x")3.246 E F0 .746(es while)B 4.138(packing. There)148 346.8 R 1.638(is no w)4.138 F 1.638(ay for)-.1 F F2(pac)4.138 E(k\(\))-.2 E F0 (and)4.138 E F2(unpac)4.138 E(k\(\))-.2 E F0 1.637(to kno)4.137 F 4.137 (ww)-.25 G 1.637(here characters are going to or)-4.137 F (coming from, so the)148 358.8 Q 2.5(yh)-.15 G (andle their output and input as \215at sequences of characters.)-2.5 E <83>128 375.6 Q(A)148 375.6 Q F1(\(\))4.011 E F0 1.511 (group is a sub-TEMPLA)4.011 F 1.511(TE enclosed in parentheses.)-1.11 F 4.011(Ag)6.511 G 1.512(roup may tak)-4.011 F 4.012(ear)-.1 G 1.512 (epeat count)-4.012 F .904(either as post\214x, or for)148 387.6 R F2 (unpac)3.404 E(k\(\))-.2 E F0 3.404(,a)C .904(lso via the)-3.404 F F1(/) 3.404 E F0 .904(template character)3.404 F 5.904(.W)-.55 G .903 (ithin each repetition of a)-6.304 F(group, positioning with)148 399.6 Q F1(@)2.5 E F0(starts o)2.5 E -.15(ve)-.15 G 2.5(ra).15 G 2.5(t0)-2.5 G 2.5(.T)-2.5 G(herefore, the result of)-2.5 E F1 (pack\("@1A\(\(@2A\)@3A\)", qw[X Y Z]\))172 417.6 Q F0(is the string)148 435.6 Q F1("\\0X\\0\\0YZ")2.5 E F0(.)A<83>128 452.4 Q F1(x)148 452.4 Q F0(and)3.202 E F1(X)3.202 E F0 .702(accept the)3.202 F F1(!)3.202 E F0 .702(modi\214er to act as alignment commands: the)3.202 F 3.202(yj)-.15 G .702(ump forw)-3.202 F .703(ard or back to the)-.1 F .537 (closest position aligned at a multiple of)148 464.4 R F1(count)3.037 E F0 .537(characters. F)3.037 F .537(or e)-.15 F .536(xample, to)-.15 F F2 (pac)3.036 E(k\(\))-.2 E F0(or)3.036 E F2(unpac)3.036 E(k\(\))-.2 E F0 (a)3.036 E 2.5(Cs)148 476.4 S(tructure lik)-2.5 E(e)-.1 E F1(struct {) 172 494.4 Q 12(char c;)196 506.4 R(/* one signed, 8\255bit character */) 24 E(double d;)196 518.4 Q 12(char cc[2];)196 530.4 R(})172 542.4 Q F0 1.63(one may need to use the template)148 560.4 R F1 7.63(cx)4.13 G 1.63 (![d] d c[2])-7.63 F F0 6.63(.T)C 1.63(his assumes that doubles must be) -6.63 F(aligned to the size of double.)148 572.4 Q -.15(Fo)148 590.4 S 2.5(ra).15 G(lignment commands, a)-2.5 E F1(count)2.5 E F0(of 0 is equi) 2.5 E -.25(va)-.25 G(lent to a).25 E F1(count)2.5 E F0 (of 1; both are no-ops.)2.5 E<83>128 607.2 Q F1(n)148 607.2 Q F0(,)A F1 (N)2.975 E F0(,)A F1(v)2.975 E F0(and)2.975 E F1(V)2.975 E F0 .475 (accept the)2.975 F F1(!)2.975 E F0 .474 (modi\214er to represent signed 16\255/32\255bit inte)2.975 F .474 (gers in big\255/little\255endian)-.15 F(order)148 619.2 Q 7.892(.T)-.55 G 2.892(his is portable only when all platforms sharing pack)-7.892 F 2.892(ed data use the same binary)-.1 F 3.274 (representation for signed inte)148 631.2 R 3.274(gers; for e)-.15 F 3.274(xample, when all platforms use tw)-.15 F(o')-.1 E(s-complement) -.55 E(representation.)148 643.2 Q<83>128 660 Q .732 (Comments can be embedded in a)148 660 R/F3 9/Times-Roman@0 SF(TEMPLA) 3.232 E(TE)-.999 E F0(using)3.232 E F1(#)3.233 E F0 .733 (through the end of line.)3.233 F .733(White space can)5.733 F .937 (separate pack codes from each other)148 672 R 3.437(,b)-.4 G .937 (ut modi\214ers and repeat counts must follo)-3.637 F 3.436(wi)-.25 G (mmediately)-3.436 E(.)-.65 E .743(Breaking comple)148 684 R 3.243(xt) -.15 G .743(emplates into indi)-3.243 F .743 (vidual line-by-line components, suitably annotated, can do)-.25 F 3.222 (as much to impro)148 696 R 3.522 -.15(ve l)-.15 H -.15(eg).15 G 3.222 (ibility and maintainability of pack/unpack formats as).15 F F1(/x)5.721 E F0 3.221(can for)5.721 F(complicated pattern matches.)148 708 Q (perl v5.14.2)72 768 Q 198.17(2011-10-01 54)162.62 F 0 Cg EP %%Page: 55 55 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E<83>128 84 Q(If)148 84 Q/F1 9/Times-Roman@0 SF(TEMPLA)5.073 E(TE)-.999 E F0 2.573 (requires more ar)5.073 F 2.573(guments than)-.18 F/F2 10/Times-Italic@0 SF(pac)5.073 E(k\(\))-.2 E F0 2.574(is gi)5.073 F -.15(ve)-.25 G(n,).15 E F2(pac)5.074 E(k\(\))-.2 E F0 2.574(assumes additional)5.074 F/F3 10 /Courier@0 SF("")5.074 E F0(ar)148 96 Q 2.5(guments. If)-.18 F F1 (TEMPLA)2.5 E(TE)-.999 E F0(requires fe)2.5 E(wer ar)-.25 E (guments than gi)-.18 E -.15(ve)-.25 G(n, e).15 E(xtra ar)-.15 E (guments are ignored.)-.18 E(Examples:)128 114 Q F3 ($foo = pack\("WWWW",65,66,67,68\);)152 132 Q 6(#f)152 144 S (oo eq "ABCD")-6 E($foo = pack\("W4",65,66,67,68\);)152 156 Q 6(#s)152 168 S(ame thing)-6 E($foo = pack\("W4",0x24b6,0x24b7,0x24b8,0x24b9\);) 152 180 Q 6(#s)152 192 S(ame thing with Unicode circled letters.)-6 E ($foo = pack\("U4",0x24b6,0x24b7,0x24b8,0x24b9\);)152 204 Q 6(#s)152 216 S(ame thing with Unicode circled letters. You don\010t get the UTF\2558) -6 E 6(#b)152 228 S (ytes because the U at the start of the format caused a switch to)-6 E 6 (#U)152 240 S (0\255mode, so the UTF\2558 bytes get joined into characters)-6 E ($foo = pack\("C0U4",0x24b6,0x24b7,0x24b8,0x24b9\);)152 252 Q 6(#f)152 264 S (oo eq "\\xe2\\x92\\xb6\\xe2\\x92\\xb7\\xe2\\x92\\xb8\\xe2\\x92\\xb9")-6 E 6(#T)152 276 S (his is the UTF\2558 encoding of the string in the previous example)-6 E ($foo = pack\("ccxxcc",65,66,67,68\);)152 300 Q 6(#f)152 312 S (oo eq "AB\\0\\0CD")-6 E 6(#N)152 336 S (OTE: The examples above featuring "W" and "c" are true)-6 E 6(#o)152 348 S(nly on ASCII and ASCII\255derived systems such as ISO Latin 1)-6 E 6(#a)152 360 S(nd UTF\2558.)-6 E (On EBCDIC systems, the first example would be)12 E 36(#$)152 372 S (foo = pack\("WWWW",193,194,195,196\);)-36 E($foo = pack\("s2",1,2\);) 152 396 Q 6(#")152 408 S(\\001\\000\\002\\000" on little\255endian)-6 E 6(#")152 420 S(\\000\\001\\000\\002" on big\255endian)-6 E ($foo = pack\("a4","abcd","x","y","z"\);)152 444 Q 6(#")152 456 S(abcd") -6 E($foo = pack\("aaaa","abcd","x","y","z"\);)152 480 Q 6(#")152 492 S (axyz")-6 E($foo = pack\("a14","abcdefg"\);)152 516 Q 6(#")152 528 S (abcdefg\\0\\0\\0\\0\\0\\0\\0")-6 E($foo = pack\("i9pl", gmtime\);)152 552 Q 6(#ar)152 564 S(eal struct tm \(on my system anyway\))-6 E ($utmp_template = "Z8 Z8 Z16 L";)152 588 Q ($utmp = pack\($utmp_template, @utmp1\);)152 600 Q 6(#as)152 612 S (truct utmp \(BSDish\))-6 E(@utmp2 = unpack\($utmp_template, $utmp\);) 152 636 Q 6(#")152 648 S(@utmp1" eq "@utmp2")-6 E(sub bintodec {)152 672 Q(unpack\("N", pack\("B32", substr\("0" x 32 . shift, \25532\)\)\);)176 684 Q(})152 696 Q($foo = pack\(\010sx2l\010, 12, 34\);)152 720 Q F0 (perl v5.14.2)72 768 Q 198.17(2011-10-01 55)162.62 F 0 Cg EP %%Page: 56 56 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#s)152 84 S(hort 12, two zero bytes padding, long 34)-6 E ($bar = pack\(\010s@4l\010, 12, 34\);)152 96 Q 6(#s)152 108 S (hort 12, zero fill to position 4, long 34)-6 E 6(#$)152 120 S (foo eq $bar)-6 E($baz = pack\(\010s.l\010, 12, 4, 34\);)152 132 Q 6(#s) 152 144 S(hort 12, zero fill to position 4, long 34)-6 E ($foo = pack\(\010nN\010, 42, 4711\);)152 168 Q 6(#p)152 180 S (ack big\255endian 16\255 and 32\255bit unsigned integers)-6 E ($foo = pack\(\010S>L>\010, 42, 4711\);)152 192 Q 6(#e)152 204 S (xactly the same)-6 E($foo = pack\(\010s.15 G 2.538(ag on \214les, that \215ag is set on all ne)-5.037 F 2.538(wly opened \214le)-.25 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 56)162.62 F 0 Cg EP %%Page: 57 57 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .409 (descriptors whose)128 84 R/F1 10/Courier@0 SF(fileno)2.909 E F0 2.909 (sa)C(re)-2.909 E/F2 10/Times-Italic@0 SF(higher)2.909 E F0 .409 (than the current v)2.909 F .409(alue of $^F \(by def)-.25 F .408 (ault 2 for)-.1 F F1(STDERR)2.908 E F0 2.908(\). See)B -.74(``)128 96 S ($^F').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E (pop)108 112.8 Q/F3 9/Times-Roman@0 SF(ARRA)2.5 E(Y)-.945 E F0(pop)108 124.8 Q F3(EXPR)2.5 E F0(pop)108 136.8 Q(Pops and returns the last v)128 136.8 Q(alue of the array)-.25 E 2.5(,s)-.65 G (hortening the array by one element.)-2.5 E 1.186 (Returns the unde\214ned v)128 154.8 R 1.186(alue if the array is empty) -.25 F 3.686(,a)-.65 G 1.187 (lthough this may also happen at other times.)-3.686 F(If)6.187 E F3 (ARRA)128 166.8 Q(Y)-.945 E F0 .765(is omitted, pops the)3.265 F F1 (@ARGV)3.265 E F0 .765(array in the main program, b)3.265 F .765(ut the) -.2 F F1(@_)3.265 E F0 .765(array in subroutines, just)3.265 F(lik)128 178.8 Q(e)-.1 E F1(shift)2.5 E F0(.)A 1.31(Starting with Perl 5.14,)128 196.8 R F1(pop)3.81 E F0 1.31(can tak)3.81 F 3.81(eas)-.1 G(calar)-3.81 E F3(EXPR)3.81 E F0 3.81(,w)C 1.311 (hich must hold a reference to an unblessed)-3.81 F(array)128 208.8 Q 6.647(.T)-.65 G 1.647(he ar)-6.647 F 1.646 (gument will be dereferenced automatically)-.18 F 6.646(.T)-.65 G 1.646 (his aspect of)-6.646 F F1(pop)4.146 E F0 1.646(is considered highly) 4.146 F -.15(ex)128 220.8 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(pos)108 237.6 Q F3(SCALAR)2.5 E F0(pos)108 249.6 Q .315 (Returns the of)128 249.6 R .315(fset of where the last)-.25 F F1(m//g) 2.816 E F0 .316(search left of)2.816 F 2.816(ff)-.25 G .316(or the v) -2.816 F .316(ariable in question \()-.25 F F1($_)A F0 .316 (is used when)2.816 F 1.555(the v)128 261.6 R 1.554 (ariable is not speci\214ed\). Note that 0 is a v)-.25 F 1.554 (alid match of)-.25 F(fset.)-.25 E F1(undef)4.054 E F0 1.554 (indicates that the search)4.054 F .709 (position is reset \(usually due to match f)128 273.6 R .709(ailure, b) -.1 F .71(ut can also be because no match has yet been run on)-.2 F (the scalar\).)128 285.6 Q F1(pos)128 303.6 Q F0 .683 (directly accesses the location used by the re)3.183 F(ge)-.15 E .683 (xp engine to store the of)-.15 F .683(fset, so assigning to)-.25 F F1 (pos)3.182 E F0 .726(will change that of)128 315.6 R .726 (fset, and so will also in\215uence the)-.25 F F1(\\G)3.226 E F0 .726 (zero-width assertion in re)3.226 F .726(gular e)-.15 F(xpressions.)-.15 E .788(Both of these ef)128 327.6 R .788(fects tak)-.25 F 3.287(ep)-.1 G .787(lace for the ne)-3.287 F .787(xt match, so you can')-.15 F 3.287 (ta)-.18 G -.25(ff)-3.287 G .787(ect the position with).25 F F1(pos) 3.287 E F0(during)3.287 E(the current match, such as in)128 339.6 Q F1 (\(?{pos\(\) = 5}\))2.5 E F0(or)2.5 E F1(s//pos\(\) = 5/e)2.5 E F0(.)A (Setting)128 357.6 Q F1(pos)5.392 E F0 2.892(also resets the)5.392 F F2 (matc)5.392 E 2.892(hed with zer)-.15 F(o-length)-.45 E F0 2.893 (\215ag, described under `)5.393 F 2.893(`Repeated P)-.74 F(atterns)-.15 E(Matching a Zero-length Substring')128 369.6 Q 2.5('i)-.74 G 2.5(np) -2.5 G(erlre.)-2.5 E 1.019(Because a f)128 387.6 R(ailed)-.1 E F1(m//gc) 3.518 E F0 1.018(match doesn')3.518 F 3.518(tr)-.18 G 1.018(eset the of) -3.518 F 1.018(fset, the return from)-.25 F F1(pos)3.518 E F0 -.1(wo) 3.518 G(n').1 E 3.518(tc)-.18 G 1.018(hange either in)-3.518 F (this case.)128 399.6 Q(See perlre and perlop.)5 E(print)108 416.4 Q F3 .25(FILEHANDLE LIST)2.5 F F0(print)108 428.4 Q F3(FILEHANDLE)2.5 E F0 (print)108 440.4 Q F3(LIST)2.5 E F0(print)108 452.4 Q .747 (Prints a string or a list of strings.)128 464.4 R .747 (Returns true if successful.)5.747 F F3(FILEHANDLE)5.747 E F0 .747 (may be a scalar v)3.247 F(ariable)-.25 E 1.85(containing the name of o\ r a reference to the \214lehandle, thus introducing one le)128 476.4 R -.15(ve)-.25 G 4.35(lo).15 G 4.35(fi)-4.35 G(ndirection.)-4.35 E(\()128 488.4 Q F3(NO)A(TE:)-.36 E F0(If)3.959 E F3(FILEHANDLE)3.959 E F0 1.459 (is a v)3.959 F 1.459(ariable and the ne)-.25 F 1.459(xt tok)-.15 F 1.459(en is a term, it may be misinterpreted as an)-.1 F 2.3 (operator unless you interpose a)128 500.4 R F1(+)4.8 E F0 2.3 (or put parentheses around the ar)4.8 F 2.3(guments.\) If)-.18 F F3 (FILEHANDLE)4.8 E F0(is)4.8 E .949 (omitted, prints to the last selected \(see `)128 512.4 R(`select')-.74 E .949('\) output handle.)-.74 F(If)5.949 E F3(LIST)3.449 E F0 .949 (is omitted, prints)3.449 F F1($_)3.449 E F0 .949(to the)3.449 F .22 (currently selected output handle.)128 524.4 R 1.82 -.8(To u)5.22 H(se) .8 E F3(FILEHANDLE)2.72 E F0 .219(alone to print the content of)2.72 F F1($_)2.719 E F0 .219(to it, you must)2.719 F 2.165 (use a real \214lehandle lik)128 536.4 R(e)-.1 E F1(FH)4.665 E F0 4.665 (,n)C 2.165(ot an indirect one lik)-4.665 F(e)-.1 E F1($fh)4.666 E F0 7.166(.T)C 4.666(os)-7.966 G 2.166(et the def)-4.666 F 2.166 (ault output handle to)-.1 F(something other than)128 548.4 Q F3(STDOUT) 2.5 E F0 2.5(,u)C(se the select operation.)-2.5 E .079(The current v)128 566.4 R .079(alue of)-.25 F F1($,)2.579 E F0 .079(\(if an)2.579 F .079 (y\) is printed between each)-.15 F F3(LIST)2.579 E F0 2.578(item. The) 2.578 F .078(current v)2.578 F .078(alue of)-.25 F F1($\\)2.578 E F0 .078(\(if an)2.578 F .078(y\) is)-.15 F 1.423(printed after the entire) 128 578.4 R F3(LIST)3.923 E F0 1.424(has been printed.)3.923 F 1.424 (Because print tak)6.424 F 1.424(es a)-.1 F F3(LIST)3.924 E F0 3.924(,a) C -.15(ny)-3.924 G 1.424(thing in the).15 F F3(LIST)3.924 E F0(is)3.924 E -.25(eva)128 590.4 S .486(luated in list conte).25 F .486 (xt, including an)-.15 F 2.985(ys)-.15 G .485 (ubroutines whose return lists you pass to)-2.985 F F1(print)2.985 E F0 5.485(.B)C 2.985(ec)-5.485 G(areful)-2.985 E 2.275(not to follo)128 602.4 R 4.775(wt)-.25 G 2.275(he print k)-4.775 F -.15(ey)-.1 G -.1(wo) .15 G 2.275(rd with a left parenthesis unless you w).1 F 2.276 (ant the corresponding right)-.1 F .293(parenthesis to terminate the ar) 128 614.4 R .292(guments to the print; put parentheses around all ar) -.18 F .292(guments \(or interpose)-.18 F(a)128 626.4 Q F1(+)2.5 E F0 2.5(,b)C(ut that doesn')-2.7 E 2.5(tl)-.18 G(ook as good\).)-2.5 E .191 (If you')128 644.4 R .191 (re storing handles in an array or hash, or in general whene)-.5 F -.15 (ve)-.25 G 2.691(ry).15 G(ou')-2.691 E .191(re using an)-.5 F 2.692(ye) -.15 G .192(xpression more)-2.842 F(comple)128 656.4 Q 2.532(xt)-.15 G .032(han a bare)-2.532 F -.1(wo)-.25 G .031 (rd handle or a plain, unsubscripted scalar v).1 F .031 (ariable to retrie)-.25 F .331 -.15(ve i)-.25 H .031(t, you will ha).15 F .331 -.15(ve t)-.2 H(o).15 E(use a block returning the \214lehandle v) 128 668.4 Q(alue instead, in which case the)-.25 E F3(LIST)2.5 E F0 (may not be omitted:)2.5 E F1(print { $files[$i] } "stuff\\n";)152 686.4 Q(print { $OK ? STDOUT : STDERR } "stuff\\n";)152 698.4 Q F0 1.437 (Printing to a closed pipe or sock)128 716.4 R 1.437(et will generate a) -.1 F F3(SIGPIPE)3.937 E F0 3.937(signal. See)3.937 F 1.437 (perlipc for more on signal)3.937 F(handling.)128 728.4 Q(perl v5.14.2) 72 768 Q 198.17(2011-10-01 57)162.62 F 0 Cg EP %%Page: 58 58 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(printf)108 84 Q/F1 9/Times-Roman@0 SF .25(FILEHANDLE FORMA)2.5 F(T)-.999 E F0(,)A F1(LIST) 2.5 E F0(printf)108 96 Q F1(FILEHANDLE)2.5 E F0(printf)108 108 Q F1 (FORMA)2.5 E(T)-.999 E F0(,)A F1(LIST)2.5 E F0(printf)108 120 Q(Equi)128 132 Q -.25(va)-.25 G 1.933(lent to).25 F/F2 10/Courier@0 SF 1.933 (print FILEHANDLE sprintf\(FORMAT, LIST\))4.433 F F0 4.433(,e)C 1.933 (xcept that)-4.583 F F2($\\)4.433 E F0 1.933(\(the output)4.433 F 1.085 (record separator\) is not appended.)128 144 R 1.085(The \214rst ar) 6.085 F 1.085(gument of the list will be interpreted as the)-.18 F F2 (printf)3.585 E F0 .471(format. See)128 156 R F2(sprintf)2.97 E F0 .47 (for an e)2.97 F .47(xplanation of the format ar)-.15 F 7.97(gument. If) -.18 F .47(you omit the)2.97 F F1(LIST)2.97 E F0(,)A F2($_)2.97 E F0 .47 (is used;)2.97 F .846(to use)128 168 R F1(FILEHANDLE)3.346 E F0 .846 (without a)3.346 F F1(LIST)3.347 E F0 3.347(,y)C .847 (ou must use a real \214lehandle lik)-3.347 F(e)-.1 E F2(FH)3.347 E F0 3.347(,n)C .847(ot an indirect one lik)-3.347 F(e)-.1 E F2($fh)128 180 Q F0 5.447(.I)C(f)-5.447 E F2 .447(use locale)2.947 F F0 .446(is in ef) 2.947 F .446(fect and)-.25 F/F3 10/Times-Italic@0 SF (POSIX::setlocale\(\))2.946 E F0 .446 (has been called, the character used for the)2.946 F .562 (decimal separator in formatted \215oating-point numbers is af)128 192 R .563(fected by the)-.25 F F1(LC_NUMERIC)3.063 E F0 .563(locale setting.) 3.063 F(See perllocale and)128 204 Q F1(POSIX)2.5 E F0(.)A(Don')128 222 Q 3.69(tf)-.18 G 1.19(all into the trap of using a)-3.79 F F2(printf) 3.69 E F0 1.189(when a simple)3.689 F F2(print)3.689 E F0 -.1(wo)3.689 G 1.189(uld do.).1 F(The)6.189 E F2(print)3.689 E F0 1.189(is more)3.689 F (ef)128 234 Q(\214cient and less error prone.)-.25 E(prototype)108 250.8 Q F1(FUNCTION)2.5 E F0 2.992 (Returns the prototype of a function as a string \(or)128 262.8 R F2 (undef)5.493 E F0 2.993(if the function has no prototype\).)5.493 F F1 (FUNCTION)128 274.8 Q F0 (is a reference to, or the name of, the function whose prototype you w) 2.5 E(ant to retrie)-.1 E -.15(ve)-.25 G(.).15 E(If)128 292.8 Q F1 (FUNCTION)3.418 E F0 .918(is a string starting with)3.418 F F2(CORE::) 3.417 E F0 3.417(,t)C .917(he rest is tak)-3.417 F .917 (en as a name for a Perl b)-.1 F 3.417(uiltin. If)-.2 F(the)3.417 E -.2 (bu)128 304.8 S 1.515(iltin is not).2 F F3 -.1(ov)4.015 G(erridable).1 E F0 1.515(\(such as)4.015 F F2(qw//)4.015 E F0 4.015(\)o)C 4.015(ri) -4.015 G 4.015(fi)-4.015 G 1.515(ts ar)-4.015 F 1.515 (guments cannot be adequately e)-.18 F 1.515(xpressed by a)-.15 F .993 (prototype \(such as)128 316.8 R F2(system)3.493 E F0(\),)A F3(pr)3.493 E(ototype\(\))-.45 E F0(returns)3.492 E F2(undef)3.492 E F0 3.492(,b)C .992(ecause the b)-3.492 F .992(uiltin does not really beha)-.2 F -.15 (ve)-.2 G(lik)128 328.8 Q 2.5(eaP)-.1 G(erl function.)-2.5 E (Otherwise, the string describing the equi)5 E -.25(va)-.25 G (lent prototype is returned.).25 E(push)108 345.6 Q F1(ARRA)2.5 E(Y) -.945 E F0(,LIST)A(push)108 357.6 Q F1(EXPR)2.5 E F0(,LIST)A -.35(Tr)128 369.6 S(eats).35 E F1(ARRA)2.59 E(Y)-.945 E F0 .09 (as a stack by appending the v)2.59 F .09(alues of)-.25 F F1(LIST)2.59 E F0 .09(to the end of)2.59 F F1(ARRA)2.591 E(Y)-.945 E F0 5.091(.T)C .091 (he length of)-5.091 F F1(ARRA)2.591 E(Y)-.945 E F0 (increases by the length of)128 381.6 Q F1(LIST)2.5 E F0 5(.H)C (as the same ef)-5 E(fect as)-.25 E F2(for $value \(LIST\) {)152 399.6 Q ($ARRAY[++$#ARRAY] = $value;)176 411.6 Q(})152 423.6 Q F0 -.2(bu)128 441.6 S 2.5(ti).2 G 2.5(sm)-2.5 G(ore ef)-2.5 E 2.5(\214cient. Returns) -.25 F(the number of elements in the array follo)2.5 E (wing the completed)-.25 E F2(push)2.5 E F0(.)A .958 (Starting with Perl 5.14,)128 459.6 R F2(push)3.458 E F0 .958(can tak) 3.458 F 3.458(ea)-.1 G(scalar)-.001 E F1(EXPR)3.457 E F0 3.457(,w)C .957 (hich must hold a reference to an unblessed)-3.457 F(array)128 471.6 Q 6.184(.T)-.65 G 1.184(he ar)-6.184 F 1.184 (gument will be dereferenced automatically)-.18 F 6.185(.T)-.65 G 1.185 (his aspect of)-6.185 F F2(push)3.685 E F0 1.185(is considered highly) 3.685 F -.15(ex)128 483.6 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(q/STRING/)108 500.4 Q(qq/STRING/)108 512.4 Q(qx/STRING/)108 524.4 Q(qw/STRING/)108 536.4 Q(Generalized quotes.)128 548.4 Q(See `)5 E (`Quote-Lik)-.74 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np) -2.5 G(erlop.)-2.5 E(qr/STRING/)108 565.2 Q(Re)128 577.2 Q(ge)-.15 E (xp-lik)-.15 E 2.5(eq)-.1 G 2.5(uote. See)-2.5 F -.74(``)2.5 G(Re).74 E (ge)-.15 E(xp Quote-Lik)-.15 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E(quotemeta)108 594 Q F1(EXPR)2.5 E F0 (quotemeta)108 606 Q .874(Returns the v)128 618 R .874(alue of)-.25 F F1 (EXPR)3.374 E F0 .873(with all non\255`)3.373 F(`w)-.74 E(ord')-.1 E 3.373('c)-.74 G .873(haracters backslashed.)-3.373 F .873 (\(That is, all characters not)5.873 F(matching)128 630 Q F2 (/[A\255Za\255z_0\2559]/)3.776 E F0 1.277 (will be preceded by a backslash in the returned string, re)3.777 F -.05 (ga)-.15 G 1.277(rdless of).05 F(an)128 642 Q 4.801(yl)-.15 G 2.301 (ocale settings.\))-4.801 F 2.301 (This is the internal function implementing the)7.301 F F2(\\Q)4.801 E F0 2.3(escape in double-quoted)4.8 F(strings.)128 654 Q(If)128 672 Q F1 (EXPR)2.5 E F0(is omitted, uses)2.5 E F2($_)2.5 E F0(.)A .875 (quotemeta \(and)128 690 R F2(\\Q)3.375 E F0(...)3.375 E F2(\\E)3.375 E F0 3.376(\)a)C .876(re useful when interpolating strings into re)-3.376 F .876(gular e)-.15 F .876(xpressions, because by)-.15 F(def)128 702 Q (ault an interpolated v)-.1 E(ariable will be considered a mini-re)-.25 E(gular e)-.15 E(xpression. F)-.15 E(or e)-.15 E(xample:)-.15 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 58)162.62 F 0 Cg EP %%Page: 59 59 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (my $sentence = \010The quick brown fox jumped over the lazy dog\010;) 152 84 Q(my $substring = \010quick.*?fox\010;)152 96 Q ($sentence =~ s{$substring}{big bad wolf};)152 108 Q F0 -.4(Wi)128 126 S (ll cause).4 E F1($sentence)2.5 E F0(to become)2.5 E F1 (\010The big bad wolf jumped over...\010)2.5 E F0(.)A (On the other hand:)128 144 Q F1 (my $sentence = \010The quick brown fox jumped over the lazy dog\010;) 152 162 Q(my $substring = \010quick.*?fox\010;)152 174 Q ($sentence =~ s{\\Q$substring\\E}{big bad wolf};)152 186 Q F0(Or:)128 204 Q F1 (my $sentence = \010The quick brown fox jumped over the lazy dog\010;) 152 222 Q(my $substring = \010quick.*?fox\010;)152 234 Q (my $quoted_substring = quotemeta\($substring\);)152 246 Q ($sentence =~ s{$quoted_substring}{big bad wolf};)152 258 Q F0 -.4(Wi) 128 276 S 2.48(ll both lea).4 F 2.78 -.15(ve t)-.2 H 2.48 (he sentence as is. Normally).15 F 4.979(,w)-.65 G 2.479 (hen accepting literal string input from the user)-4.979 F(,)-.4 E/F2 10 /Times-Italic@0 SF(quotemeta\(\))128 288 Q F0(or)2.5 E F1(\\Q)2.5 E F0 (must be used.)2.5 E .334 (In Perl 5.14, all characters whose code points are abo)128 306 R .634 -.15(ve 1)-.15 H .335(27 are not quoted in UTF8\255encoded strings,).15 F -.2(bu)128 318 S 3.222(ta).2 G .722(ll are quoted in)-3.222 F/F3 9 /Times-Roman@0 SF(UTF\2558)3.222 E F0 3.222(strings. It)3.222 F .722 (is planned to change this beha)3.222 F .721(vior in 5.16, b)-.2 F .721 (ut the e)-.2 F .721(xact rules)-.15 F(ha)128 330 Q -.15(ve)-.2 G(n').15 E 2.5(tb)-.18 G(een determined yet.)-2.5 E(rand)108 346.8 Q F3(EXPR)2.5 E F0(rand)108 358.8 Q .018 (Returns a random fractional number greater than or equal to)128 370.8 R F1(0)2.518 E F0 .018(and less than the v)2.518 F .018(alue of)-.25 F F3 (EXPR)2.518 E F0 5.018(.\()C F3(EXPR)-5.018 E F0 .434(should be positi) 128 382.8 R -.15(ve)-.25 G 2.934(.\) If).15 F F3(EXPR)2.934 E F0 .434 (is omitted, the v)2.934 F(alue)-.25 E F1(1)2.934 E F0 .434(is used.) 2.934 F(Currently)5.434 E F3(EXPR)2.934 E F0 .434(with the v)2.934 F (alue)-.25 E F1(0)2.933 E F0 .433(is also)2.933 F .013(special-cased as) 128 394.8 R F1(1)2.513 E F0 .013(\(this w)2.513 F .014 (as undocumented before Perl 5.8.0 and is subject to change in future v) -.1 F(ersions)-.15 E(of Perl\).)128 406.8 Q(Automatically calls)5 E F1 (srand)2.5 E F0(unless)2.5 E F1(srand)2.5 E F0(has already been called.) 2.5 E(See also)5 E F1(srand)2.5 E F0(.)A(Apply)128 424.8 Q F1(int\(\)) 4.437 E F0 1.937(to the v)4.437 F 1.937(alue returned by)-.25 F F1 (rand\(\))4.437 E F0 1.937(if you w)4.437 F 1.936(ant random inte)-.1 F 1.936(gers instead of random)-.15 F(fractional numbers.)128 436.8 Q -.15 (Fo)5 G 2.5(re).15 G(xample,)-2.65 E F1(int\(rand\(10\)\))152 454.8 Q F0 (returns a random inte)128 472.8 Q(ger between)-.15 E F1(0)2.5 E F0(and) 2.5 E F1(9)2.5 E F0 2.5(,i)C(nclusi)-2.5 E -.15(ve)-.25 G(.).15 E 1.234 (\(Note: If your rand function consistently returns numbers that are to\ o lar)128 490.8 R 1.234(ge or too small, then your)-.18 F -.15(ve)128 502.8 S(rsion of Perl w).15 E (as probably compiled with the wrong number of)-.1 E F3(RANDBITS)2.5 E F0(.\))A/F4 10/Courier-Bold@0 SF(rand\(\))128 520.8 Q/F5 10/Times-Bold@0 SF 3.649(is not cryptographically secur)6.149 F 6.148(e. Y)-.18 F 3.648 (ou should not r)-1.11 F 3.648(ely on it in security-sensiti)-.18 F -.1 (ve)-.1 G(situations.)128 532.8 Q F0 .037 (As of this writing, a number of third-party)5.036 F F3(CP)2.537 E(AN) -.828 E F0 .037(modules of)2.537 F .037(fer random number generators) -.25 F 5.011(intended by their authors to be cryptographically secure, \ including: Math::Random::Secure,)128 544.8 R(Math::Random::MT)128 556.8 Q(::Perl, and Math::T)-.5 E(rulyRandom.)-.35 E(read)108 573.6 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH,OFFSET)A(read)108 585.6 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH)A .443(Attempts to read)128 597.6 R F3(LENGTH)2.943 E F2 -.15(ch)2.943 G(ar).15 E(acter)-.15 E(s)-.1 E F0 .443(of data into v)2.943 F(ariable)-.25 E F3(SCALAR)2.944 E F0 .444 (from the speci\214ed)2.944 F F3(FILEHANDLE)2.944 E F0(.)A .589 (Returns the number of characters actually read,)128 609.6 R F1(0)3.089 E F0 .588(at end of \214le, or undef if there w)3.089 F .588 (as an error \(in the)-.1 F .472(latter case)128 621.6 R F1($!)2.972 E F0 .473(is also set\).)2.973 F F3(SCALAR)5.473 E F0 .473(will be gro) 2.973 F .473(wn or shrunk so that the last character actually read is) -.25 F(the last character of the scalar after the read.)128 633.6 Q(An) 128 651.6 Q F3(OFFSET)4.883 E F0 2.383(may be speci\214ed to place the \ read data at some place in the string other than the)4.883 F(be)128 663.6 Q 3.056(ginning. A)-.15 F(ne)3.056 E -.05(ga)-.15 G(ti).05 E -.15 (ve)-.25 G F3(OFFSET)3.207 E F0 .557(speci\214es placement at that man) 3.057 F 3.057(yc)-.15 G .557(haracters counting backw)-3.057 F .557 (ards from)-.1 F .215(the end of the string.)128 675.6 R 2.715(Ap)5.215 G(ositi)-2.715 E -.15(ve)-.25 G F3(OFFSET)2.865 E F0 .215 (greater than the length of)2.715 F F3(SCALAR)2.715 E F0 .214 (results in the string being)2.715 F(padded to the required size with) 128 687.6 Q F1("\\0")2.5 E F0 (bytes before the result of the read is appended.)2.5 E .295 (The call is implemented in terms of either Perl')128 705.6 R 2.795(so) -.55 G 2.795(ry)-2.795 G .295(our system')-2.795 F 2.795(sn)-.55 G(ati) -2.795 E -.15(ve)-.25 G F2(fr)2.946 E(ead)-.37 E F0 .296 (\(3\) library function.)1.666 F -.8(To)5.296 G(get a true)128 717.6 Q F2 -.37(re)2.5 G(ad).37 E F0(\(2\) system call, see)1.666 E F1(sysread) 2.5 E F0(.)A(perl v5.14.2)72 768 Q 198.17(2011-10-01 59)162.62 F 0 Cg EP %%Page: 60 60 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.049(Note the)128 84 R/F1 10/Times-Italic@0 SF -.15(ch)3.549 G(ar).15 E(acter)-.15 E(s)-.1 E F0 3.549(:d)C 1.049(epending on the status of the \214lehandle, eithe\ r \(8\255bit\) bytes or characters are)-3.549 F 3.421(read. By)128 96 R (def)3.421 E .922(ault, all \214lehandles operate on bytes, b)-.1 F .922 (ut for e)-.2 F .922(xample if the \214lehandle has been opened)-.15 F 2.49(with the)128 108 R/F2 10/Courier@0 SF(:utf8)4.99 E F0 2.49 (I/O layer \(see `)4.99 F(`open')-.74 E 2.49(', and the)-.74 F F2(open) 4.99 E F0 2.49(pragma, open\), the I/O will operate on)4.99 F 1.29 (UTF8\255encoded Unicode characters, not bytes.)128 120 R 1.29 (Similarly for the)6.29 F F2(:encoding)3.79 E F0 1.29 (pragma: in that case)3.79 F(pretty much an)128 132 Q 2.5(yc)-.15 G (haracters can be read.)-2.5 E(readdir)108 148.8 Q/F3 9/Times-Roman@0 SF (DIRHANDLE)2.5 E F0 .77(Returns the ne)128 160.8 R .77 (xt directory entry for a directory opened by)-.15 F F2(opendir)3.269 E F0 5.769(.I)C 3.269(fu)-5.769 G .769(sed in list conte)-3.269 F .769 (xt, returns)-.15 F .683(all the rest of the entries in the directory) 128 172.8 R 5.684(.I)-.65 G 3.184(ft)-5.684 G .684 (here are no more entries, returns the unde\214ned v)-3.184 F .684 (alue in)-.25 F(scalar conte)128 184.8 Q (xt and the empty list in list conte)-.15 E(xt.)-.15 E .143(If you')128 202.8 R .143(re planning to \214letest the return v)-.5 F .143 (alues out of a)-.25 F F2(readdir)2.643 E F0 2.643(,y)C(ou')-2.643 E 2.643(db)-.5 G .143(etter prepend the directory in)-2.643 F 2.5 (question. Otherwise,)128 214.8 R(because we didn')2.5 E(t)-.18 E F2 (chdir)2.5 E F0(there, it w)2.5 E(ould ha)-.1 E .3 -.15(ve b)-.2 H (een testing the wrong \214le.).15 E F2 (opendir\(my $dh, $some_dir\) || die "can\010t opendir $some_dir: $!";) 152 232.8 Q (@dots = grep { /^\\./ && \255f "$some_dir/$_" } readdir\($dh\);)152 244.8 Q(closedir $dh;)152 256.8 Q F0 (As of Perl 5.11.2 you can use a bare)128 274.8 Q F2(readdir)2.5 E F0 (in a)2.5 E F2(while)2.5 E F0(loop, which will set)2.5 E F2($_)2.5 E F0 (on e)2.5 E -.15(ve)-.25 G(ry iteration.).15 E F2 (opendir\(my $dh, $some_dir\) || die;)152 292.8 Q (while\(readdir $dh\) {)152 304.8 Q(print "$some_dir/$_\\n";)176 316.8 Q (})152 328.8 Q(closedir $dh;)152 340.8 Q F0(readline)108 357.6 Q F3 (EXPR)2.5 E F0(readline)108 369.6 Q 1.879 (Reads from the \214lehandle whose type)128 381.6 R 1.879 (glob is contained in)-.15 F F3(EXPR)4.379 E F0 1.879(\(or from)4.379 F F2(*ARGV)4.379 E F0(if)4.379 E F3(EXPR)4.379 E F0 1.879(is not)4.379 F (pro)128 393.6 Q 4.244(vided\). In)-.15 F 1.744(scalar conte)4.244 F 1.744(xt, each call reads and returns the ne)-.15 F 1.744 (xt line until end-of-\214le is reached,)-.15 F .892 (whereupon the subsequent call returns)128 405.6 R F2(undef)3.393 E F0 5.893(.I)C 3.393(nl)-5.893 G .893(ist conte)-3.393 F .893 (xt, reads until end-of-\214le is reached and)-.15 F .212 (returns a list of lines.)128 417.6 R .212(Note that the notion of `) 5.212 F(`line')-.74 E 2.712('u)-.74 G .211(sed here is whate)-2.712 F -.15(ve)-.25 G 2.711(ry).15 G .211(ou may ha)-2.711 F .511 -.15(ve d)-.2 H .211(e\214ned with).15 F F2($/)128 429.6 Q F0(or)2.5 E F2 ($INPUT_RECORD_SEPARATOR)2.5 E F0 2.5(\). See)B -.74(``)2.5 G($/').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E(When)128 447.6 Q F2($/)3.162 E F0 .662(is set to)3.162 F F2(undef)3.162 E F0 3.162(,w)C(hen)-3.162 E F2(readline)3.162 E F0 .662(is in scalar conte) 3.162 F .663(xt \(i.e., \214le slurp mode\), and when an)-.15 F (empty \214le is read, it returns)128 459.6 Q F2<0808>2.5 E F0 (the \214rst time, follo)2.5 E(wed by)-.25 E F2(undef)2.5 E F0 (subsequently)2.5 E(.)-.65 E 1.597 (This is the internal function implementing the)128 477.6 R F2() 4.097 E F0(operator)4.097 E 4.097(,b)-.4 G 1.596 (ut you can use it directly)-4.297 F 6.596(.T)-.65 G(he)-6.596 E F2 ()128 489.6 Q F0(operator is discussed in more detail in `)2.5 E (`I/O Operators')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E F2 ($line = ;)152 507.6 Q($line = readline\(*STDIN\);)152 519.6 Q 6 (#s)24 G(ame thing)-6 E F0(If)128 537.6 Q F2(readline)4.482 E F0 1.982 (encounters an operating system error)4.482 F(,)-.4 E F2($!)4.482 E F0 1.982(will be set with the corresponding error)4.482 F 2.654 (message. It)128 549.6 R .154(can be helpful to check)2.654 F F2($!) 2.653 E F0 .153(when you are reading from \214lehandles you don')2.653 F 2.653(tt)-.18 G .153(rust, such as)-2.653 F 2.608(at)128 561.6 S .108 (ty or a sock)-2.608 F 2.608(et. The)-.1 F(follo)2.608 E .108(wing e) -.25 F .108(xample uses the operator form of)-.15 F F2(readline)2.609 E F0 .109(and dies if the result is)2.609 F(not de\214ned.)128 573.6 Q F2 (while \( ! eof\($fh\) \) {)152 591.6 Q (defined\( $_ = <$fh> \) or die "readline failed: $!";)176 603.6 Q(...) 176 615.6 Q(})152 627.6 Q F0 .982(Note that you ha)128 645.6 R 1.282 -.15(ve c)-.2 H(an').15 E 3.481(th)-.18 G(andle)-3.481 E F2(readline) 3.481 E F0 .981(errors that w)3.481 F .981(ay with the)-.1 F F2(ARGV) 3.481 E F0 .981(\214lehandle. In that case,)3.481 F(you ha)128 657.6 Q .3 -.15(ve t)-.2 H 2.5(oo).15 G(pen each element of)-2.5 E F2(@ARGV)2.5 E F0(yourself since)2.5 E F2(eof)2.5 E F0(handles)2.5 E F2(ARGV)2.5 E F0 (dif)2.5 E(ferently)-.25 E(.)-.65 E F2(foreach my $arg \(@ARGV\) {)152 675.6 Q(open\(my $fh, $arg\) or warn "Can\010t open $arg: $!";)176 687.6 Q(while \( ! eof\($fh\) \) {)176 711.6 Q(defined\( $_ = <$fh> \))200 723.6 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 60)162.62 F 0 Cg EP %%Page: 61 61 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (or die "readline failed for $arg: $!";)224 84 Q(...)200 96 Q(})176 108 Q(})152 120 Q F0(readlink)108 136.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0(readlink)108 148.8 Q .062(Returns the v)128 160.8 R .062 (alue of a symbolic link, if symbolic links are implemented.)-.25 F .063 (If not, raises an e)5.063 F 2.563(xception. If)-.15 F (there is a system error)128 172.8 Q 2.5(,r)-.4 G (eturns the unde\214ned v)-2.5 E(alue and sets)-.25 E F1($!)2.5 E F0 2.5 (\(errno\). If)2.5 F F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A(readpipe)108 189.6 Q F2(EXPR)2.5 E F0(readpipe)108 201.6 Q F2 (EXPR)128 213.6 Q F0 .735(is e)3.236 F -.15(xe)-.15 G .735 (cuted as a system command.).15 F .735 (The collected standard output of the command is returned.)5.735 F .35 (In scalar conte)128 225.6 R .35 (xt, it comes back as a single \(potentially multi-line\) string.)-.15 F .35(In list conte)5.35 F .35(xt, returns a list)-.15 F 1.76 (of lines \(ho)128 237.6 R(we)-.25 E -.15(ve)-.25 G 4.259(ry).15 G(ou') -4.259 E 2.059 -.15(ve d)-.5 H 1.759(e\214ned lines with).15 F F1($/) 4.259 E F0(or)4.259 E F1($INPUT_RECORD_SEPARATOR)4.259 E F0 4.259 (\). This)B 1.759(is the)4.259 F .432 (internal function implementing the)128 249.6 R F1(qx/EXPR/)2.932 E F0 (operator)2.932 E 2.932(,b)-.4 G .432(ut you can use it directly)-3.132 F 5.433(.T)-.65 G(he)-5.433 E F1(qx/EXPR/)2.933 E F0 (operator is discussed in more detail in `)128 261.6 Q(`I/O Operators') -.74 E 2.5('i)-.74 G 2.5(np)-2.5 G 2.5(erlop. If)-2.5 F F2(EXPR)2.5 E F0 (is omitted, uses)2.5 E F1($_)2.5 E F0(.)A(recv)108 278.4 Q F2(SOCKET) 2.5 E F0(,SCALAR,LENGTH,FLA)A(GS)-.4 E(Recei)128 290.4 Q -.15(ve)-.25 G 5.082(sam).15 G 2.582(essage on a sock)-5.082 F 5.081(et. Attempts)-.1 F 2.581(to recei)5.081 F -.15(ve)-.25 G F2(LENGTH)5.231 E F0 2.581 (characters of data into v)5.081 F(ariable)-.25 E F2(SCALAR)128 302.4 Q F0 2.035(from the speci\214ed)4.534 F F2(SOCKET)4.535 E F0 (\214lehandle.)4.535 E F2(SCALAR)7.035 E F0 2.035(will be gro)4.535 F 2.035(wn or shrunk to the length)-.25 F .783(actually read.)128 314.4 R -.8(Ta)5.783 G -.1(ke).8 G 3.283(st).1 G .783 (he same \215ags as the system call of the same name.)-3.283 F .782 (Returns the address of the)5.783 F 1.822(sender if)128 326.4 R F2 (SOCKET)4.322 E F0 2.922 -.55('s p)D 1.822 (rotocol supports this; returns an empty string otherwise.).55 F 1.822 (If there')6.822 F 4.322(sa)-.55 G 4.323(ne)-4.322 G(rror)-4.323 E(,)-.4 E 1.196(returns the unde\214ned v)128 338.4 R 3.696(alue. This)-.25 F 1.195(call is actually implemented in terms of)3.695 F/F3 10 /Times-Italic@0 SF -.37(re)3.695 G(cvfr).37 E(om)-.45 E F0 1.195 (\(2\) system call.)1.666 F(See `)128 350.4 Q(`)-.74 E F2(UDP:)A F0 (Message P)2.5 E(assing')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlipc for e)-2.5 E(xamples.)-.15 E 1.981(Note the)128 368.4 R F3 -.15 (ch)4.481 G(ar).15 E(acter)-.15 E(s)-.1 E F0 4.481(:d)C 1.981 (epending on the status of the sock)-4.481 F 1.982 (et, either \(8\255bit\) bytes or characters are)-.1 F(recei)128 380.4 Q -.15(ve)-.25 G 2.522(d. By).15 F(def)2.522 E .022(ault all sock)-.1 F .021(ets operate on bytes, b)-.1 F .021(ut for e)-.2 F .021 (xample if the sock)-.15 F .021(et has been changed using)-.1 F F3 (binmode\(\))128 392.4 Q F0 .695(to operate with the)3.195 F F1 (:encoding\(utf8\))3.196 E F0 .696(I/O layer \(see the)3.196 F F1(open) 3.196 E F0 .696(pragma, open\), the I/O)3.196 F .04 (will operate on UTF8\255encoded Unicode characters, not bytes.)128 404.4 R .04(Similarly for the)5.04 F F1(:encoding)2.54 E F0(pragma:)2.54 E(in that case pretty much an)128 416.4 Q 2.5(yc)-.15 G (haracters can be read.)-2.5 E(redo)108 433.2 Q F2(LABEL)2.5 E F0(redo) 108 445.2 Q(The)128 457.2 Q F1(redo)2.523 E F0 .024 (command restarts the loop block without e)2.523 F -.25(va)-.25 G .024 (luating the conditional ag).25 F 2.524(ain. The)-.05 F F1(continue) 2.524 E F0 .146(block, if an)128 469.2 R 1.446 -.65(y, i)-.15 H 2.646 (sn).65 G .146(ot e)-2.646 F -.15(xe)-.15 G 2.646(cuted. If).15 F(the) 2.646 E F2(LABEL)2.646 E F0 .146 (is omitted, the command refers to the innermost enclosing)2.646 F 2.5 (loop. Programs)128 481.2 R(that w)2.5 E(ant to lie to themselv)-.1 E (es about what w)-.15 E(as just input normally use this command:)-.1 E F1 6(#as)152 499.2 S(impleminded Pascal comment stripper)-6 E 6(#\()152 511.2 S(warning: assumes no { or } in strings\))-6 E (LINE: while \(\) {)152 523.2 Q (while \(s|\({.*}.*\){.*}|$1 |\) {})176 535.2 Q(s|{.*}| |;)176 547.2 Q (if \(s|{.*| |\) {)176 559.2 Q($front = $_;)200 571.2 Q (while \(\) {)200 583.2 Q(if \(/}/\) {)224 595.2 Q 6(#e)12 G (nd of comment?)-6 E(s|^|$front\\{|;)248 607.2 Q(redo LINE;)248 619.2 Q (})224 631.2 Q(})200 643.2 Q(})176 655.2 Q(print;)176 667.2 Q(})152 679.2 Q(redo)128 697.2 Q F0 .081 (cannot be used to retry a block that returns a v)2.58 F .081 (alue such as)-.25 F F1 .081(eval {})2.581 F F0(,)A F1 .081(sub {})2.581 F F0 2.581(,o)C(r)-2.581 E F1 .081(do {})2.581 F F0 2.581(,a)C(nd)-2.581 E(should not be used to e)128 709.2 Q(xit a)-.15 E F3(gr)2.5 E(ep\(\)) -.37 E F0(or)2.5 E F3(map\(\))2.5 E F0(operation.)2.5 E .932 (Note that a block by itself is semantically identical to a loop that e) 128 727.2 R -.15(xe)-.15 G .931(cutes once.).15 F(Thus)5.931 E F1(redo) 3.431 E F0(inside)3.431 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 61) 162.62 F 0 Cg EP %%Page: 62 62 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (such a block will ef)128 84 Q(fecti)-.25 E -.15(ve)-.25 G (ly turn it into a looping construct.).15 E(See also `)128 102 Q (`continue')-.74 E 2.5('f)-.74 G(or an illustration of ho)-2.5 E(w)-.25 E/F1 10/Courier@0 SF(last)2.5 E F0(,)A F1(next)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(redo)2.5 E F0 -.1(wo)2.5 G(rk.).1 E(ref)108 118.8 Q/F2 9 /Times-Roman@0 SF(EXPR)2.5 E F0(ref)108 130.8 Q 2.495 (Returns a non-empty string if)128 130.8 R F2(EXPR)4.996 E F0 2.496 (is a reference, the empty string otherwise. If)4.996 F F2(EXPR)4.996 E F0 2.496(is not)4.996 F(speci\214ed,)128 142.8 Q F1($_)4.808 E F0 2.307 (will be used.)4.807 F 2.307(The v)7.307 F 2.307 (alue returned depends on the type of thing the reference is a)-.25 F (reference to.)128 154.8 Q(Builtin types include:)5 E F1(SCALAR)152 172.8 Q(ARRAY)152 184.8 Q(HASH)152 196.8 Q(CODE)152 208.8 Q(REF)152 220.8 Q(GLOB)152 232.8 Q(LVALUE)152 244.8 Q(FORMAT)152 256.8 Q(IO)152 268.8 Q(VSTRING)152 280.8 Q(Regexp)152 292.8 Q F0 .757(If the reference\ d object has been blessed into a package, then that package name is ret\ urned instead.)128 310.8 R -1.1(Yo)128 322.8 S 2.5(uc)1.1 G(an think of) -2.5 E F1(ref)2.5 E F0(as a)2.5 E F1(typeof)2.5 E F0(operator)2.5 E(.) -.55 E F1(if \(ref\($r\) eq "HASH"\) {)152 340.8 Q (print "r is a reference to a hash.\\n";)176 352.8 Q(})152 364.8 Q (unless \(ref\($r\)\) {)152 376.8 Q (print "r is not a reference at all.\\n";)176 388.8 Q(})152 400.8 Q F0 .889(The return v)128 418.8 R(alue)-.25 E F1(LVALUE)3.389 E F0 .888 (indicates a reference to an lv)3.389 F .888(alue that is not a v)-.25 F .888(ariable. Y)-.25 F .888(ou get this from)-1.1 F 2.753 (taking the reference of function calls lik)128 430.8 R(e)-.1 E F1 (pos\(\))5.254 E F0(or)5.254 E F1(substr\(\))5.254 E F0(.)A F1(VSTRING) 5.254 E F0 2.754(is returned if the)5.254 F(reference points to a v)128 442.8 Q(ersion string.)-.15 E(The result)128 460.8 Q F1(Regexp)2.5 E F0 (indicates that the ar)2.5 E(gument is a re)-.18 E(gular e)-.15 E (xpression resulting from)-.15 E F1(qr//)2.5 E F0(.)A(See also perlref.) 128 478.8 Q(rename)108 495.6 Q F2(OLDN)2.5 E(AME)-.315 E F0(,NEWN)A(AME) -.35 E .919(Changes the name of a \214le; an e)128 507.6 R .919 (xisting \214le)-.15 F F2(NEWN)3.418 E(AME)-.315 E F0 .918 (will be clobbered.)3.418 F .918(Returns true for success,)5.918 F -.1 (fa)128 519.6 S(lse otherwise.).1 E(Beha)128 537.6 Q 1.281 (vior of this function v)-.2 F 1.282 (aries wildly depending on your system implementation.)-.25 F -.15(Fo) 6.282 G 3.782(re).15 G 1.282(xample, it)-3.932 F .518 (will usually not w)128 549.6 R .518 (ork across \214le system boundaries, e)-.1 F -.15(ve)-.25 G 3.018(nt) .15 G .518(hough the system)-3.018 F/F3 10/Times-Italic@0 SF(mv)3.018 E F0 .517(command sometimes)3.017 F 1.305(compensates for this.)128 561.6 R 1.306(Other restrictions include whether it w)6.305 F 1.306 (orks on directories, open \214les, or pre-)-.1 F -.15(ex)128 573.6 S .535(isting \214les.).15 F .535(Check perlport and either the)5.535 F F3 -.37(re)3.034 G(name).37 E F0 .534(\(2\) manpage or equi)1.666 F -.25 (va)-.25 G .534(lent system documentation).25 F(for details.)128 585.6 Q -.15(Fo)128 603.6 S 2.5(rap).15 G(latform independent)-2.5 E F1(move)2.5 E F0(function look at the File::Cop)2.5 E 2.5(ym)-.1 G(odule.)-2.5 E (require)108 620.4 Q F2(VERSION)2.5 E F0(require)108 632.4 Q F2(EXPR)2.5 E F0(require)108 644.4 Q .679(Demands a v)128 656.4 R .68 (ersion of Perl speci\214ed by)-.15 F F2(VERSION)3.18 E F0 3.18(,o)C 3.18(rd)-3.18 G .68(emands some semantics speci\214ed by)-3.18 F F2 (EXPR)3.18 E F0(or)3.18 E(by)128 668.4 Q F1($_)2.5 E F0(if)2.5 E F2 (EXPR)2.5 E F0(is not supplied.)2.5 E F2(VERSION)128 686.4 Q F0 .27 (may be either a numeric ar)2.771 F .27 (gument such as 5.006, which will be compared to)-.18 F F1($])2.77 E F0 2.77(,o)C 2.77(ral)-2.77 G(iteral)-2.77 E .488 (of the form v5.6.1, which will be compared to)128 698.4 R F1($^V)2.988 E F0(\(aka)2.988 E F1($PERL_VERSION)2.988 E F0 2.988(\). An)B -.15(ex) 2.988 G .488(ception is raised).15 F(if)128 710.4 Q F2(VERSION)2.639 E F0 .139(is greater than the v)2.639 F .139 (ersion of the current Perl interpreter)-.15 F 5.139(.C)-.55 G .139 (ompare with `)-5.139 F(`use')-.74 E .139(', which can)-.74 F (do a similar check at compile time.)128 722.4 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 62)162.62 F 0 Cg EP %%Page: 63 63 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(Specifying)128 84 Q/F1 9/Times-Roman@0 SF(VERSION)3.497 E F0 .998 (as a literal of the form v5.6.1 should generally be a)3.497 F -.2(vo) -.2 G .998(ided, because it leads to).2 F 2.935 (misleading error messages under earlier v)128 96 R 2.935 (ersions of Perl that do not support this syntax.)-.15 F(The)7.935 E (equi)128 108 Q -.25(va)-.25 G(lent numeric v).25 E (ersion should be used instead.)-.15 E/F2 10/Courier@0 SF (require v5.6.1;)152 126 Q 6(#r)30 G(un time version check)-6 E (require 5.6.1;)152 138 Q 6(#d)36 G(itto)-6 E(require 5.006_001;)152 150 Q 6(#d)12 G(itto; preferred for backwards compatibility)-6 E F0 (Otherwise,)128 168 Q F2(require)3.257 E F0 .757 (demands that a library \214le be included if it hasn')3.257 F 3.258(ta) -.18 G .758(lready been included.)-3.258 F(The)5.758 E .084(\214le is i\ ncluded via the do-FILE mechanism, which is essentially just a v)128 180 R .083(ariety of)-.25 F F2(eval)2.583 E F0 .083(with the ca)2.583 F -.15 (ve)-.2 G(at).15 E 1.84(that le)128 192 R 1.84(xical v)-.15 F 1.84 (ariables in the in)-.25 F -.2(vo)-.4 G 1.84(king script will be in).2 F 1.84(visible to the included code.)-.4 F 1.84(Has semantics)6.84 F (similar to the follo)128 204 Q(wing subroutine:)-.25 E F2 (sub require {)152 222 Q(my \($filename\) = @_;)170 234 Q (if \(exists $INC{$filename}\) {)170 246 Q(return 1 if $INC{$filename};) 194 258 Q(die "Compilation failed in require";)194 270 Q(})170 282 Q (my \($realfilename,$result\);)170 294 Q(ITER: {)170 306 Q (foreach $prefix \(@INC\) {)194 318 Q ($realfilename = "$prefix/$filename";)218 330 Q (if \(\255f $realfilename\) {)218 342 Q ($INC{$filename} = $realfilename;)242 354 Q($result = do $realfilename;) 242 366 Q(last ITER;)242 378 Q(})218 390 Q(})194 402 Q (die "Can\010t find $filename in \\@INC";)194 414 Q(})170 426 Q (if \($@\) {)170 438 Q($INC{$filename} = undef;)194 450 Q(die $@;)194 462 Q 6(}e)170 474 S(lsif \(!$result\) {)-6 E(delete $INC{$filename};) 194 486 Q(die "$filename did not return true value";)194 498 Q 6(}e)170 510 S(lse {)-6 E(return $result;)194 522 Q(})170 534 Q(})152 546 Q F0(N\ ote that the \214le will not be included twice under the same speci\214\ ed name.)128 564 Q 1.481(The \214le must return true as the last statem\ ent to indicate successful e)128 582 R -.15(xe)-.15 G 1.481 (cution of an).15 F 3.981(yi)-.15 G(nitialization)-3.981 E .062 (code, so it')128 594 R 2.562(sc)-.55 G .062 (ustomary to end such a \214le with)-2.562 F F2(1;)2.563 E F0 .063 (unless you')2.563 F .063(re sure it')-.5 F .063 (ll return true otherwise.)-.1 F .063(But it')5.063 F(s)-.55 E (better just to put the)128 606 Q F2(1;)2.5 E F0 2.5(,i)C 2.5(nc)-2.5 G (ase you add more statements.)-2.5 E(If)128 624 Q F1(EXPR)4.344 E F0 1.844(is a bare)4.344 F -.1(wo)-.25 G 1.844(rd, the require assumes a ") .1 F/F3 10/Times-Italic@0 SF(.pm)A F0 3.324 -.74(`` e)D 1.844 (xtension and replaces ').59 F(')-.74 E F3(::)A F0 3.324 -.74(`` w)D 1.844(ith ').74 F(')-.74 E F3(/)A F0 4.343("i)C 4.343(nt)-4.343 G(he) -4.343 E .226(\214lename for you, to mak)128 636 R 2.726(ei)-.1 G 2.726 (te)-2.726 G .227(asy to load standard modules.)-2.726 F .227 (This form of loading of modules does not)5.227 F (risk altering your namespace.)128 648 Q(In other w)128 666 Q (ords, if you try this:)-.1 E F2(require Foo::Bar;)176 684 Q 6(#as)30 G (plendid bareword)-6 E F0 1.552 (The require function will actually look for the ")128 702 R F3 -1.05 (Fo)C(o/Bar)1.05 E(.pm)-1.11 E F0 4.051<228c>C 1.551 (le in the directories speci\214ed in the)-4.051 F F2(@INC)128 714 Q F0 (array)2.5 E(.)-.65 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 63)162.62 F 0 Cg EP %%Page: 64 64 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (But if you try this:)128 84 Q/F1 10/Courier@0 SF ($class = \010Foo::Bar\010;)176 102 Q(require $class;)176 114 Q 6(#$)42 G(class is not a bareword)-6 E(#or)152 126 Q(require "Foo::Bar";)176 138 Q 6(#n)18 G(ot a bareword because of the "")-6 E F0 .519 (The require function will look for the ")128 156 R/F2 10/Times-Italic@0 SF -1.05(Fo)C(o::Bar)1.05 E F0 1.999 -.74(`` \214)D .519(le in the).74 F F1(@INC)3.019 E F0 .519(array and will complain about not)3.019 F (\214nding ')128 168 Q(')-.74 E F2 -1.05(Fo)C(o::Bar)1.05 E F0 2.5("t)C 2.5(here. In)-2.5 F(this case you can do:)2.5 E F1 (eval "require $class";)176 186 Q F0(No)128 204 Q 3.8(wt)-.25 G 1.3 (hat you understand ho)-3.8 F(w)-.25 E F1(require)3.8 E F0 1.3 (looks for \214les with a bare)3.8 F -.1(wo)-.25 G 1.3(rd ar).1 F 1.3 (gument, there is a little)-.18 F -.15(ex)128 216 S .448 (tra functionality going on behind the scenes.).15 F(Before)5.449 E F1 (require)2.949 E F0 .449(looks for a ")2.949 F F2(.pm)A F0 1.929 -.74 (`` e)D .449(xtension, it will).59 F .198 (\214rst look for a similar \214lename with a ')128 228 R(')-.74 E F2 (.pmc)A F0 1.678 -.74(`` e)D .197 (xtension. If this \214le is found, it will be loaded in place).59 F (of an)128 240 Q 2.5<798c>-.15 G(le ending in a ')-2.5 E(')-.74 E F2 (.pm)A F0 2.5("e)C(xtension.)-2.65 E -1.1(Yo)128 258 S 3.473(uc)1.1 G .973(an also insert hooks into the import f)-3.473 F .974 (acility by putting Perl code directly into the)-.1 F F1(@INC)3.474 E F0 (array)3.474 E(.)-.65 E(There are three forms of hooks: subroutine refe\ rences, array references, and blessed objects.)128 270 Q 1.633 (Subroutine references are the simplest case.)128 288 R 1.632 (When the inclusion system w)6.632 F 1.632(alks through)-.1 F F1(@INC) 4.132 E F0(and)4.132 E .441 (encounters a subroutine, this subroutine gets called with tw)128 300 R 2.941(op)-.1 G .442(arameters, the \214rst a reference to itself,)-2.941 F .448(and the second the name of the \214le to be included \(e.g., ") 128 312 R F2 -1.05(Fo)C(o/Bar)1.05 E(.pm)-1.11 E F0 2.948("\). The)B .448(subroutine should return)2.948 F (either nothing or else a list of up to three v)128 324 Q (alues in the follo)-.25 E(wing order:)-.25 E(1.)128 340.8 Q 2.5<418c> 148 340.8 S(lehandle, from which the \214le will be read.)-2.5 E(2.)128 357.6 Q 4.413(Ar)148 357.6 S 1.913 (eference to a subroutine. If there is no \214lehandle \(pre)-4.413 F 1.914(vious item\), then this subroutine is)-.25 F -.15(ex)148 369.6 S 1.043(pected to generate one line of source code per call, writing the \ line into).15 F F1($_)3.543 E F0 1.043(and returning 1,)3.543 F .224 (then \214nally at end of \214le returning 0.)148 381.6 R .225 (If there is a \214lehandle, then the subroutine will be called to)5.225 F .169(act as a simple source \214lter)148 393.6 R 2.669(,w)-.4 G .169 (ith the line as read in)-2.669 F F1($_)2.669 E F0 5.169(.A)C -.05(ga) -5.169 G .169(in, return 1 for each v).05 F .169(alid line, and 0)-.25 F (after all lines ha)148 405.6 Q .3 -.15(ve b)-.2 H(een returned.).15 E (3.)128 422.4 Q .476 (Optional state for the subroutine. The state is passed in as)148 422.4 R F1($_[1])2.976 E F0 -5.475 2.976(.A r)D .477 (eference to the subroutine)-2.976 F(itself is passed in as)148 434.4 Q F1($_[0])2.5 E F0(.)A .656(If an empty list,)128 452.4 R F1(undef)3.156 E F0 3.156(,o)C 3.155(rn)-3.156 G .655 (othing that matches the \214rst 3 v)-3.155 F .655(alues abo)-.25 F .955 -.15(ve i)-.15 H 3.155(sr).15 G .655(eturned, then)-3.155 F F1(require) 3.155 E F0 .195(looks at the remaining elements of)128 464.4 R F1(@INC) 2.695 E F0 5.195(.N)C .195 (ote that this \214lehandle must be a real \214lehandle \(strictly a) -5.195 F(type)128 476.4 Q .048(glob or reference to a type)-.15 F .047(\ glob, whether blessed or unblessed\); tied \214lehandles will be ignore\ d and)-.15 F(processing will stop there.)128 488.4 Q .776(If the hook i\ s an array reference, its \214rst element must be a subroutine referenc\ e.)128 506.4 R .777(This subroutine is)5.777 F .504(called as abo)128 518.4 R -.15(ve)-.15 G 3.003(,b).15 G .503 (ut the \214rst parameter is the array reference.)-3.203 F .503 (This lets you indirectly pass ar)5.503 F(guments)-.18 E (to the subroutine.)128 530.4 Q(In other w)128 548.4 Q (ords, you can write:)-.1 E F1(push @INC, \\&my_sub;)152 566.4 Q (sub my_sub {)152 578.4 Q(my \($coderef, $filename\) = @_;)176 590.4 Q 6 (#$)12 G(coderef is \\&my_sub)-6 E(...)176 602.4 Q(})152 614.4 Q F0(or:) 128 632.4 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 64)162.62 F 0 Cg EP %%Page: 65 65 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (push @INC, [ \\&my_sub, $x, $y, ... ];)152 84 Q(sub my_sub {)152 96 Q (my \($arrayref, $filename\) = @_;)176 108 Q 6(#R)176 120 S (etrieve $x, $y, ...)-6 E(my @parameters = @$arrayref[1..$#$arrayref];) 176 132 Q(...)176 144 Q(})152 156 Q F0 .183 (If the hook is an object, it must pro)128 174 R .184(vide an)-.15 F/F2 9/Times-Roman@0 SF(INC)2.684 E F0 .184 (method that will be called as abo)2.684 F -.15(ve)-.15 G 2.684(,t).15 G .184(he \214rst parameter)-2.684 F .216(being the object itself.)128 186 R .216(\(Note that you must fully qualify the sub')5.216 F 2.716(sn)-.55 G .216(ame, as unquali\214ed)-2.716 F F1(INC)2.716 E F0 .215(is al)2.715 F -.1(wa)-.1 G(ys).1 E(forced into package)128 198 Q F1(main)2.5 E F0 2.5(.\) Here)B(is a typical code layout:)2.5 E F1 6(#I)152 216 S 6(nF)-6 G(oo.pm)-6 E(package Foo;)152 228 Q(sub new { ... })152 240 Q (sub Foo::INC {)152 252 Q(my \($self, $filename\) = @_;)176 264 Q(...) 176 276 Q(})152 288 Q 6(#I)152 312 S 6(nt)-6 G(he main program)-6 E (push @INC, Foo\255>new\(...\);)152 324 Q F0 .373 (These hooks are also permitted to set the)128 342 R F1(%INC)2.873 E F0 .373(entry corresponding to the \214les the)2.873 F 2.873(yh)-.15 G -2.25 -.2(av e)-2.873 H .373(loaded. See)3.073 F -.74(``)128 354 S (%INC').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E -.15(Fo)128 372 S 2.5(ray).15 G(et-more-po)-2.5 E(werful import f)-.25 E (acility)-.1 E 2.5(,s)-.65 G(ee `)-2.5 E(`use')-.74 E 2.5('a)-.74 G (nd perlmod.)-2.5 E(reset)108 388.8 Q F2(EXPR)2.5 E F0(reset)108 400.8 Q .46(Generally used in a)128 412.8 R F1(continue)2.96 E F0 .459 (block at the end of a loop to clear v)2.96 F .459(ariables and reset) -.25 F F1(??)2.959 E F0 .459(searches so)2.959 F .455(that the)128 424.8 R 2.955(yw)-.15 G .455(ork ag)-3.055 F 2.955(ain. The)-.05 F -.15(ex) 2.955 G .455(pression is interpreted as a list of single characters \(h) .15 F .455(yphens allo)-.05 F .455(wed for)-.25 F 2.761(ranges\). All) 128 436.8 R -.25(va)2.761 G .261(riables and arrays be).25 F .26 (ginning with one of those letters are reset to their pristine state.) -.15 F(If)5.26 E 1.192(the e)128 448.8 R 1.192 (xpression is omitted, one-match searches \()-.15 F F1(?pattern?)A F0 3.692(\)a)C 1.192(re reset to match ag)-3.692 F 3.693(ain. Only)-.05 F (resets)3.693 E -.25(va)128 460.8 S (riables or searches in the current package.).25 E(Al)5 E -.1(wa)-.1 G (ys returns 1.).1 E(Examples:)5 E F1(reset \010X\010;)152 478.8 Q 6(#r) 36 G(eset all X variables)-6 E(reset \010a\255z\010;)152 490.8 Q 6(#r)24 G(eset lower case variables)-6 E 54(reset; #)152 502.8 R (just reset ?one\255time? searches)6 E F0(Resetting)128 520.8 Q F1 ("A\255Z")3.916 E F0 1.416(is not recommended because you')3.916 F 1.416 (ll wipe out your)-.1 F F1(@ARGV)3.916 E F0(and)3.915 E F1(@INC)3.915 E F0 1.415(arrays and)3.915 F(your)128 532.8 Q F1(%ENV)4.714 E F0 4.714 (hash. Resets)4.714 F 2.214(only package v)4.714 F 2.215(ariables; le) -.25 F 2.215(xical v)-.15 F 2.215(ariables are unaf)-.25 F 2.215 (fected, b)-.25 F 2.215(ut the)-.2 F 4.715(yc)-.15 G(lean)-4.715 E (themselv)128 544.8 Q(es up on scope e)-.15 E(xit an)-.15 E(yw)-.15 E (ay)-.1 E 2.5(,s)-.65 G 2.5(oy)-2.5 G(ou')-2.5 E(ll probably w)-.1 E (ant to use them instead.)-.1 E(See `)5 E(`my')-.74 E('.)-.74 E(return) 108 561.6 Q F2(EXPR)2.5 E F0(return)108 573.6 Q .909 (Returns from a subroutine,)128 585.6 R F1(eval)3.409 E F0 3.408(,o)C(r) -3.408 E F1 .908(do FILE)3.408 F F0 .908(with the v)3.408 F .908 (alue gi)-.25 F -.15(ve)-.25 G 3.408(ni).15 G(n)-3.408 E F2(EXPR)3.408 E F0 5.908(.E)C -.25(va)-5.908 G .908(luation of).25 F F2(EXPR)3.408 E F0 .225(may be in list, scalar)128 597.6 R 2.726(,o)-.4 G 2.726(rv)-2.726 G .226(oid conte)-2.926 F .226(xt, depending on ho)-.15 F 2.726(wt)-.25 G .226(he return v)-2.726 F .226(alue will be used, and the conte)-.25 F (xt)-.15 E .82(may v)128 609.6 R .82(ary from one e)-.25 F -.15(xe)-.15 G .82(cution to the ne).15 F .82(xt \(see)-.15 F F1(wantarray)3.32 E F0 3.32(\). If)B(no)3.32 E F2(EXPR)3.32 E F0 .819(is gi)3.32 F -.15(ve)-.25 G .819(n, returns an empty).15 F(list in list conte)128 621.6 Q (xt, the unde\214ned v)-.15 E(alue in scalar conte)-.25 E (xt, and \(of course\) nothing at all in v)-.15 E(oid conte)-.2 E(xt.) -.15 E .585(\(In the absence of an e)128 639.6 R(xplicit)-.15 E F1 (return)3.085 E F0 3.085(,as)C .585(ubroutine, e)-3.085 F -.25(va)-.25 G .585(l, or do).25 F F2(FILE)3.085 E F0 .585(automatically returns the v) 3.085 F(alue)-.25 E(of the last e)128 651.6 Q(xpression e)-.15 E -.25 (va)-.25 G(luated.\)).25 E(re)108 668.4 Q -.15(ve)-.25 G(rse).15 E F2 (LIST)2.5 E F0 .763(In list conte)128 680.4 R .763(xt, returns a list v) -.15 F .762(alue consisting of the elements of)-.25 F F2(LIST)3.262 E F0 .762(in the opposite order)3.262 F 5.762(.I)-.55 G 3.262(ns)-5.762 G (calar)-3.262 E(conte)128 692.4 Q .061(xt, concatenates the elements of) -.15 F F2(LIST)2.561 E F0 .061(and returns a string v)2.561 F .062 (alue with all characters in the opposite)-.25 F(order)128 704.4 Q(.) -.55 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 65)162.62 F 0 Cg EP %%Page: 66 66 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (print join\(", ", reverse "world", "Hello"\); # Hello, world)152 84 Q (print scalar reverse "dlrow ,", "olleH";)152 108 Q 6(#H)24 G (ello, world)-6 E F0(Used without ar)128 126 Q(guments in scalar conte) -.18 E(xt,)-.15 E/F2 10/Times-Italic@0 SF -1.91 -.37(re v)2.5 H(er).37 E (se\(\))-.1 E F0(re)2.5 E -.15(ve)-.25 G(rses).15 E F1($_)2.5 E F0(.)A F1($_ = "dlrow ,olleH";)152 144 Q(print reverse;)152 156 Q 6(#N)180 G 6 (oo)-6 G(utput, list context)-6 E(print scalar reverse;)152 168 Q 6(#H) 138 G(ello, world)-6 E F0 .225(Note that re)128 186 R -.15(ve)-.25 G .225(rsing an array to itself \(as in).15 F F1 .225(@a = reverse @a) 2.725 F F0 2.725(\)w)C .225(ill preserv)-2.725 F 2.725(en)-.15 G(on-e) -2.725 E .225(xistent elements)-.15 F(whene)128 198 Q -.15(ve)-.25 G 2.5 (rp).15 G(ossible, i.e., for non magical arrays or tied arrays with)-2.5 E F1(EXISTS)2.5 E F0(and)2.5 E F1(DELETE)2.5 E F0(methods.)2.5 E 2.183 (This operator is also handy for in)128 216 R -.15(ve)-.4 G 2.184 (rting a hash, although there are some ca).15 F -.15(ve)-.2 G 4.684 (ats. If).15 F 4.684(av)4.684 G 2.184(alue is)-4.934 F 1.24(duplicated \ in the original hash, only one of those can be represented as a k)128 228 R 1.54 -.15(ey i)-.1 H 3.74(nt).15 G 1.24(he in)-3.74 F -.15(ve)-.4 G 1.24(rted hash.).15 F .694(Also, this has to unwind one hash and b)128 240 R .694(uild a whole ne)-.2 F 3.195(wo)-.25 G .695(ne, which may tak) -3.195 F 3.195(es)-.1 G .695(ome time on a lar)-3.195 F(ge)-.18 E (hash, such as from a)128 252 Q/F3 9/Times-Roman@0 SF(DBM)2.5 E F0 (\214le.)2.5 E F1(%by_name = reverse %by_address;)152 270 Q 6(#I)12 G (nvert the hash)-6 E F0(re)108 286.8 Q(winddir)-.25 E F3(DIRHANDLE)2.5 E F0(Sets the current position to the be)128 298.8 Q (ginning of the directory for the)-.15 E F1(readdir)2.5 E F0(routine on) 2.5 E F3(DIRHANDLE)2.5 E F0(.)A(rinde)108 315.6 Q(x)-.15 E F3(STR)2.5 E F0(,SUBSTR,POSITION)A(rinde)108 327.6 Q(x)-.15 E F3(STR)2.5 E F0 (,SUBSTR)A -.8(Wo)128 339.6 S .433(rks just lik).8 F(e)-.1 E F2(inde) 2.933 E(x\(\))-.2 E F0 -.15(ex)2.933 G .433 (cept that it returns the position of the).15 F F2(last)2.933 E F0 .433 (occurrence of)2.933 F F3(SUBSTR)2.933 E F0(in)2.933 E F3(STR)2.933 E F0 5.432(.I)C(f)-5.432 E F3(POSITION)128 351.6 Q F0 (is speci\214ed, returns the last occurrence be)2.5 E (ginning at or before that position.)-.15 E(rmdir)108 368.4 Q F3(FILEN) 2.5 E(AME)-.315 E F0(rmdir)108 380.4 Q .644 (Deletes the directory speci\214ed by)128 392.4 R F3(FILEN)3.144 E(AME) -.315 E F0 .644(if that directory is empty)3.144 F 5.645(.I)-.65 G 3.145 (fi)-5.645 G 3.145(ts)-3.145 G .645(ucceeds it returns true;)-3.145 F (otherwise it returns f)128 404.4 Q(alse and sets)-.1 E F1($!)2.5 E F0 2.5(\(errno\). If)2.5 F F3(FILEN)2.5 E(AME)-.315 E F0(is omitted, uses) 2.5 E F1($_)2.5 E F0(.)A 3.799 -.8(To r)128 422.4 T(emo).8 E 2.499 -.15 (ve a d)-.15 H 2.199(irectory tree recursi).15 F -.15(ve)-.25 G 2.199 (ly \().15 F F1 2.199(rm \255rf)B F0 2.199(on Unix\) look at the)4.699 F F1(rmtree)4.698 E F0 2.198(function of the)4.698 F(File::P)128 434.4 Q (ath module.)-.15 E(s///)108 451.2 Q(The substitution operator)128 451.2 Q 5(.S)-.55 G(ee `)-5 E(`Re)-.74 E(ge)-.15 E(xp Quote-Lik)-.15 E 2.5(eO) -.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E(say)108 468 Q F3 .25(FILEHANDLE LIST)2.5 F F0(say)108 480 Q F3(FILEHANDLE)2.5 E F0(say)108 492 Q F3(LIST)2.5 E F0(say)108 504 Q 2.013(Just lik)128 504 R (e)-.1 E F1(print)4.513 E F0 4.513(,b)C 2.013 (ut implicitly appends a ne)-4.713 F(wline.)-.25 E F1 2.013(say LIST) 7.013 F F0 2.014(is simply an abbre)4.513 F 2.014(viation for)-.25 F F1 ({)4.514 E .135(local $\\ = "\\n"; print LIST })128 516 R F0 5.135(.T)C 2.635(ou)-5.935 G(se)-2.635 E F3(FILEHANDLE)2.634 E F0 .134(without a) 2.634 F F3(LIST)2.634 E F0 .134(to print the contents)2.634 F(of)128 528 Q F1($_)2.5 E F0(to it, you must use a real \214lehandle lik)2.5 E(e)-.1 E F1(FH)2.5 E F0 2.5(,n)C(ot an indirect one lik)-2.5 E(e)-.1 E F1($fh) 2.5 E F0(.)A .236(This k)128 546 R -.15(ey)-.1 G -.1(wo).15 G .236 (rd is a).1 F -.25(va)-.2 G .236(ilable only when the).25 F F1("say") 2.736 E F0 .236(feature is enabled; see feature.)2.736 F(Alternately) 5.236 E 2.736(,i)-.65 G .236(nclude a)-2.736 F F1(use v5.10)128 558 Q F0 (or later to the current scope.)2.5 E(scalar)108 574.8 Q F3(EXPR)2.5 E F0 -.15(Fo)128 586.8 S(rces).15 E F3(EXPR)2.5 E F0 (to be interpreted in scalar conte)2.5 E(xt and returns the v)-.15 E (alue of)-.25 E F3(EXPR)2.5 E F0(.)A F1 (@counts = \( scalar @a, scalar @b, scalar @c \);)152 604.8 Q F0 1.465 (There is no equi)128 622.8 R -.25(va)-.25 G 1.465 (lent operator to force an e).25 F 1.464 (xpression to be interpolated in list conte)-.15 F 1.464(xt because in) -.15 F .507(practice, this is ne)128 634.8 R -.15(ve)-.25 G 3.007(rn).15 G 3.007(eeded. If)-3.007 F .508(you really w)3.007 F .508 (anted to do so, ho)-.1 F(we)-.25 E -.15(ve)-.25 G 1.308 -.4(r, y).15 H .508(ou could use the construction).4 F F1(@{[ \(some expression\) ]}) 128 646.8 Q F0 2.5(,b)C(ut usually a simple)-2.7 E F1 (\(some expression\))2.5 E F0(suf)2.5 E(\214ces.)-.25 E(Because)128 664.8 Q F1(scalar)3.446 E F0 .946(is a unary operator)3.446 F 3.446(,i) -.4 G 3.446(fy)-3.446 G .946 (ou accidentally use a parenthesized list for the)-3.446 F F3(EXPR)3.446 E F0 3.446(,t)C(his)-3.446 E(beha)128 676.8 Q -.15(ve)-.2 G 2.639(sa).15 G 2.639(sas)-2.639 G .139(calar comma e)-2.639 F .139(xpression, e)-.15 F -.25(va)-.25 G .139(luating all b).25 F .14(ut the last element in v) -.2 F .14(oid conte)-.2 F .14(xt and returning)-.15 F (the \214nal element e)128 688.8 Q -.25(va)-.25 G (luated in scalar conte).25 E 2.5(xt. This)-.15 F(is seldom what you w) 2.5 E(ant.)-.1 E(The follo)128 706.8 Q(wing single statement:)-.25 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 66)162.62 F 0 Cg EP %%Page: 67 67 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (print uc\(scalar\(&foo,$bar\)\),$baz;)152 84 Q F0(is the moral equi)128 102 Q -.25(va)-.25 G(lent of these tw).25 E(o:)-.1 E F1(&foo;)152 120 Q (print\(uc\($bar\),$baz\);)152 132 Q F0 (See perlop for more details on unary operators and the comma operator) 128 150 Q(.)-.55 E(seek)108 166.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(,POSITION,WHENCE)A(Sets)128 178.8 Q F2(FILEHANDLE)5.886 E F0 4.486 -.55('s p)D 3.386(osition, just lik).55 F 5.886(et)-.1 G(he)-5.886 E F1 (fseek)5.886 E F0 3.385(call of)5.886 F F1(stdio)5.885 E F0(.)A F2 (FILEHANDLE)8.385 E F0 3.385(may be an)5.885 F -.15(ex)128 190.8 S .061 (pression whose v).15 F .061(alue gi)-.25 F -.15(ve)-.25 G 2.561(st).15 G .061(he name of the \214lehandle.)-2.561 F .062(The v)5.061 F .062 (alues for)-.25 F F2(WHENCE)2.562 E F0(are)2.562 E F1(0)2.562 E F0 .062 (to set the ne)2.562 F(w)-.25 E(position)128 202.8 Q/F3 10 /Times-Italic@0 SF .299(in bytes)2.799 F F0(to)2.799 E F2(POSITION)2.799 E F0(;)A F1(1)2.799 E F0 .299(to set it to the current position plus) 2.799 F F2(POSITION)2.798 E F0 2.798(;a)C(nd)-2.798 E F1(2)2.798 E F0 .298(to set it to)2.798 F F2(EOF)2.798 E F0(plus)128 214.8 Q F2 (POSITION)2.527 E F0 2.527(,t)C .027(ypically ne)-2.527 F -.05(ga)-.15 G (ti).05 E -.15(ve)-.25 G 5.027(.F).15 G(or)-5.177 E F2(WHENCE)2.528 E F0 .028(you may use the constants)2.528 F F1(SEEK_SET)2.528 E F0(,)A F1 (SEEK_CUR)2.528 E F0(,)A(and)128 226.8 Q F1(SEEK_END)3.218 E F0 .718(\(\ start of the \214le, current position, end of the \214le\) from the Fcn\ tl module.)3.218 F(Returns)5.717 E F1(1)3.217 E F0(on success, f)128 238.8 Q(alse otherwise.)-.1 E .095(Note the)128 256.8 R F3 .095 (in bytes)2.595 F F0 2.595(:e)C -.15(ve)-2.845 G 2.595(ni).15 G 2.595 (ft)-2.595 G .095 (he \214lehandle has been set to operate on characters \(for e)-2.595 F .096(xample by using the)-.15 F F1(:encoding\(utf8\))128 268.8 Q F0 3.039(open layer\),)5.539 F F3(tell\(\))5.538 E F0 3.038 (will return byte of)5.538 F 3.038(fsets, not character of)-.25 F 3.038 (fsets \(because)-.25 F(implementing that w)128 280.8 Q(ould render)-.1 E F3(seek\(\))2.5 E F0(and)2.5 E F3(tell\(\))2.5 E F0(rather slo)2.5 E (w\).)-.25 E 1.788(If you w)128 298.8 R 1.788 (ant to position the \214le for)-.1 F F1(sysread)4.289 E F0(or)4.289 E F1(syswrite)4.289 E F0 4.289(,d)C(on')-4.289 E 4.289(tu)-.18 G(se)-4.289 E F1(seek)4.289 E F0 4.289(,b)C 1.789(ecause b)-4.289 F(uf)-.2 E(fering) -.25 E(mak)128 310.8 Q 2.257(es its ef)-.1 F 2.257(fect on the \214le') -.25 F 4.757(sr)-.55 G 2.257 (ead-write position unpredictable and non-portable.)-4.757 F(Use)7.256 E F1(sysseek)4.756 E F0(instead.)128 322.8 Q .687 (Due to the rules and rigors of)128 340.8 R F2(ANSI)3.187 E F0 .688 (C, on some systems you ha)3.188 F .988 -.15(ve t)-.2 H 3.188(od).15 G 3.188(oas)-3.188 G .688(eek whene)-3.188 F -.15(ve)-.25 G 3.188(ry).15 G .688(ou switch)-3.188 F 2.471(between reading and writing.)128 352.8 R 2.471(Amongst other things, this may ha)7.471 F 2.771 -.15(ve t)-.2 H 2.47(he ef).15 F 2.47(fect of calling stdio')-.25 F(s)-.55 E F3(clear) 128 364.8 Q(err)-.37 E F0 2.5(\(3\). A)1.666 F F2(WHENCE)2.5 E F0(of)2.5 E F1(1)2.5 E F0(\()2.5 E F1(SEEK_CUR)A F0 2.5(\)i)C 2.5(su)-2.5 G (seful for not mo)-2.5 E(ving the \214le position:)-.15 E F1 (seek\(TEST,0,1\);)152 382.8 Q F0 1.126 (This is also useful for applications emulating)128 400.8 R F1 1.126 (tail \255f)3.626 F F0 6.126(.O)C 1.126(nce you hit)-6.126 F F2(EOF) 3.627 E F0 1.127(on your read and then)3.627 F .648 (sleep for a while, you \(probably\) ha)128 412.8 R .947 -.15(ve t)-.2 H 3.147(os).15 G .647(tick in a dummy)-3.147 F F3(seek\(\))3.147 E F0 .647 (to reset things.)3.147 F(The)5.647 E F1(seek)3.147 E F0(doesn')3.147 E (t)-.18 E .327(change the position, b)128 424.8 R .327(ut it)-.2 F F3 (does)2.827 E F0 .327 (clear the end-of-\214le condition on the handle, so that the ne)2.827 F (xt)-.15 E F1()2.828 E F0(mak)128 436.8 Q(es Perl try ag)-.1 E (ain to read something.)-.05 E(\(W)5 E 2.5(eh)-.8 G(ope.\))-2.5 E 2.681 (If that doesn')128 454.8 R 5.181(tw)-.18 G 2.681 (ork \(some I/O implementations are particularly cantank)-5.281 F 2.68 (erous\), you might need)-.1 F(something lik)128 466.8 Q 2.5(et)-.1 G (his:)-2.5 E F1(for \(;;\) {)152 484.8 Q (for \($curpos = tell\(FILE\); $_ = ;)176 496.8 Q ($curpos = tell\(FILE\)\) {)206 508.8 Q 6(#s)200 520.8 S (earch for some stuff and put it into files)-6 E(})176 532.8 Q (sleep\($for_a_while\);)176 544.8 Q(seek\(FILE, $curpos, 0\);)176 556.8 Q(})152 568.8 Q F0(seekdir)108 585.6 Q F2(DIRHANDLE)2.5 E F0(,POS)A .393 (Sets the current position for the)128 597.6 R F1(readdir)2.893 E F0 .393(routine on)2.893 F F2(DIRHANDLE)2.894 E F0(.)A F2(POS)5.394 E F0 .394(must be a v)2.894 F .394(alue returned by)-.25 F F1(telldir)128 609.6 Q F0(.)A F1(seekdir)8.617 E F0 3.617(also has the same ca)6.117 F -.15(ve)-.2 G 3.616(ats about possible directory compaction as the).15 F (corresponding system library routine.)128 621.6 Q(select)108 638.4 Q F2 (FILEHANDLE)2.5 E F0(select)108 650.4 Q 1.391 (Returns the currently selected \214lehandle.)128 662.4 R(If)6.391 E F2 (FILEHANDLE)3.892 E F0 1.392(is supplied, sets the ne)3.892 F 3.892(wc) -.25 G 1.392(urrent def)-3.892 F(ault)-.1 E .441 (\214lehandle for output.)128 674.4 R .441(This has tw)5.441 F 2.941(oe) -.1 G -.25(ff)-2.941 G .441(ects: \214rst, a).25 F F1(write)2.941 E F0 .44(or a)2.941 F F1(print)2.94 E F0 .44(without a \214lehandle def)2.94 F .44(ault to)-.1 F(this)128 686.4 Q F2(FILEHANDLE)2.5 E F0 5(.S)C (econd, references to v)-5 E (ariables related to output will refer to this output channel.)-.25 E -.15(Fo)128 704.4 S 4.591(re).15 G 2.091(xample, to set the top-of-form\ format for more than one output channel, you might do the)-4.741 F (follo)128 716.4 Q(wing:)-.25 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 67)162.62 F 0 Cg EP %%Page: 68 68 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (select\(REPORT1\);)152 84 Q($^ = \010report1_top\010;)152 96 Q (select\(REPORT2\);)152 108 Q($^ = \010report2_top\010;)152 120 Q/F2 9 /Times-Roman@0 SF(FILEHANDLE)128 138 Q F0(may be an e)2.5 E (xpression whose v)-.15 E(alue gi)-.25 E -.15(ve)-.25 G 2.5(st).15 G (he name of the actual \214lehandle.)-2.5 E(Thus:)5 E F1 ($oldfh = select\(STDERR\); $| = 1; select\($oldfh\);)152 156 Q F0 .397 (Some programmers may prefer to think of \214lehandles as objects with \ methods, preferring to write the)128 174 R(last e)128 186 Q(xample as:) -.15 E F1(use IO::Handle;)152 204 Q(STDERR\255>autoflush\(1\);)152 216 Q F0(select)108 232.8 Q F2(RBITS)2.5 E F0(,WBITS,EBITS,TIMEOUT)A .514 (This calls the)128 244.8 R/F3 10/Times-Italic@0 SF(select)3.014 E F0 .514(\(2\) syscall with the bit masks speci\214ed, which can be constru\ cted using)1.666 F F1(fileno)3.015 E F0(and)128 256.8 Q F1(vec)2.5 E F0 2.5(,a)C(long these lines:)-2.5 E F1($rin = $win = $ein = \010\010;)152 274.8 Q(vec\($rin,fileno\(STDIN\),1\) = 1;)152 286.8 Q (vec\($win,fileno\(STDOUT\),1\) = 1;)152 298.8 Q($ein = $rin | $win;)152 310.8 Q F0(If you w)128 328.8 Q(ant to select on man)-.1 E 2.5<798c>-.15 G(lehandles, you may wish to write a subroutine lik)-2.5 E 2.5(et)-.1 G (his:)-2.5 E F1(sub fhbits {)152 346.8 Q (my\(@fhlist\) = split\(\010 \010,$_[0]\);)176 358.8 Q(my\($bits\);)176 370.8 Q(for \(@fhlist\) {)176 382.8 Q(vec\($bits,fileno\($_\),1\) = 1;) 200 394.8 Q(})176 406.8 Q($bits;)176 418.8 Q(})152 430.8 Q ($rin = fhbits\(\010STDIN TTY SOCK\010\);)152 442.8 Q F0 (The usual idiom is:)128 460.8 Q F1(\($nfound,$timeleft\) =)152 478.8 Q (select\($rout=$rin, $wout=$win, $eout=$ein, $timeout\);)164 490.8 Q F0 (or to block until something becomes ready just do this)128 508.8 Q F1 ($nfound = select\($rout=$rin, $wout=$win, $eout=$ein, undef\);)152 526.8 Q F0 1.472(Most systems do not bother to return an)128 544.8 R 1.471(ything useful in)-.15 F F1($timeleft)3.971 E F0 3.971(,s)C 3.971 (oc)-3.971 G(alling)-3.971 E F3(select\(\))3.971 E F0 1.471(in scalar) 3.971 F(conte)128 556.8 Q(xt just returns)-.15 E F1($nfound)2.5 E F0(.)A (An)128 574.8 Q 4.396(yo)-.15 G 4.396(ft)-4.396 G 1.896 (he bit masks can also be undef.)-4.396 F 1.897 (The timeout, if speci\214ed, is in seconds, which may be)6.897 F 4.542 (fractional. Note:)128 586.8 R 2.042 (not all implementations are capable of returning the)4.542 F F1 ($timeleft)4.541 E F0 7.041(.I)C 4.541(fn)-7.041 G 2.041(ot, the)-4.541 F(y)-.15 E(al)128 598.8 Q -.1(wa)-.1 G(ys return).1 E F1($timeleft)2.5 E F0(equal to the supplied)2.5 E F1($timeout)2.5 E F0(.)A -1.1(Yo)128 616.8 S 2.5(uc)1.1 G(an ef)-2.5 E (fect a sleep of 250 milliseconds this w)-.25 E(ay:)-.1 E F1 (select\(undef, undef, undef, 0.25\);)152 634.8 Q F0 .59 (Note that whether)128 652.8 R F1(select)3.09 E F0 .59 (gets restarted after signals \(say)3.09 F(,)-.65 E F2(SIGALRM)3.09 E F0 3.09(\)i)C 3.09(si)-3.09 G(mplementation-dependent.)-3.09 E (See also perlport for notes on the portability of)128 664.8 Q F1 (select)2.5 E F0(.)A(On error)128 682.8 Q(,)-.4 E F1(select)2.5 E F0 (beha)2.5 E -.15(ve)-.2 G 2.5(sl).15 G(ik)-2.5 E(e)-.1 E F3(select)2.5 E F0(\(2\): it returns \2551 and sets)1.666 E F1($!)2.5 E F0(.)A .873 (On some Unix)128 700.8 R(es,)-.15 E F3(select)3.373 E F0 .873 (\(2\) may report a sock)1.666 F .873(et \214le descriptor as `)-.1 F .873(`ready for reading')-.74 F 3.372('e)-.74 G -.15(ve)-3.622 G 3.372 (nw).15 G .872(hen no)-3.372 F .599(data is a)128 712.8 R -.25(va)-.2 G .599(ilable, and thus an).25 F 3.099(ys)-.15 G(ubsequent)-3.099 E F1 (read)3.099 E F0 -.1(wo)3.099 G .6(uld block. This can be a).1 F -.2(vo) -.2 G .6(ided if you al).2 F -.1(wa)-.1 G .6(ys use).1 F (O_NONBLOCK on the sock)128 724.8 Q(et. See)-.1 E F3(select)2.5 E F0 (\(2\) and)1.666 E F3(fcntl)2.5 E F0(\(2\) for further details.)1.666 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 68)162.62 F 0 Cg EP %%Page: 69 69 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 9/Times-Bold@0 SF -1.08(WA)128 84 S(RNING)1.08 E F0 2.586(:O)C .086 (ne should not attempt to mix b)-2.586 F(uf)-.2 E .086(fered I/O \(lik) -.25 F(e)-.1 E/F2 10/Courier@0 SF(read)2.586 E F0 .086(or <)2.586 F/F3 9 /Times-Roman@0 SF(FH)A F0 .086(>\) with)B F2(select)2.585 E F0 2.585(,e) C .085(xcept as)-2.735 F(permitted by)128 96 Q F3(POSIX)2.5 E F0 2.5(,a) C(nd e)-2.5 E -.15(ve)-.25 G 2.5(nt).15 G(hen only on)-2.5 E F3(POSIX) 2.5 E F0 2.5(systems. Y)2.5 F(ou ha)-1.1 E .3 -.15(ve t)-.2 H 2.5(ou).15 G(se)-2.5 E F2(sysread)2.5 E F0(instead.)2.5 E(semctl)108 112.8 Q F3(ID) 2.5 E F0(,SEMNUM,CMD,ARG)A(Calls the System V)128 124.8 Q F3(IPC)2.5 E F0(function)2.5 E/F4 10/Times-Italic@0 SF(semctl)2.5 E F0 2.5(\(2\). Y) 1.666 F(ou')-1.1 E(ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G (ay)-2.5 E F2(use IPC::SysV;)152 142.8 Q F0 1.521 (\214rst to get the correct constant de\214nitions.)128 160.8 R(If)6.521 E F3(CMD)4.021 E F0(is)4.022 E F3(IPC_ST)4.022 E -.999(AT)-.837 G F0(or) 5.021 E F3(GET)4.022 E(ALL)-.837 E F0 4.022(,t)C(hen)-4.022 E F3(ARG) 4.022 E F0 1.522(must be a)4.022 F -.25(va)128 172.8 S .118 (riable that will hold the returned semid_ds structure or semaphore v) .25 F .118(alue array)-.25 F 5.118(.R)-.65 G .117(eturns lik)-5.118 F(e) -.1 E F2(ioctl)2.617 E F0(:)A .033(the unde\214ned v)128 184.8 R .033 (alue for error)-.25 F 2.533(,")-.4 G F2 6.033(0b)-2.533 G .033(ut true) -6.033 F F0 2.533("f)C .033(or zero, or the actual return v)-2.533 F .033(alue otherwise.)-.25 F(The)5.033 E F3(ARG)2.533 E F0 8.503 (must consist of a v)128 196.8 R 8.502(ector of nati)-.15 F 8.802 -.15 (ve s)-.25 H 8.502(hort inte).15 F 8.502 (gers, which may be created with)-.15 F F2(pack\("s!",\(0\)x$nsem\))128 208.8 Q F0 6.298(.S)C 1.298(ee also `)-6.298 F(`SysV)-.74 E F3(IPC)3.798 E F0 2.778 -.74('' i)D 3.798(np).74 G(erlipc,)-3.798 E F2(IPC::SysV) 3.799 E F0(,)A F2(IPC::Semaphore)3.799 E F0(documentation.)128 220.8 Q (semget)108 237.6 Q F3(KEY)2.5 E F0(,NSEMS,FLA)A(GS)-.4 E 1.56 (Calls the System V)128 249.6 R F3(IPC)4.06 E F0(function)4.06 E F4 (semg)4.059 E(et)-.1 E F0 4.059(\(2\). Returns)1.666 F 1.559 (the semaphore id, or the unde\214ned v)4.059 F 1.559(alue on)-.25 F (error)128 261.6 Q 5(.S)-.55 G(ee also `)-5 E(`SysV)-.74 E F3(IPC)2.5 E F0 1.48 -.74('' i)D 2.5(np).74 G(erlipc,)-2.5 E F2(IPC::SysV)2.5 E F0(,) A F2(IPC::SysV::Semaphore)2.5 E F0(documentation.)2.5 E(semop)108 278.4 Q F3(KEY)2.5 E F0(,OPSTRING)A .839(Calls the System V)128 290.4 R F3 (IPC)3.339 E F0(function)3.339 E F4(semop)3.339 E F0 .839 (\(2\) for semaphore operations such as signalling and w)1.666 F (aiting.)-.1 E F3(OPSTRING)128 302.4 Q F0 .602(must be a pack)3.102 F .602(ed array of semop structures.)-.1 F .602 (Each semop structure can be generated with)5.602 F F2 3.272 (pack\("s!3", $semnum, $semop, $semflag\))128 314.4 R F0 8.272(.T)C 3.272(he length of)-8.272 F F3(OPSTRING)5.772 E F0 3.273(implies the) 5.772 F 2.151(number of semaphore operations.)128 326.4 R 2.151 (Returns true if successful, f)7.151 F 2.151(alse on error)-.1 F 7.15 (.A)-.55 G 4.65(sa)-7.15 G 4.65(ne)-4.65 G 2.15(xample, the)-4.8 F (follo)128 338.4 Q(wing code w)-.25 E(aits on semaphore)-.1 E F2 ($semnum)2.5 E F0(of semaphore id)2.5 E F2($semid:)2.5 E ($semop = pack\("s!3", $semnum, \2551, 0\);)152 356.4 Q (die "Semaphore trouble: $!\\n" unless semop\($semid, $semop\);)152 368.4 Q F0 3.303 -.8(To s)128 386.4 T 1.703 (ignal the semaphore, replace).8 F F24.204 E F0(with)4.204 E F2(1) 4.204 E F0 6.704(.S)C 1.704(ee also `)-6.704 F(`SysV)-.74 E F3(IPC)4.204 E F0 3.184 -.74('' i)D 4.204(np).74 G(erlipc,)-4.204 E F2(IPC::SysV) 4.204 E F0 4.204(,a)C(nd)-4.204 E F2(IPC::SysV::Semaphore)128 398.4 Q F0 (documentation.)2.5 E(send)108 415.2 Q F3(SOCKET)2.5 E F0(,MSG,FLA)A (GS,T)-.4 E(O)-.18 E(send)108 427.2 Q F3(SOCKET)2.5 E F0(,MSG,FLA)A(GS) -.4 E .585(Sends a message on a sock)128 439.2 R 3.085(et. Attempts)-.1 F .584(to send the scalar)3.085 F F3(MSG)3.084 E F0 .584(to the)3.084 F F3(SOCKET)3.084 E F0 3.084(\214lehandle. T)3.084 F(ak)-.8 E .584(es the) -.1 F 2.479(same \215ags as the system call of the same name.)128 451.2 R 2.479(On unconnected sock)7.479 F 2.479(ets, you must specify a)-.1 F 1.223(destination to)128 463.2 R F4 1.223(send to)3.723 F F0 3.723(,i)C 3.723(nw)-3.723 G 1.223(hich case it does a)-3.723 F F4(sendto)3.723 E F0 1.223(\(2\) syscall.)1.666 F 1.222(Returns the number of characters) 6.223 F .123(sent, or the unde\214ned v)128 475.2 R .123(alue on error) -.25 F 5.123(.T)-.55 G(he)-5.123 E F4(sendmsg)2.623 E F0 .123 (\(2\) syscall is currently unimplemented.)1.666 F .123(See `)5.123 F(`) -.74 E F3(UDP:)A F0(Message P)128 487.2 Q(assing')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc for e)-2.5 E(xamples.)-.15 E .539(Note the)128 505.2 R F4 -.15(ch)3.039 G(ar).15 E(acter)-.15 E(s)-.1 E F0 3.038(:d)C .538(epending on the status of the sock)-3.038 F .538 (et, either \(8\255bit\) bytes or characters are sent.)-.1 F 2.583 (By def)128 517.2 R 2.583(ault all sock)-.1 F 2.583 (ets operate on bytes, b)-.1 F 2.583(ut for e)-.2 F 2.583 (xample if the sock)-.15 F 2.583(et has been changed using)-.1 F F4 (binmode\(\))128 529.2 Q F0 1.612(to operate with the)4.112 F F2 (:encoding\(utf8\))4.112 E F0 1.611(I/O layer \(see `)4.112 F(`open') -.74 E 1.611(', or the)-.74 F F2(open)4.111 E F0(pragma,)4.111 E 2.456 (open\), the I/O will operate on)128 541.2 R F3(UTF\2558)4.956 E F0 2.456(encoded Unicode characters, not bytes.)4.956 F 2.456 (Similarly for the)7.456 F F2(:encoding)128 553.2 Q F0 (pragma: in that case pretty much an)2.5 E 2.5(yc)-.15 G (haracters can be sent.)-2.5 E(setpgrp)108 570 Q F3(PID)2.5 E F0(,PGRP)A 1.098(Sets the current process group for the speci\214ed)128 582 R F3 (PID)3.598 E F0(,)A F2(0)3.598 E F0 1.098(for the current process.)3.598 F 1.098(Raises an e)6.098 F(xception)-.15 E 2.885 (when used on a machine that doesn')128 594 R 5.385(ti)-.18 G(mplement) -5.385 E F3(POSIX)5.385 E F4(setpgid)5.385 E F0 2.885(\(2\) or)1.666 F F3(BSD)5.385 E F4(setpgrp)5.385 E F0 5.386(\(2\). If)1.666 F(the)5.386 E (ar)128 606 Q .113(guments are omitted, it def)-.18 F .113(aults to)-.1 F F2(0,0)2.613 E F0 5.113(.N)C .113(ote that the)-5.113 F F3(BSD)2.613 E F0 .112(4.2 v)2.613 F .112(ersion of)-.15 F F2(setpgrp)2.612 E F0 .112 (does not accept)2.612 F(an)128 618 Q 2.5(ya)-.15 G -.18(rg)-2.5 G (uments, so only).18 E F2(setpgrp\(0,0\))2.5 E F0(is portable.)2.5 E (See also)5 E F2(POSIX::setsid\(\))2.5 E F0(.)A(setpriority)108 634.8 Q F3(WHICH)2.5 E F0(,WHO,PRIORITY)A 1.588 (Sets the current priority for a process, a process group, or a user)128 646.8 R 6.589(.\()-.55 G(See)-6.589 E F4(setpriority)4.089 E F0 4.089 (\(2\).\) Raises)1.666 F(an)4.089 E -.15(ex)128 658.8 S (ception when used on a machine that doesn').15 E 2.5(ti)-.18 G (mplement)-2.5 E F4(setpriority)2.5 E F0(\(2\).)1.666 E(setsock)108 675.6 Q(opt)-.1 E F3(SOCKET)2.5 E F0(,LEVEL,OPTN)A(AME,OPTV)-.35 E(AL) -1.35 E 1.485(Sets the sock)128 687.6 R 1.485(et option requested.)-.1 F (Returns)6.484 E F2(undef)3.984 E F0 1.484(on error)3.984 F 6.484(.U) -.55 G 1.484(se inte)-6.484 F 1.484(ger constants pro)-.15 F 1.484 (vided by the)-.15 F F2(Socket)128 699.6 Q F0 4.315(module for)6.815 F F3(LEVEL)6.815 E F0(and)6.815 E F3(OPN)6.815 E(AME)-.315 E F0 9.315(.V)C 4.315(alues for)-10.425 F F3(LEVEL)6.815 E F0 4.316 (can also be obtained from)6.815 F(getprotobyname.)128 711.6 Q F3(OPTV) 7.222 E(AL)-1.215 E F0 2.222(might either be a pack)4.722 F 2.222 (ed string or an inte)-.1 F(ger)-.15 E 7.222(.A)-.55 G 4.722(ni)-7.222 G (nte)-4.722 E(ger)-.15 E F3(OPTV)4.722 E(AL)-1.215 E F0(is)4.722 E (shorthand for pack\(`)128 723.6 Q(`i')-.74 E(',)-.74 E F3(OPTV)2.5 E (AL)-1.215 E F0(\).)A(perl v5.14.2)72 768 Q 198.17(2011-10-01 69)162.62 F 0 Cg EP %%Page: 70 70 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(An e)128 84 Q (xample disabling Nagle')-.15 E 2.5(sa)-.55 G(lgorithm on a sock)-2.5 E (et:)-.1 E/F1 10/Courier@0 SF(use Socket qw\(IPPROTO_TCP TCP_NODELAY\);) 152 102 Q(setsockopt\($socket, IPPROTO_TCP, TCP_NODELAY, 1\);)152 114 Q F0(shift)108 130.8 Q/F2 9/Times-Roman@0 SF(ARRA)2.5 E(Y)-.945 E F0 (shift)108 142.8 Q F2(EXPR)2.5 E F0(shift)108 154.8 Q .805 (Shifts the \214rst v)128 166.8 R .805(alue of the array of)-.25 F 3.305 (fa)-.25 G .806(nd returns it, shortening the array by 1 and mo)-3.305 F .806(ving e)-.15 F -.15(ve)-.25 G(rything).15 E(do)128 178.8 Q 3.164 (wn. If)-.25 F .663(there are no elements in the array)3.164 F 3.163(,r) -.65 G .663(eturns the unde\214ned v)-3.163 F 3.163(alue. If)-.25 F F2 (ARRA)3.163 E(Y)-.945 E F0 .663(is omitted, shifts)3.163 F(the)128 190.8 Q F1(@_)4.232 E F0 1.732(array within the le)4.232 F 1.733 (xical scope of subroutines and formats, and the)-.15 F F1(@ARGV)4.233 E F0 1.733(array outside a)4.233 F .616(subroutine and also within the le) 128 202.8 R .616(xical scopes established by the)-.15 F F1 .615 (eval STRING)3.116 F F0(,)A F1 .615(BEGIN {})3.115 F F0(,)A F1(INIT) 3.115 E({})128 214.8 Q F0(,)A F1(CHECK {})2.5 E F0(,)A F1(UNITCHECK {}) 2.5 E F0 2.5(,a)C(nd)-2.5 E F1(END {})2.5 E F0(constructs.)2.5 E .604 (Starting with Perl 5.14,)128 232.8 R F1(shift)3.104 E F0 .604(can tak) 3.104 F 3.104(eas)-.1 G(calar)-3.104 E F2(EXPR)3.104 E F0 3.105(,w)C .605(hich must hold a reference to an unblessed)-3.105 F(array)128 244.8 Q 5.724(.T)-.65 G .723(he ar)-5.724 F .723 (gument will be dereferenced automatically)-.18 F 5.723(.T)-.65 G .723 (his aspect of)-5.723 F F1(shift)3.223 E F0 .723(is considered highly) 3.223 F -.15(ex)128 256.8 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E .705(See also)128 274.8 R F1(unshift)3.205 E F0(,)A F1(push)3.205 E F0 3.205(,a)C(nd)-3.205 E F1(pop)3.205 E F0(.)A F1(shift)5.705 E F0 (and)3.205 E F1(unshift)3.205 E F0 .706 (do the same thing to the left end of an)3.206 F(array that)128 286.8 Q F1(pop)2.5 E F0(and)2.5 E F1(push)2.5 E F0(do to the right end.)2.5 E (shmctl)108 303.6 Q F2(ID)2.5 E F0(,CMD,ARG)A(Calls the System V)128 315.6 Q F2(IPC)2.5 E F0(function shmctl.)2.5 E -1.1(Yo)5 G(u')1.1 E (ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1 (use IPC::SysV;)152 333.6 Q F0 .739 (\214rst to get the correct constant de\214nitions.)128 351.6 R(If)5.739 E F2(CMD)3.239 E F0(is)3.239 E F1(IPC_STAT)3.239 E F0 3.239(,t)C(hen) -3.239 E F2(ARG)3.239 E F0 .738(must be a v)3.239 F .738(ariable that) -.25 F .046(will hold the returned)128 363.6 R F1(shmid_ds)2.547 E F0 2.547(structure. Returns)2.547 F(lik)2.547 E 2.547(ei)-.1 G(octl:)-2.547 E F1(undef)2.547 E F0 .047(for error; ")2.547 F F1(0)A F0 -.2(bu)2.547 G 2.547(tt).2 G .047(rue" for zero;)-2.547 F 4.442 (and the actual return v)128 375.6 R 4.441(alue otherwise.)-.25 F 4.441 (See also `)9.441 F(`SysV)-.74 E F2(IPC)6.941 E F0 5.921 -.74('' i)D 6.941(np).74 G 4.441(erlipc and)-6.941 F F1(IPC::SysV)6.941 E F0 (documentation.)128 387.6 Q(shmget)108 404.4 Q F2(KEY)2.5 E F0 (,SIZE,FLA)A(GS)-.4 E .337(Calls the System V)128 416.4 R F2(IPC)2.837 E F0 .337(function shmget.)2.837 F .337(Returns the shared memory se)5.337 F .337(gment id, or)-.15 F F1(undef)2.838 E F0 .338(on error)2.838 F(.) -.55 E(See also `)128 428.4 Q(`SysV)-.74 E F2(IPC)2.5 E F0 1.48 -.74 ('' i)D 2.5(np).74 G(erlipc and)-2.5 E F1(IPC::SysV)2.5 E F0 (documentation.)2.5 E(shmread)108 445.2 Q F2(ID)2.5 E F0(,V)A (AR,POS,SIZE)-1.35 E(shmwrite)108 457.2 Q F2(ID)2.5 E F0 (,STRING,POS,SIZE)A 1.126(Reads or writes the System V shared memory se) 128 469.2 R(gment)-.15 E F2(ID)3.625 E F0 1.125(starting at position) 3.625 F F2(POS)3.625 E F0 1.125(for size)3.625 F F2(SIZE)3.625 E F0(by) 3.625 E .336(attaching to it, cop)128 481.2 R .336 (ying in/out, and detaching from it.)-.1 F .336(When reading,)5.336 F F2 -1.215(VA)2.836 G(R)1.215 E F0 .337(must be a v)2.836 F .337 (ariable that will)-.25 F .672(hold the data read.)128 493.2 R .671 (When writing, if)5.672 F F2(STRING)3.171 E F0 .671(is too long, only) 3.171 F F2(SIZE)3.171 E F0 .671(bytes are used; if)3.171 F F2(STRING) 3.171 E F0 .671(is too)3.171 F .157 (short, nulls are written to \214ll out)128 505.2 R F2(SIZE)2.658 E F0 2.658(bytes. Return)2.658 F .158(true if successful, f)2.658 F .158 (alse on error)-.1 F(.)-.55 E/F3 10/Times-Italic@0 SF(shmr)5.158 E (ead\(\))-.37 E F0(taints)2.658 E .009(the v)128 517.2 R .008 (ariable. See also `)-.25 F(`SysV)-.74 E F2(IPC)2.508 E F0 1.488 -.74 ('' i)D 2.508(np).74 G(erlipc,)-2.508 E F1(IPC::SysV)2.508 E F0 2.508 (,a)C .008(nd the)-2.508 F F1(IPC::Shareable)2.508 E F0 .008 (module from)2.508 F F2(CP)128 529.2 Q(AN)-.828 E F0(.)A(shutdo)108 546 Q(wn)-.25 E F2(SOCKET)2.5 E F0(,HO)A(W)-.35 E .059(Shuts do)128 558 R .059(wn a sock)-.25 F .059(et connection in the manner indicated by)-.1 F F2(HO)2.56 E(W)-.315 E F0 2.56(,w)C .06 (hich has the same interpretation as)-2.56 F (in the syscall of the same name.)128 570 Q F1(shutdown\(SOCKET, 0\);) 152 588 Q 6(#I)24 G(/we have stopped reading data)-6 E (shutdown\(SOCKET, 1\);)152 600 Q 6(#I)24 G (/we have stopped writing data)-6 E(shutdown\(SOCKET, 2\);)152 612 Q 6 (#I)24 G(/we have stopped using this socket)-6 E F0 1.49 (This is useful with sock)128 630 R 1.49(ets when you w)-.1 F 1.49 (ant to tell the other side you')-.1 F 1.49(re done writing b)-.5 F 1.49 (ut not done)-.2 F 2.352(reading, or vice v)128 642 R 4.852(ersa. It') -.15 F 4.852(sa)-.55 G 2.352 (lso a more insistent form of close because it also disables the \214le) -4.852 F(descriptor in an)128 654 Q 2.5(yf)-.15 G(ork)-2.5 E (ed copies in other processes.)-.1 E(Returns)128 672 Q F1(1)2.667 E F0 .167(for success; on error)2.667 F 2.667(,r)-.4 G(eturns)-2.667 E F1 (undef)2.667 E F0 .167(if the \214rst ar)2.667 F .166(gument is not a v) -.18 F .166(alid \214lehandle, or returns)-.25 F F1(0)128 684 Q F0 (and sets)2.5 E F1($!)2.5 E F0(for an)2.5 E 2.5(yo)-.15 G(ther f)-2.5 E (ailure.)-.1 E(sin)108 700.8 Q F2(EXPR)2.5 E F0(sin)108 712.8 Q (Returns the sine of)128 712.8 Q F2(EXPR)2.5 E F0(\(e)2.5 E (xpressed in radians\).)-.15 E(If)5 E F2(EXPR)2.5 E F0 (is omitted, returns sine of)2.5 E F1($_)2.5 E F0(.)A -.15(Fo)128 730.8 S 2.5(rt).15 G(he in)-2.5 E -.15(ve)-.4 G (rse sine operation, you may use the).15 E F1(Math::Trig::asin)2.5 E F0 (function, or use this relation:)2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 70)162.62 F 0 Cg EP %%Page: 71 71 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (sub asin { atan2\($_[0], sqrt\(1 \255 $_[0] * $_[0]\)\) })152 84 Q F0 (sleep)108 100.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0(sleep)108 112.8 Q .469(Causes the script to sleep for \(inte)128 124.8 R(ger\))-.15 E F2 (EXPR)2.969 E F0 .469(seconds, or fore)2.969 F -.15(ve)-.25 G 2.969(ri) .15 G 2.969(fn)-2.969 G 2.969(oa)-2.969 G -.18(rg)-2.969 G .469 (ument is gi).18 F -.15(ve)-.25 G 2.97(n. Returns).15 F(the)2.97 E(inte) 128 136.8 Q(ger number of seconds actually slept.)-.15 E (May be interrupted if the process recei)128 154.8 Q -.15(ve)-.25 G 2.5 (sas).15 G(ignal such as)-2.5 E F1(SIGALRM)2.5 E F0(.)A F1(eval {)152 172.8 Q(local $SIG{ALARM} = sub { die "Alarm!\\n" };)176 184.8 Q(sleep;) 176 196.8 Q(};)152 208.8 Q(die $@ unless $@ eq "Alarm!\\n";)152 220.8 Q F0 -1.1(Yo)128 238.8 S 4.622(up)1.1 G 2.122(robably cannot mix)-4.622 F F1(alarm)4.622 E F0(and)4.622 E F1(sleep)4.622 E F0 2.121 (calls, because)4.622 F F1(sleep)4.621 E F0 2.121 (is often implemented using)4.621 F F1(alarm)128 250.8 Q F0(.)A .7(On s\ ome older systems, it may sleep up to a full second less than what you \ requested, depending on)128 268.8 R(ho)128 280.8 Q 2.631(wi)-.25 G 2.631 (tc)-2.631 G .131(ounts seconds.)-2.631 F .131(Most modern systems al) 5.131 F -.1(wa)-.1 G .131(ys sleep the full amount.).1 F(The)5.13 E 2.63 (ym)-.15 G .13(ay appear to sleep)-2.63 F 2.812(longer than that, ho)128 292.8 R(we)-.25 E -.15(ve)-.25 G 3.612 -.4(r, b).15 H 2.812 (ecause your process might not be scheduled right a).4 F -.1(wa)-.15 G 5.312(yi).1 G 5.312(nab)-5.312 G(usy)-5.512 E(multitasking system.)128 304.8 Q -.15(Fo)128 322.8 S 3.844(rd).15 G 1.344 (elays of \214ner granularity than one second, the T)-3.844 F 1.344 (ime::HiRes module \(from)-.35 F F2(CP)3.844 E(AN)-.828 E F0 3.844(,a)C 1.343(nd starting)-3.844 F 2.024 (from Perl 5.8 part of the standard distrib)128 334.8 R 2.025 (ution\) pro)-.2 F(vides)-.15 E/F3 10/Times-Italic@0 SF(usleep\(\))4.525 E F0 7.025(.Y)C 2.025(ou may also use Perl')-8.125 F 4.525(sf)-.55 G (our)-4.525 E(-)-.2 E(ar)128 346.8 Q .816(gument v)-.18 F .816 (ersion of)-.15 F F3(select\(\))3.316 E F0(lea)3.316 E .816 (ving the \214rst three ar)-.2 F .815 (guments unde\214ned, or you might be able to use)-.18 F(the)128 358.8 Q F1(syscall)2.5 E F0(interf)2.5 E(ace to access)-.1 E F3(setitimer)2.5 E F0(\(2\) if your system supports it. See perlf)1.666 E(aq8 for details.) -.1 E(See also the)128 376.8 Q F2(POSIX)2.5 E F0(module')2.5 E(s)-.55 E F1(pause)2.5 E F0(function.)2.5 E(sock)108 393.6 Q(et)-.1 E F2(SOCKET) 2.5 E F0(,DOMAIN,TYPE,PR)A -1.88 -.4(OT O)-.4 H(COL).4 E 1.787 (Opens a sock)128 405.6 R 1.788 (et of the speci\214ed kind and attaches it to \214lehandle)-.1 F F2 (SOCKET)4.288 E F0(.)A F2(DOMAIN)6.788 E F0(,)A F2(TYPE)4.288 E F0 4.288 (,a)C(nd)-4.288 E F2(PR)128 417.6 Q -1.692 -.36(OT O)-.36 H(COL).36 E F0 1.086(are speci\214ed the same as for the syscall of the same name.) 3.586 F -1.1(Yo)6.085 G 3.585(us)1.1 G(hould)-3.585 E F1 1.085 (use Socket)3.585 F F0 4.986 (\214rst to get the proper de\214nitions imported.)128 429.6 R 4.986 (See the e)9.986 F 4.986(xamples in `)-.15 F(`Sock)-.74 E 4.986 (ets: Client/Serv)-.1 F(er)-.15 E(Communication')128 441.6 Q 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E 1.179 (On systems that support a close-on-e)128 459.6 R -.15(xe)-.15 G 3.679 <638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.679 F 1.178(wly opened \214le)-.25 F(descriptor)128 471.6 Q 2.5(,a) -.4 G 2.5(sd)-2.5 G(etermined by the v)-2.5 E(alue of $^F)-.25 E 5(.S) -.8 G(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar) -.25 E(.)-.55 E(sock)108 488.4 Q(etpair)-.1 E F2(SOCKET1)2.5 E F0 (,SOCKET2,DOMAIN,TYPE,PR)A -1.88 -.4(OT O)-.4 H(COL).4 E .955 (Creates an unnamed pair of sock)128 500.4 R .955 (ets in the speci\214ed domain, of the speci\214ed type.)-.1 F F2 (DOMAIN)5.956 E F0(,)A F2(TYPE)3.456 E F0(,)A(and)128 512.4 Q F2(PR) 3.067 E -1.692 -.36(OT O)-.36 H(COL).36 E F0 .567 (are speci\214ed the same as for the syscall of the same name.)3.067 F .566(If unimplemented, raises)5.567 F(an e)128 524.4 Q 2.5 (xception. Returns)-.15 F(true if successful.)2.5 E 1.178 (On systems that support a close-on-e)128 542.4 R -.15(xe)-.15 G 3.678 <638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.678 F 1.179(wly opened \214le)-.25 F (descriptors, as determined by the v)128 554.4 Q(alue of $^F)-.25 E 5 (.S)-.8 G(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E (ar)-.25 E(.)-.55 E 1.249(Some systems de\214ned)128 572.4 R F1(pipe) 3.749 E F0 1.249(in terms of)3.749 F F1(socketpair)3.749 E F0 3.749(,i)C 3.749(nw)-3.749 G 1.248(hich a call to)-3.749 F F1 1.248 (pipe\(Rdr, Wtr\))3.748 F F0(is)3.748 E(essentially:)128 584.4 Q F1 (use Socket;)152 602.4 Q (socketpair\(Rdr, Wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC\);)152 614.4 Q (shutdown\(Rdr, 1\);)152 626.4 Q 6(#n)48 G 6(om)-6 G (ore writing for reader)-6 E(shutdown\(Wtr, 0\);)152 638.4 Q 6(#n)48 G 6 (om)-6 G(ore reading for writer)-6 E F0 1.786(See perlipc for an e)128 656.4 R 1.787(xample of sock)-.15 F 1.787(etpair use.)-.1 F 1.787 (Perl 5.8 and later will emulate sock)6.787 F 1.787(etpair using)-.1 F F2(IP)4.287 E F0(sock)128 668.4 Q (ets to localhost if your system implements sock)-.1 E(ets b)-.1 E (ut not sock)-.2 E(etpair)-.1 E(.)-.55 E(sort)108 685.2 Q F2(SUBN)2.5 E .25(AME LIST)-.315 F F0(sort)108 697.2 Q F2 .25(BLOCK LIST)2.5 F F0 (perl v5.14.2)72 768 Q 198.17(2011-10-01 71)162.62 F 0 Cg EP %%Page: 72 72 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(sort)108 84 Q/F1 9 /Times-Roman@0 SF(LIST)2.5 E F0 .489(In list conte)128 96 R .489 (xt, this sorts the)-.15 F F1(LIST)2.989 E F0 .489 (and returns the sorted list v)2.989 F 2.989(alue. In)-.25 F .489 (scalar conte)2.989 F .489(xt, the beha)-.15 F .488(viour of)-.2 F/F2 10 /Courier@0 SF(sort\(\))128 108 Q F0(is unde\214ned.)2.5 E(If)128 126 Q F1(SUBN)4.395 E(AME)-.315 E F0(or)4.395 E F1(BLOCK)4.395 E F0 1.895 (is omitted,)4.395 F F2(sort)4.395 E F0 4.395(si)C 4.396(ns)-4.395 G 1.896(tandard string comparison order)-4.396 F 6.896(.I)-.55 G(f)-6.896 E F1(SUBN)4.396 E(AME)-.315 E F0(is)4.396 E .159(speci\214ed, it gi)128 138 R -.15(ve)-.25 G 2.659(st).15 G .159 (he name of a subroutine that returns an inte)-2.659 F .158 (ger less than, equal to, or greater than)-.15 F F2(0)2.658 E F0(,)A 2.153(depending on ho)128 150 R 4.653(wt)-.25 G 2.153 (he elements of the list are to be ordered.)-4.653 F(\(The)7.154 E F2 (<=>)4.654 E F0(and)4.654 E F2(cmp)4.654 E F0 2.154(operators are)4.654 F -.15(ex)128 162 S 1.873(tremely useful in such routines.\)).15 F F1 (SUBN)6.873 E(AME)-.315 E F0 1.873(may be a scalar v)4.373 F 1.872 (ariable name \(unsubscripted\), in)-.25 F .322(which case the v)128 174 R .322(alue pro)-.25 F .323 (vides the name of \(or a reference to\) the actual subroutine to use.) -.15 F .323(In place of)5.323 F(a)128 186 Q F1(SUBN)2.5 E(AME)-.315 E F0 2.5(,y)C(ou can pro)-2.5 E(vide a)-.15 E F1(BLOCK)2.5 E F0(as an anon) 2.5 E(ymous, in-line sort subroutine.)-.15 E .538(If the subroutine')128 204 R 3.038(sp)-.55 G .538(rototype is)-3.038 F F2(\($$\))3.038 E F0 3.038(,t)C .538(he elements to be compared are passed by reference in) -3.038 F F2(@_)3.037 E F0 3.037(,a)C(s)-3.037 E 1.85 (for a normal subroutine.)128 216 R 1.851(This is slo)6.85 F 1.851 (wer than unprototyped subroutines, where the elements to be)-.25 F 1.585(compared are passed into the subroutine as the package global v) 128 228 R(ariables)-.25 E F2($a)4.084 E F0(and)4.084 E F2($b)4.084 E F0 1.584(\(see e)4.084 F(xample)-.15 E(belo)128 240 Q 3.481(w\). Note)-.25 F .982(that in the latter case, it is usually highly counter)3.481 F (-producti)-.2 E 1.282 -.15(ve t)-.25 H 3.482(od).15 G(eclare)-3.482 E F2($a)3.482 E F0(and)3.482 E F2($b)3.482 E F0(as)3.482 E(le)128 252 Q (xicals.)-.15 E(The v)128 270 Q(alues to be compared are al)-.25 E -.1 (wa)-.1 G(ys passed by reference and should not be modi\214ed.).1 E -1.1 (Yo)128 288 S 4.549(ua)1.1 G 2.049(lso cannot e)-4.549 F 2.049 (xit out of the sort block or subroutine using an)-.15 F 4.549(yo)-.15 G 4.549(ft)-4.549 G 2.048(he loop control operators)-4.549 F (described in perlsyn or with)128 300 Q F2(goto)2.5 E F0(.)A(When)128 318 Q F2 1.009(use locale)3.509 F F0 1.009(is in ef)3.509 F(fect,)-.25 E F2 1.009(sort LIST)3.509 F F0(sorts)3.509 E F1(LIST)3.509 E F0 1.01 (according to the current collation locale.)3.51 F(See perllocale.)128 330 Q/F3 10/Times-Italic@0 SF(sort\(\))128 348 Q F0 .291 (returns aliases into the original list, much as a for loop')2.791 F 2.79(si)-.55 G(nde)-2.79 E 2.79(xv)-.15 G .29 (ariable aliases the list elements.)-3.04 F .255 (That is, modifying an element of a list returned by)128 360 R F3 (sort\(\))2.755 E F0 .255(\(for e)2.755 F .255(xample, in a)-.15 F F2 (foreach)2.755 E F0(,)A F2(map)2.755 E F0(or)2.755 E F2(grep)2.755 E F0 (\))A 2.068(actually modi\214es the element in the original list.)128 372 R 2.068(This is usually something to be a)7.068 F -.2(vo)-.2 G 2.068 (ided when).2 F(writing clear code.)128 384 Q .862 (Perl 5.6 and earlier used a quicksort algorithm to implement sort.)128 402 R .863(That algorithm w)5.863 F .863(as not stable, so)-.1 F F3 (could)128 414 Q F0 .093(go quadratic.)2.593 F(\(A)5.093 E F3(stable) 2.593 E F0 .093(sort preserv)2.593 F .093 (es the input order of elements that compare equal.)-.15 F(Although) 5.092 E(quicksort')128 426 Q 2.644(sr)-.55 G .144 (un time is O\(NlogN\) when a)-2.644 F -.15(ve)-.2 G .145(raged o).15 F -.15(ve)-.15 G 2.645(ra).15 G .145 (ll arrays of length N, the time can be O\(N**2\),)-2.645 F F3(quadr)128 438 Q(atic)-.15 E F0(beha)2.886 E(vior)-.2 E 2.886(,f)-.4 G .386 (or some inputs.\))-2.886 F .386(In 5.7, the quicksort implementation w) 5.386 F .385(as replaced with a stable)-.1 F(mer)128 450 Q .027 (gesort algorithm whose w)-.18 F .027(orst-case beha)-.1 F .027 (vior is O\(NlogN\).)-.2 F .028(But benchmarks indicated that for some) 5.028 F .435(inputs, on some platforms, the original quicksort w)128 462 R .435(as f)-.1 F(aster)-.1 E 5.435(.5)-.55 G .435 (.8 has a sort pragma for limited control)-5.435 F .784(of the sort.)128 474 R .785(Its rather blunt control of the underlying algorithm may not\ persist into future Perls, b)5.784 F(ut)-.2 E .212(the ability to char\ acterize the input or output in implementation independent w)128 486 R .212(ays quite probably will.)-.1 F(See the sort pragma.)128 498 Q (Examples:)128 516 Q F2 6(#s)152 534 S(ort lexically)-6 E (@articles = sort @files;)152 546 Q 6(#s)152 570 S (ame thing, but with explicit sort routine)-6 E (@articles = sort {$a cmp $b} @files;)152 582 Q 6(#n)152 606 S (ow case\255insensitively)-6 E (@articles = sort {uc\($a\) cmp uc\($b\)} @files;)152 618 Q 6(#s)152 642 S(ame thing in reversed order)-6 E(@articles = sort {$b cmp $a} @files;) 152 654 Q 6(#s)152 678 S(ort numerically ascending)-6 E (@articles = sort {$a <=> $b} @files;)152 690 Q 6(#s)152 714 S (ort numerically descending)-6 E(@articles = sort {$b <=> $a} @files;) 152 726 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 72)162.62 F 0 Cg EP %%Page: 73 73 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#t)152 96 S(his sorts the %age hash by value instead of key)-6 E 6(#u) 152 108 S(sing an in\255line function)-6 E (@eldest = sort { $age{$b} <=> $age{$a} } keys %age;)152 120 Q 6(#s)152 144 S(ort using explicit subroutine name)-6 E(sub byage {)152 156 Q ($age{$a} <=> $age{$b};)152 168 Q 6(#p)12 G(resuming numeric)-6 E(})152 180 Q(@sortedclass = sort byage @class;)152 192 Q (sub backwards { $b cmp $a })152 216 Q 6(@harry =)152 228 R (qw\(dog cat x Cain Abel\);)6 E (@george = qw\(gone chased yz Punished Axed\);)152 240 Q (print sort @harry;)152 252 Q 6(#p)176 264 S(rints AbelCaincatdogx)-6 E (print sort backwards @harry;)152 276 Q 6(#p)176 288 S (rints xdogcatCainAbel)-6 E(print sort @george, \010to\010, @harry;)152 300 Q 6(#p)176 312 S(rints AbelAxedCainPunishedcatchaseddoggonetoxyz)-6 E 6(#i)152 336 S(nefficiently sort by descending numeric compare using) -6 E 6(#t)152 348 S(he first integer after the first = sign, or the)-6 E 6(#w)152 360 S(hole record case\255insensitively otherwise)-6 E (my @new = sort {)152 384 Q (\($b =~ /=\(\\d+\)/\)[0] <=> \($a =~ /=\(\\d+\)/\)[0])176 396 Q(||)200 408 Q 6(uc\($a\) cmp uc\($b\))176 420 R 6(}@)152 432 S(old;)-6 E 6(#s) 152 456 S(ame thing, but much more efficiently;)-6 E 6(#w)152 468 S (e\010ll build auxiliary indices instead)-6 E 6(#f)152 480 S(or speed)-6 E(my @nums = @caps = \(\);)152 492 Q(for \(@old\) {)152 504 Q (push @nums, \( /=\(\\d+\)/ ? $1 : undef \);)176 516 Q (push @caps, uc\($_\);)176 528 Q(})152 540 Q(my @new = @old[ sort {)152 564 Q($nums[$b] <=> $nums[$a])176 576 Q(||)200 588 Q ($caps[$a] cmp $caps[$b])176 600 Q 6(}0)176 612 S(..$#old)-6 E(];)152 624 Q 6(#s)152 648 S(ame thing, but without any temps)-6 E (@new = map { $_\255>[0] })152 660 Q(sort { $b\255>[1] <=> $a\255>[1]) 194 672 Q(||)218 684 Q($a\255>[2] cmp $b\255>[2])194 696 Q 6(}m)152 708 S(ap { [$_, /=\(\\d+\)/, uc\($_\)] } @old;)-6 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 73)162.62 F 0 Cg EP %%Page: 74 74 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#u)152 84 S (sing a prototype allows you to use any comparison subroutine)-6 E 6(#a) 152 96 S 6(sas)-6 G (ort subroutine \(including other package\010s subroutines\))-6 E (package other;)152 108 Q(sub backwards \($$\) { $_[1] cmp $_[0]; })152 120 Q 6(#$)12 G 6(aa)-6 G(nd $b are not set here)-6 E(package main;)152 144 Q(@new = sort other::backwards @old;)152 156 Q 6(#g)152 180 S (uarantee stability, regardless of algorithm)-6 E (use sort \010stable\010;)152 192 Q (@new = sort { substr\($a, 3, 5\) cmp substr\($b, 3, 5\) } @old;)152 204 Q 6(#f)152 228 S (orce use of mergesort \(not portable outside Perl 5.8\))-6 E (use sort \010_mergesort\010;)152 240 Q 6(#n)12 G(ote discouraging _)-6 E(@new = sort { substr\($a, 3, 5\) cmp substr\($b, 3, 5\) } @old;)152 252 Q F0 -.8(Wa)128 270 S .142(rning: syntactical care is required when\ sorting the list returned from a function. If you w).8 F .143 (ant to sort)-.1 F(the list returned by the function call)128 282 Q F1 (find_records\(@key\))2.5 E F0 2.5(,y)C(ou can use:)-2.5 E F1 (@contact = sort { $a cmp $b } find_records @key;)152 300 Q (@contact = sort +find_records\(@key\);)152 312 Q (@contact = sort &find_records\(@key\);)152 324 Q (@contact = sort\(find_records\(@key\)\);)152 336 Q F0 .295 (If instead you w)128 354 R .295(ant to sort the array)-.1 F F1(@key) 2.795 E F0 .294(with the comparison routine)2.795 F F1(find_records\(\)) 2.794 E F0 .294(then you)2.794 F(can use:)128 366 Q F1 (@contact = sort { find_records\(\) } @key;)152 384 Q (@contact = sort find_records\(@key\);)152 396 Q (@contact = sort\(find_records @key\);)152 408 Q (@contact = sort\(find_records \(@key\)\);)152 420 Q F0 1.045(If you') 128 438 R 1.045(re using strict, you)-.5 F/F2 10/Times-Italic@0 SF 1.045 (must not)3.545 F F0(declare)3.545 E F1($a)3.545 E F0(and)3.545 E F1($b) 3.545 E F0 1.045(as le)3.545 F 3.546(xicals. The)-.15 F 3.546(ya)-.15 G 1.046(re package globals.)-3.546 F(That)6.046 E(means that if you')128 450 Q(re in the)-.5 E F1(main)2.5 E F0(package and type)2.5 E F1 (@articles = sort {$b <=> $a} @files;)152 468 Q F0(then)128 486 Q F1($a) 2.793 E F0(and)2.793 E F1($b)2.793 E F0(are)2.793 E F1($main::a)2.793 E F0(and)2.793 E F1($main::b)2.792 E F0(\(or)2.792 E F1($::a)2.792 E F0 (and)2.792 E F1($::b)2.792 E F0 .292(\), b)B .292(ut if you')-.2 F .292 (re in the)-.5 F F1(FooPack)2.792 E F0(package, it')128 498 Q 2.5(st) -.55 G(he same as typing)-2.5 E F1 (@articles = sort {$FooPack::b <=> $FooPack::a} @files;)152 516 Q F0 1.317(The comparison function is required to beha)128 534 R -.15(ve)-.2 G 6.317(.I).15 G 3.817(fi)-6.317 G 3.817(tr)-3.817 G 1.317 (eturns inconsistent results \(sometimes saying)-3.817 F F1($x[1])128 546 Q F0 .537(is less than)3.037 F F1($x[2])3.037 E F0 .536 (and sometimes saying the opposite, for e)3.036 F .536 (xample\) the results are not well-)-.15 F(de\214ned.)128 558 Q(Because) 128 576 Q F1(<=>)3.985 E F0(returns)3.985 E F1(undef)3.985 E F0 1.485 (when either operand is)3.985 F F1(NaN)3.985 E F0 1.486 (\(not-a-number\), and laso because)3.986 F F1(sort)3.986 E F0 2.17 (raises an e)128 588 R 2.17(xception unless the result of a comparison \ is de\214ned, be careful when sorting with a)-.15 F 1.137 (comparison function lik)128 600 R(e)-.1 E F1 1.137($a <=> $b)3.637 F F0 (an)3.637 E 3.637(yl)-.15 G 1.137(ists that might contain a)-3.637 F F1 (NaN)3.638 E F0 6.138(.T)C 1.138(he follo)-6.138 F 1.138(wing e)-.25 F (xample)-.15 E(tak)128 612 Q(es adv)-.1 E(antage that)-.25 E F1 (NaN != NaN)2.5 E F0(to eliminate an)2.5 E(y)-.15 E F1(NaN)2.5 E F0 2.5 (sf)C(rom the input list.)-2.5 E F1 (@result = sort { $a <=> $b } grep { $_ == $_ } @input;)152 630 Q F0 (splice)108 646.8 Q/F3 9/Times-Roman@0 SF(ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR)2.5 E F0(,OFFSET)A(,LENGTH,LIST)-.74 E(splice)108 658.8 Q F3 (ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR)2.5 E F0(,OFFSET)A(,LENGTH) -.74 E(splice)108 670.8 Q F3(ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR) 2.5 E F0(,OFFSET)A(splice)108 682.8 Q F3(ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR)2.5 E F0(Remo)128 694.8 Q -.15(ve)-.15 G 2.876(st).15 G .376 (he elements designated by)-2.876 F F3(OFFSET)2.876 E F0(and)2.876 E F3 (LENGTH)2.875 E F0 .375(from an array)2.875 F 2.875(,a)-.65 G .375 (nd replaces them with the)-2.875 F 1.943(elements of)128 706.8 R F3 (LIST)4.443 E F0 4.443(,i)C 4.443(fa)-4.443 G -.15(ny)-4.443 G 6.943(.I) -.5 G 4.443(nl)-6.943 G 1.943(ist conte)-4.443 F 1.943 (xt, returns the elements remo)-.15 F -.15(ve)-.15 G 4.443(df).15 G 1.943(rom the array)-4.443 F 6.944(.I)-.65 G 4.444(ns)-6.944 G(calar) -4.444 E(conte)128 718.8 Q .437(xt, returns the last element remo)-.15 F -.15(ve)-.15 G .436(d, or).15 F F1(undef)2.936 E F0 .436 (if no elements are remo)2.936 F -.15(ve)-.15 G 2.936(d. The).15 F .436 (array gro)2.936 F .436(ws or)-.25 F .045(shrinks as necessary)128 730.8 R 5.045(.I)-.65 G(f)-5.045 E F3(OFFSET)2.545 E F0 .045(is ne)2.545 F -.05(ga)-.15 G(ti).05 E .345 -.15(ve t)-.25 H .045(hen it starts that f) .15 F .046(ar from the end of the array)-.1 F 5.046(.I)-.65 G(f)-5.046 E F3(LENGTH)2.546 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 74)162.62 F 0 Cg EP %%Page: 75 75 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .811 (is omitted, remo)128 84 R -.15(ve)-.15 G 3.31(se).15 G -.15(ve)-3.56 G .81(rything from).15 F/F1 9/Times-Roman@0 SF(OFFSET)3.31 E F0(onw)3.31 E 3.31(ard. If)-.1 F F1(LENGTH)3.31 E F0 .81(is ne)3.31 F -.05(ga)-.15 G (ti).05 E -.15(ve)-.25 G 3.31(,r).15 G(emo)-3.31 E -.15(ve)-.15 G 3.31 (st).15 G .81(he elements)-3.31 F(from)128 96 Q F1(OFFSET)3.791 E F0 (onw)3.791 E 1.291(ard e)-.1 F 1.291 (xcept for \255LENGTH elements at the end of the array)-.15 F 6.292(.I) -.65 G 3.792(fb)-6.292 G(oth)-3.792 E F1(OFFSET)3.792 E F0(and)3.792 E F1(LENGTH)128 108 Q F0 2.269(are omitted, remo)4.769 F -.15(ve)-.15 G 4.769(se).15 G -.15(ve)-5.019 G 2.269(rything. If).15 F F1(OFFSET)4.769 E F0 2.269(is past the end of the array)4.769 F 4.768(,P)-.65 G 2.268 (erl issues a)-4.768 F -.1(wa)128 120 S (rning, and splices at the end of the array).1 E(.)-.65 E(The follo)128 138 Q(wing equi)-.25 E -.25(va)-.25 G(lences hold \(assuming).25 E/F2 10 /Courier@0 SF($[ == 0 and $#a >= $i)2.5 E F0(\))2.5 E F2 30 (push\(@a,$x,$y\) splice\(@a,@a,0,$x,$y\))152 156 R 72 (pop\(@a\) splice\(@a,\2551\))152 168 R 60(shift\(@a\) splice\(@a,0,1\)) 152 180 R 12(unshift\(@a,$x,$y\) splice\(@a,0,0,$x,$y\))152 192 R ($a[$i] = $y)152 204 Q(splice\(@a,$i,1,$y\))54 E F0 (Example, assuming array lengths are passed before arrays:)128 222 Q F2 (sub aeq {)152 240 Q 6(#c)12 G(ompare two list values)-6 E (my\(@a\) = splice\(@_,0,shift\);)176 252 Q (my\(@b\) = splice\(@_,0,shift\);)176 264 Q(return 0 unless @a == @b;) 176 276 Q 6(#s)12 G(ame len?)-6 E(while \(@a\) {)176 288 Q (return 0 if pop\(@a\) ne pop\(@b\);)200 300 Q(})176 312 Q(return 1;)176 324 Q(})152 336 Q(if \(&aeq\($len,@foo[1..$len],0+@bar,@bar\)\) { ... }) 152 348 Q F0 .701(Starting with Perl 5.14,)128 366 R F2(splice)3.201 E F0 .701(can tak)3.201 F 3.201(es)-.1 G(calar)-3.201 E F1(EXPR)3.201 E F0 3.201(,w)C .701(hich must hold a reference to an unblessed)-3.201 F (array)128 378 Q 5.262(.T)-.65 G .262(he ar)-5.262 F .262 (gument will be dereferenced automatically)-.18 F 5.262(.T)-.65 G .261 (his aspect of)-5.262 F F2(splice)2.761 E F0 .261(is considered highly) 2.761 F -.15(ex)128 390 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(split /P)108 406.8 Q -1.11(AT)-.92 G(TERN/,EXPR,LIMIT)1.11 E (split /P)108 418.8 Q -1.11(AT)-.92 G(TERN/,EXPR)1.11 E(split /P)108 430.8 Q -1.11(AT)-.92 G(TERN/)1.11 E(split)108 442.8 Q .798 (Splits the string)128 454.8 R F1(EXPR)3.298 E F0 .799 (into a list of strings and returns that list.)3.298 F .799(By def)5.799 F .799(ault, empty leading \214elds are)-.1 F(preserv)128 466.8 Q 1.718 (ed, and empty trailing ones are deleted.)-.15 F 1.718 (\(If all \214elds are empty)6.718 F 4.218(,t)-.65 G(he)-4.218 E 4.218 (ya)-.15 G 1.718(re considered to be)-4.218 F(trailing.\))128 478.8 Q (In scalar conte)128 496.8 Q(xt, returns the number of \214elds found.) -.15 E(If)128 514.8 Q F1(EXPR)4.444 E F0 1.944(is omitted, splits the) 4.444 F F2($_)4.444 E F0 4.445(string. If)4.444 F F1 -.828(PA)4.445 G (TTERN)-.171 E F0 1.945(is also omitted, splits on whitespace \(after) 4.445 F .611(skipping an)128 526.8 R 3.111(yl)-.15 G .611 (eading whitespace\).)-3.111 F(An)5.611 E .611(ything matching)-.15 F F1 -.828(PA)3.111 G(TTERN)-.171 E F0 .61(is tak)3.111 F .61 (en to be a delimiter separating)-.1 F(the \214elds.)128 538.8 Q (\(Note that the delimiter may be longer than one character)5 E(.\))-.55 E(If)128 556.8 Q F1(LIMIT)3.119 E F0 .619(is speci\214ed and positi) 3.119 F -.15(ve)-.25 G 3.119(,i).15 G 3.119(tr)-3.119 G .62 (epresents the maximum number of \214elds the)-3.119 F F1(EXPR)3.12 E F0 .62(will be split)3.12 F .781(into, though the actual number of \214eld\ s returned depends on the number of times)128 568.8 R F1 -.828(PA)3.28 G (TTERN)-.171 E F0(matches)3.28 E(within)128 580.8 Q F1(EXPR)2.77 E F0 5.27(.I)C(f)-5.27 E F1(LIMIT)2.77 E F0 .27(is unspeci\214ed or zero, tr\ ailing null \214elds are stripped \(which potential users of)2.77 F F2 (pop)128 592.8 Q F0 -.1(wo)2.557 G .057(uld do well to remember\).).1 F (If)5.057 E F1(LIMIT)2.557 E F0 .057(is ne)2.557 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 2.557(,i).15 G 2.556(ti)-2.557 G 2.556(st)-2.556 G .056 (reated as if an arbitrarily lar)-2.556 F(ge)-.18 E F1(LIMIT)2.556 E F0 (had)2.556 E .052(been speci\214ed.)128 604.8 R .053 (Note that splitting an)5.052 F F1(EXPR)2.553 E F0 .053(that e)2.553 F -.25(va)-.25 G .053(luates to the empty string al).25 F -.1(wa)-.1 G .053(ys returns the empty).1 F(list, re)128 616.8 Q -.05(ga)-.15 G (rdless of the).05 E F1(LIMIT)2.5 E F0(speci\214ed.)2.5 E 3.104(Ap)128 634.8 S .604(attern matching the empty string \(not to be confused with\ an empty pattern)-3.104 F F2(//)3.104 E F0 3.104(,w)C .603 (hich is just one)-3.104 F .518 (member of the set of patterns matching the epmty string\), splits)128 646.8 R F1(EXPR)3.018 E F0 .518(into indi)3.018 F .518 (vidual characters.)-.25 F -.15(Fo)5.518 G(r).15 E -.15(ex)128 658.8 S (ample:).15 E F2 (print join\(\010:\010, split\(/ */, \010hi there\010\)\), "\\n";)152 676.8 Q F0(produces the output 'h:i:t:h:e:r:e'.)128 694.8 Q .049 (As a special case for)128 712.8 R F2(split)2.549 E F0 2.549(,t)C .049 (he empty pattern)-2.549 F F2(//)2.549 E F0 .049 (speci\214cally matches the empty string; this is not be)2.549 F 1.255(\ confused with the normal use of an empty pattern to mean the last succe\ ssful match.)128 724.8 R 1.256(So to split a)6.256 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 75)162.62 F 0 Cg EP %%Page: 76 76 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(string into indi) 128 84 Q(vidual characters, the follo)-.25 E(wing:)-.25 E/F1 10 /Courier@0 SF (print join\(\010:\010, split\(//, \010hi there\010\)\), "\\n";)152 102 Q F0(produces the output 'h:i: :t:h:e:r:e'.)128 120 Q 1.854 (Empty leading \214elds are produced when there are positi)128 138 R -.15(ve)-.25 G 1.853(-width matches at the be).15 F 1.853 (ginning of the)-.15 F(string; a zero-width match at the be)128 150 Q (ginning of the string does not produce an empty \214eld. F)-.15 E(or e) -.15 E(xample:)-.15 E F1 (print join\(\010:\010, split\(/\(?=\\w\)/, \010hi there!\010\)\);)146 168 Q F0 .545(produces the output 'h:i :t:h:e:r:e!'. Empty trailing \ \214elds, on the other hand, are produced when there)128 186 R .563 (is a match at the end of the string \(and when)128 198 R/F2 9 /Times-Roman@0 SF(LIMIT)3.063 E F0 .563(is gi)3.063 F -.15(ve)-.25 G 3.063(na).15 G .563(nd is not 0\), re)-3.063 F -.05(ga)-.15 G .563 (rdless of the length of).05 F(the match.)128 210 Q -.15(Fo)5 G 2.5(re) .15 G(xample:)-2.65 E F1(print join\(\010:\010, split\(//,)146 228 Q (\010hi there!\010, \2551\)\), "\\n";)18 E(print join\(\010:\010, split\ \(/\\W/, \010hi there!\010, \2551\)\), "\\n";)146 240 Q F0 (produce the output 'h:i: :t:h:e:r:e:!:' and 'hi:there:', respecti)128 258 Q -.15(ve)-.25 G(ly).15 E 2.5(,b)-.65 G (oth with an empty trailing \214eld.)-2.5 E(The)128 276 Q F2(LIMIT)2.5 E F0(parameter can be used to split a line partially)2.5 E F1 (\($login, $passwd, $remainder\) = split\(/:/, $_, 3\);)152 294 Q F0 .059(When assigning to a list, if)128 312 R F2(LIMIT)2.559 E F0 .059 (is omitted, or zero, Perl supplies a)2.559 F F2(LIMIT)2.559 E F0 .059 (one lar)2.559 F .06(ger than the number)-.18 F 1.117(of v)128 324 R 1.117(ariables in the list, to a)-.25 F -.2(vo)-.2 G 1.117 (id unnecessary w).2 F 3.617(ork. F)-.1 F 1.116(or the list abo)-.15 F -.15(ve)-.15 G F2(LIMIT)3.766 E F0 -.1(wo)3.616 G 1.116(uld ha).1 F 1.416 -.15(ve b)-.2 H 1.116(een 4 by).15 F(def)128 336 Q 2.5(ault. In) -.1 F(time critical applications it behoo)2.5 E -.15(ve)-.15 G 2.5(sy) .15 G(ou not to split into more \214elds than you really need.)-2.5 E 3.177(If the)128 354 R F2 -.828(PA)5.677 G(TTERN)-.171 E F0 3.177(conta\ ins parentheses, additional list elements are created from each matchin\ g)5.677 F(substring in the delimiter)128 366 Q(.)-.55 E F1 (split\(/\([,\255]\)/, "1\25510,20", 3\);)152 384 Q F0 (produces the list v)128 402 Q(alue)-.25 E F1 (\(1, \010\255\010, 10, \010,\010, 20\))152 420 Q F0 .617 (If you had the entire header of a normal Unix email message in)128 438 R F1($header)3.116 E F0 3.116(,y)C .616(ou could split it up into)-3.116 F(\214elds and their v)128 450 Q(alues this w)-.25 E(ay:)-.1 E F1 ($header =~ s/\\n\(?=\\s\)//g;)152 468 Q 6(#f)12 G (ix continuation lines)-6 E 12(%hdrs =)152 480 R (\(UNIX_FROM => split /^\(\\S*?\):\\s*/m, $header\);)12 E F0 .342 (The pattern)128 498 R F1(/PATTERN/)2.842 E F0 .343 (may be replaced with an e)2.842 F .343 (xpression to specify patterns that v)-.15 F .343(ary at runtime.)-.25 F (\(T)128 510 Q 2.5(od)-.8 G 2.5(or)-2.5 G (untime compilation only once, use)-2.5 E F1(/$variable/o)2.5 E F0(.\))A .012(As a special case, specifying a)128 528 R F2 -.828(PA)2.512 G (TTERN)-.171 E F0 .012(of space \()2.512 F F1<08c22008>A F0 2.512(\)w)C .012(ill split on white space just as)-2.512 F F1(split)2.512 E F0(with) 2.512 E 1.025(no ar)128 540 R 1.025(guments does.)-.18 F(Thus,)6.025 E F1(split\(\010\302 \010\))3.525 E F0 1.025(can be used to emulate)3.525 F/F3 10/Times-Bold@0 SF(awk)3.526 E F0 2.126 -.55('s d)D(ef).55 E 1.026 (ault beha)-.1 F(vior)-.2 E 3.526(,w)-.4 G(hereas)-3.526 E F1 (split\(/\302 /\))128 552 Q F0 .308(will gi)2.808 F .608 -.15(ve y)-.25 H .308(ou as man).15 F 2.808(yi)-.15 G .307 (nitial null \214elds \(empty string\) as there are leading spaces.) -2.808 F(A)5.307 E F1(split)128 564 Q F0(on)3.281 E F1(/\\s+/)3.281 E F0 .781(is lik)3.281 F 3.281(ea)-.1 G F1(split\(\010\302 \010\))A F0 -.15 (ex)3.281 G .781(cept that an).15 F 3.281(yl)-.15 G .782 (eading whitespace produces a null \214rst)-3.281 F 2.5(\214eld. A)128 576 R F1(split)2.5 E F0(with no ar)2.5 E(guments really does a)-.18 E F1 (split\(\010\302 \010,\302 $_\))2.5 E F0(internally)2.5 E(.)-.65 E(A)128 594 Q F2 -.828(PA)2.5 G(TTERN)-.171 E F0(of)2.5 E F1(/^/)2.5 E F0 (is treated as if it were)2.5 E F1(/^/m)2.5 E F0 2.5(,s)C(ince it isn') -2.5 E 2.5(tm)-.18 G(uch use otherwise.)-2.5 E(Example:)128 612 Q F1 (open\(PASSWD, \010/etc/passwd\010\);)152 630 Q(while \(\) {)152 642 Q(chomp;)176 654 Q(\($login, $passwd, $uid, $gid,)176 666 Q ($gcos, $home, $shell\) = split\(/:/\);)182 678 Q(#...)176 690 Q(})152 702 Q F0 .506(As with re)128 720 R .506(gular pattern matching, an)-.15 F 3.006(yc)-.15 G .506(apturing parentheses that are not matched in a) -3.006 F F1(split\(\))3.006 E F0(will)3.006 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 76)162.62 F 0 Cg EP %%Page: 77 77 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(be set to)128 84 Q /F1 10/Courier@0 SF(undef)2.5 E F0(when returned:)2.5 E F1 (@fields = split /\(A\)|B/, "1A2B3";)152 102 Q 6(#@)152 114 S (fields is \(1, \010A\010, 2, undef, 3\))-6 E F0(sprintf)108 130.8 Q/F2 9/Times-Roman@0 SF(FORMA)2.5 E(T)-.999 E F0(,)A F2(LIST)2.5 E F0 .102 (Returns a string formatted by the usual)128 142.8 R F1(printf)2.602 E F0(con)2.602 E -.15(ve)-.4 G .102(ntions of the C library function).15 F F1(sprintf)2.602 E F0 5.102(.S)C(ee)-5.102 E(belo)128 154.8 Q 3.194(wf) -.25 G .694(or more details and see)-3.194 F F1(sprintf\(3\))3.193 E F0 (or)3.193 E F1(printf\(3\))3.193 E F0 .693(on your system for an e)3.193 F .693(xplanation of)-.15 F(the general principles.)128 166.8 Q -.15(Fo) 128 184.8 S 2.5(re).15 G(xample:)-2.65 E F1 6(#F)176 202.8 S (ormat number with up to 8 leading zeroes)-6 E ($result = sprintf\("%08d", $number\);)176 214.8 Q 6(#R)176 238.8 S (ound number to 3 digits after decimal point)-6 E ($rounded = sprintf\("%.3f", $number\);)176 250.8 Q F0 .136 (Perl does its o)128 268.8 R(wn)-.25 E F1(sprintf)2.636 E F0 .136 (formatting: it emulates the C function)2.636 F/F3 10/Times-Italic@0 SF (sprintf)2.637 E F0 .137(\(3\), b)1.666 F .137(ut doesn')-.2 F 2.637(tu) -.18 G .137(se it e)-2.637 F(xcept)-.15 E 3.529 (for \215oating-point numbers, and e)128 280.8 R -.15(ve)-.25 G 6.029 (nt).15 G 3.529(hen only standard modi\214ers are allo)-6.029 F 6.029 (wed. Non-standard)-.25 F -.15(ex)128 292.8 S(tensions in your local).15 E F3(sprintf)2.5 E F0(\(3\) are therefore una)1.666 E -.25(va)-.2 G (ilable from Perl.).25 E(Unlik)128 310.8 Q(e)-.1 E F1(printf)3.267 E F0 (,)A F1(sprintf)3.267 E F0 .767 (does not do what you probably mean when you pass it an array as your) 3.267 F .712(\214rst ar)128 322.8 R .712(gument. The array is gi)-.18 F -.15(ve)-.25 G 3.212(ns).15 G .712(calar conte)-3.212 F .711 (xt, and instead of using the 0th element of the array as)-.15 F(the fo\ rmat, Perl will use the count of elements in the array as the format, w\ hich is almost ne)128 334.8 Q -.15(ve)-.25 G 2.5(ru).15 G(seful.)-2.5 E (Perl')128 352.8 Q(s)-.55 E F1(sprintf)2.5 E F0(permits the follo)2.5 E (wing uni)-.25 E -.15(ve)-.25 G(rsally-kno).15 E(wn con)-.25 E -.15(ve) -.4 G(rsions:).15 E F1 18(%% a)146 370.8 R(percent sign)6 E 18(%c a)146 382.8 R(character with the given number)6 E 18(%s a)146 394.8 R(string)6 E 18(%d a)146 406.8 R(signed integer, in decimal)6 E 18(%u an)146 418.8 R(unsigned integer, in decimal)6 E 18(%o an)146 430.8 R (unsigned integer, in octal)6 E 18(%x an)146 442.8 R (unsigned integer, in hexadecimal)6 E 18(%e a)146 454.8 R (floating\255point number, in scientific notation)6 E 18(%f a)146 466.8 R(floating\255point number, in fixed decimal notation)6 E 18(%g a)146 478.8 R(floating\255point number, in %e or %f notation)6 E F0 (In addition, Perl permits the follo)128 496.8 Q (wing widely-supported con)-.25 E -.15(ve)-.4 G(rsions:).15 E F1 18 (%X like)146 514.8 R(%x, but using upper\255case letters)6 E 18(%E like) 146 526.8 R(%e, but using an upper\255case "E")6 E 18(%G like)146 538.8 R(%g, but with an upper\255case "E" \(if applicable\))6 E 18(%b an)146 550.8 R(unsigned integer, in binary)6 E 18(%B like)146 562.8 R (%b, but using an upper\255case "B" with the # flag)6 E 18(%p a)146 574.8 R(pointer \(outputs the Perl value\010s address in hexadecimal\))6 E 18(%n special:)146 586.8 R (*stores* the number of characters output so far)6 E (into the next variable in the parameter list)176 598.8 Q F0(Finally)128 616.8 Q 2.542(,f)-.65 G .042(or backw)-2.542 F .042 (ard \(and we do mean `)-.1 F(`backw)-.74 E(ard')-.1 E .042 ('\) compatibility)-.74 F 2.542(,P)-.65 G .043 (erl permits these unnecessary b)-2.542 F(ut)-.2 E(widely-supported con) 128 628.8 Q -.15(ve)-.4 G(rsions:).15 E F1 18(%i a)146 646.8 R (synonym for %d)6 E 18(%D a)146 658.8 R(synonym for %ld)6 E 18(%U a)146 670.8 R(synonym for %lu)6 E 18(%O a)146 682.8 R(synonym for %lo)6 E 18 (%F a)146 694.8 R(synonym for %f)6 E F0 .418(Note that the number of e) 128 712.8 R .418 (xponent digits in the scienti\214c notation produced by)-.15 F F1(%e) 2.918 E F0(,)A F1(%E)2.918 E F0(,)A F1(%g)2.917 E F0(and)2.917 E F1(%G) 2.917 E F0(for)2.917 E .537(numbers with the modulus of the e)128 724.8 R .537 (xponent less than 100 is system-dependent: it may be three or less)-.15 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 77)162.62 F 0 Cg EP %%Page: 78 78 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.081 (\(zero-padded as necessary\).)128 84 R 1.081(In other w)6.081 F 1.081 (ords, 1.23 times ten to the 99th may be either `)-.1 F(`1.23e99')-.74 E 3.58('o)-.74 G(r)-3.58 E -.74(``)128 96 S(1.23e099').74 E('.)-.74 E 1.833(Between the)128 114 R/F1 10/Courier@0 SF(%)4.333 E F0 1.833 (and the format letter)4.333 F 4.334(,y)-.4 G 1.834(ou may specify se) -4.334 F -.15(ve)-.25 G 1.834(ral additional attrib).15 F 1.834 (utes controlling the)-.2 F(interpretation of the format.)128 126 Q (In order)5 E 2.5(,t)-.4 G(hese are:)-2.5 E(format parameter inde)128 142.8 Q(x)-.15 E .985(An e)148 154.8 R .985 (xplicit format parameter inde)-.15 F .985(x, such as)-.15 F F1(2$)3.485 E F0 3.485(.B)C 3.485(yd)-3.485 G(ef)-3.485 E .984 (ault sprintf will format the ne)-.1 F .984(xt unused)-.15 F(ar)148 166.8 Q(gument in the list, b)-.18 E(ut this allo)-.2 E(ws you to tak) -.25 E 2.5(et)-.1 G(he ar)-2.5 E(guments out of order:)-.18 E F1 (printf \010%2$d %1$d\010, 12, 34;)160 184.8 Q 6(#p)36 G(rints "34 12") -6 E(printf \010%3$d %d %1$d\010, 1, 2, 3;)160 196.8 Q 6(#p)12 G (rints "3 1 1")-6 E F0(\215ags)128 213.6 Q(one or more of:)148 225.6 Q F1 12(space prefix)166 243.6 R(non\255negative number with a space)6 E 42(+p)166 255.6 S(refix non\255negative number with a plus sign)-42 E 42 166 267.6 S(eft\255justify within the field)-42 E 42(0u)166 279.6 S(se zeros, not spaces, to right\255justify)-42 E 42(#e)166 291.6 S (nsure the leading "0" for any octal,)-42 E (prefix non\255zero hexadecimal with "0x" or "0X",)214 303.6 Q (prefix non\255zero binary with "0b" or "0B")214 315.6 Q F0 -.15(Fo)148 333.6 S 2.5(re).15 G(xample:)-2.65 E F1(printf \010<% d>\010,)160 351.6 Q 12(12; #)12 F(prints "< 12>")6 E(printf \010<%+d>\010,)160 363.6 Q 12 (12; #)12 F(prints "<+12>")6 E(printf \010<%6s>\010,)160 375.6 Q 12 (12; #)12 F(prints "<)6 E(12>")24 E(printf \010<%\2556s>\010, 12;)160 387.6 Q 6(#p)18 G(rints "<12)-6 E(>")24 E(printf \010<%06s>\010, 12;)160 399.6 Q 6(#p)18 G(rints "<000012>")-6 E(printf \010<%#o>\010,)160 411.6 Q 12(12; #)12 F(prints "<014>")6 E(printf \010<%#x>\010,)160 423.6 Q 12 (12; #)12 F(prints "<0xc>")6 E(printf \010<%#X>\010,)160 435.6 Q 12 (12; #)12 F(prints "<0XC>")6 E(printf \010<%#b>\010,)160 447.6 Q 12 (12; #)12 F(prints "<0b1100>")6 E(printf \010<%#B>\010,)160 459.6 Q 12 (12; #)12 F(prints "<0B1100>")6 E F0 .117 (When a space and a plus sign are gi)148 477.6 R -.15(ve)-.25 G 2.617 (na).15 G 2.617(st)-2.617 G .117 (he \215ags at once, a plus sign is used to pre\214x a positi)-2.617 F -.15(ve)-.25 G(number)148 489.6 Q(.)-.55 E F1 (printf \010<%+ d>\010, 12;)160 507.6 Q 6(#p)18 G(rints "<+12>")-6 E (printf \010<% +d>\010, 12;)160 519.6 Q 6(#p)18 G(rints "<+12>")-6 E F0 .01(When the # \215ag and a precision are gi)148 537.6 R -.15(ve)-.25 G 2.51(ni).15 G 2.51(nt)-2.51 G(he)-2.51 E F1(%o)2.51 E F0(con)2.51 E -.15 (ve)-.4 G .01(rsion, the precision is incremented if it').15 F(s)-.55 E (necessary for the leading `)148 549.6 Q(`0')-.74 E('.)-.74 E F1 (printf \010<%#.5o>\010, 012;)160 567.6 Q 6(#p)36 G(rints "<00012>")-6 E (printf \010<%#.5o>\010, 012345;)160 579.6 Q 6(#p)18 G(rints "<012345>") -6 E(printf \010<%#.0o>\010, 0;)160 591.6 Q 6(#p)48 G(rints "<0>")-6 E F0 -.15(ve)128 608.4 S(ctor \215ag).15 E .116 (This \215ag tells Perl to interpret the supplied string as a v)148 620.4 R .117(ector of inte)-.15 F .117(gers, one for each character in) -.15 F .929(the string. Perl applies the format to each inte)148 632.4 R .929(ger in turn, then joins the resulting strings with a)-.15 F 1.01 (separator \(a dot)148 644.4 R F1(.)3.51 E F0 1.01(by def)3.51 F 1.01 (ault\). This can be useful for displaying ordinal v)-.1 F 1.01 (alues of characters in)-.25 F(arbitrary strings:)148 656.4 Q F1 (printf "%vd", "AB\\x{100}";)160 674.4 Q 6(#p)66 G(rints "65.66.256")-6 E(printf "version is v%vd\\n", $^V;)160 686.4 Q 6(#P)30 G (erl\010s version)-6 E F0(Put an asterisk)148 704.4 Q F1(*)2.5 E F0 (before the)2.5 E F1(v)2.5 E F0(to o)2.5 E -.15(ve)-.15 G (rride the string to use to separate the numbers:).15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 78)162.62 F 0 Cg EP %%Page: 79 79 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (printf "address is %*vX\\n", ":", $addr;)160 84 Q 6(#I)18 G (Pv6 address)-6 E(printf "bits are %0*v8b\\n", " ", $bits;)160 96 Q 6 (#r)18 G(andom bitstring)-6 E F0 -1.1(Yo)148 114 S 3.49(uc)1.1 G .99 (an also e)-3.49 F .99(xplicitly specify the ar)-.15 F .99 (gument number to use for the join string using something)-.18 F(lik)148 126 Q(e)-.1 E F1(*2$v)2.5 E F0 2.5(;f)C(or e)-2.5 E(xample:)-.15 E F1 (printf \010%*4$vX %*4$vX %*4$vX\010, @addr[1..3], ":";)160 144 Q 6(#3I) 18 G(Pv6 addresses)-6 E F0(\(minimum\) width)128 160.8 Q(Ar)148 172.8 Q .787(guments are usually formatted to be only as wide as required to di\ splay the gi)-.18 F -.15(ve)-.25 G 3.288(nv).15 G .788(alue. Y)-3.538 F (ou)-1.1 E .682(can o)148 184.8 R -.15(ve)-.15 G .681 (rride the width by putting a number here, or get the width from the ne) .15 F .681(xt ar)-.15 F .681(gument \(with)-.18 F F1(*)148 196.8 Q F0 2.5(\)o)C 2.5(rf)-2.5 G(rom a speci\214ed ar)-2.5 E(gument \(e.g., with) -.18 E F1(*2$)2.5 E F0(\):)A F1(printf "<%s>", "a";)160 214.8 Q 6(#p)42 G(rints "")-6 E(printf "<%6s>", "a";)160 226.8 Q 6(#p)36 G(rints "<) -6 E(a>")30 E(printf "<%*s>", 6, "a";)160 238.8 Q 6(#p)18 G(rints "<)-6 E(a>")30 E(printf "<%*2$s>", "a", 6; # prints "<)160 250.8 Q(a>")30 E (printf "<%2s>", "long";)160 262.8 Q 6(#p)18 G (rints "" \(does not truncate\))-6 E F0 2.565 (If a \214eld width obtained through)148 280.8 R F1(*)5.065 E F0 2.565 (is ne)5.065 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 5.066(,i).15 G 5.066(th)-5.066 G 2.566(as the same ef)-5.066 F 2.566(fect as the)-.25 F F15.066 E F0 2.566(\215ag: left-)5.066 F(justi\214cation.)148 292.8 Q(precision, or maximum width)128 309.6 Q -1.1(Yo)148 321.6 S 6.141(uc) 1.1 G 3.641(an specify a precision \(for numeric con)-6.141 F -.15(ve) -.4 G 3.641(rsions\) or a maximum width \(for string).15 F(con)148 333.6 Q -.15(ve)-.4 G .232(rsions\) by specifying a).15 F F1(.)2.732 E F0 (follo)2.732 E .232(wed by a number)-.25 F 5.232(.F)-.55 G .232 (or \215oating-point formats e)-5.382 F(xcept)-.15 E F1(g)2.732 E F0 (and)2.732 E F1(G)2.732 E F0(,)A 1.642(this speci\214es ho)148 345.6 R 4.142(wm)-.25 G(an)-4.142 E 4.142(yp)-.15 G 1.642 (laces right of the decimal point to sho)-4.142 F 4.142(w\()-.25 G 1.642 (the def)-4.142 F 1.642(ault being 6\).)-.1 F -.15(Fo)6.641 G(r).15 E -.15(ex)148 357.6 S(ample:).15 E F1 6(#t)160 375.6 S (hese examples are subject to system\255specific variation)-6 E (printf \010<%f>\010, 1;)160 387.6 Q 6(#p)24 G(rints "<1.000000>")-6 E (printf \010<%.1f>\010, 1;)160 399.6 Q 6(#p)12 G(rints "<1.0>")-6 E (printf \010<%.0f>\010, 1;)160 411.6 Q 6(#p)12 G(rints "<1>")-6 E (printf \010<%e>\010, 10;)160 423.6 Q 6(#p)18 G(rints "<1.000000e+01>") -6 E(printf \010<%.1e>\010, 10; # prints "<1.0e+01>")160 435.6 Q F0 -.15 (Fo)148 453.6 S 3.12(r`).15 G(`g')-3.86 E 3.12('a)-.74 G .62(nd `)-3.12 F(`G')-.74 E .621 (', this speci\214es the maximum number of digits to sho)-.74 F 1.921 -.65(w, i)-.25 H .621(ncluding thoe prior to).65 F (the decimal point and those after it; for e)148 465.6 Q(xample:)-.15 E F1 6(#T)160 483.6 S (hese examples are subject to system\255specific variation.)-6 E (printf \010<%g>\010, 1;)160 495.6 Q 6(#p)48 G(rints "<1>")-6 E (printf \010<%.10g>\010, 1;)160 507.6 Q 6(#p)30 G(rints "<1>")-6 E (printf \010<%g>\010, 100;)160 519.6 Q 6(#p)36 G(rints "<100>")-6 E (printf \010<%.1g>\010, 100;)160 531.6 Q 6(#p)24 G(rints "<1e+02>")-6 E (printf \010<%.2g>\010, 100.01; # prints "<1e+02>")160 543.6 Q (printf \010<%.5g>\010, 100.01; # prints "<100.01>")160 555.6 Q (printf \010<%.4g>\010, 100.01; # prints "<100>")160 567.6 Q F0 -.15(Fo) 148 585.6 S 2.726(ri).15 G(nte)-2.726 E .226(ger con)-.15 F -.15(ve)-.4 G .226(rsions, specifying a precision implies that the output of the nu\ mber itself should).15 F (be zero-padded to this width, where the 0 \215ag is ignored:)148 597.6 Q F1(printf \010<%.6d>\010, 1;)160 615.6 Q 6(#p)36 G(rints "<000001>")-6 E(printf \010<%+.6d>\010, 1;)160 627.6 Q 6(#p)30 G(rints "<+000001>")-6 E(printf \010<%\25510.6d>\010, 1;)160 639.6 Q 6(#p)18 G(rints "<000001) -6 E(>")24 E(printf \010<%10.6d>\010, 1;)160 651.6 Q 6(#p)24 G(rints "<) -6 E(000001>")24 E(printf \010<%010.6d>\010, 1;)160 663.6 Q 6(#p)18 G (rints "<)-6 E(000001>")24 E(printf \010<%+10.6d>\010, 1;)160 675.6 Q 6 (#p)18 G(rints "<)-6 E(+000001>")18 E(printf \010<%.6x>\010, 1;)160 699.6 Q 6(#p)36 G(rints "<000001>")-6 E(printf \010<%#.6x>\010, 1;)160 711.6 Q 6(#p)30 G(rints "<0x000001>")-6 E (printf \010<%\25510.6x>\010, 1;)160 723.6 Q 6(#p)18 G(rints "<000001)-6 E(>")24 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 79)162.62 F 0 Cg EP %%Page: 80 80 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (printf \010<%10.6x>\010, 1;)160 84 Q 6(#p)24 G(rints "<)-6 E(000001>") 24 E(printf \010<%010.6x>\010, 1;)160 96 Q 6(#p)18 G(rints "<)-6 E (000001>")24 E(printf \010<%#10.6x>\010, 1;)160 108 Q 6(#p)18 G (rints "<)-6 E(0x000001>")12 E F0 -.15(Fo)148 126 S 2.5(rs).15 G (tring con)-2.5 E -.15(ve)-.4 G(rsions, specifying a precision truncate\ s the string to \214t the speci\214ed width:).15 E F1 (printf \010<%.5s>\010, "truncated";)160 144 Q 6(#p)18 G (rints "")-6 E(printf \010<%10.5s>\010, "truncated"; # prints "<) 160 156 Q(trunc>")30 E F0 -1.1(Yo)148 174 S 2.5(uc)1.1 G (an also get the precision from the ne)-2.5 E(xt ar)-.15 E(gument using) -.18 E F1(.*)2.5 E F0(:)A F1(printf \010<%.6x>\010, 1;)160 192 Q 6(#p)42 G(rints "<000001>")-6 E(printf \010<%.*x>\010, 6, 1;)160 204 Q 6(#p)24 G (rints "<000001>")-6 E F0(If a precision obtained through)148 222 Q F1 (*)2.5 E F0(is ne)2.5 E -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 2.5(,i) .15 G 2.5(tc)-2.5 G(ounts as ha)-2.5 E(ving no precision at all.)-.2 E F1(printf \010<%.*s>\010,)160 240 Q(7, "string";)12 E 6(#p)18 G (rints "")-6 E(printf \010<%.*s>\010,)160 252 Q(3, "string";)12 E 6(#p)18 G(rints "")-6 E(printf \010<%.*s>\010,)160 264 Q (0, "string";)12 E 6(#p)18 G(rints "<>")-6 E (printf \010<%.*s>\010, \2551, "string";)160 276 Q 6(#p)18 G (rints "")-6 E(printf \010<%.*d>\010,)160 300 Q(1, 0;)12 E 6(#p) 18 G(rints "<0>")-6 E(printf \010<%.*d>\010,)160 312 Q(0, 0;)12 E 6(#p) 18 G(rints "<>")-6 E(printf \010<%.*d>\010, \2551, 0;)160 324 Q 6(#p)18 G(rints "<0>")-6 E F0 -1.1(Yo)148 342 S 2.72(uc)1.1 G .22 (annot currently get the precision from a speci\214ed number)-2.72 F 2.72(,b)-.4 G .22(ut it is intended that this will be)-2.92 F (possible in the future, for e)148 354 Q(xample using)-.15 E F1(.*2$)2.5 E F0(:)A F1(printf "<%.*2$x>", 1, 6;)160 372 Q 6(#I)18 G (NVALID, but in future will print "<000001>")-6 E F0(size)128 388.8 Q -.15(Fo)148 400.8 S 2.962(rn).15 G .462(umeric con)-2.962 F -.15(ve)-.4 G .462 (rsions, you can specify the size to interpret the number as using).15 F F1(l)2.961 E F0(,)A F1(h)2.961 E F0(,)A F1(V)2.961 E F0(,)A F1(q)2.961 E F0(,)A F1(L)2.961 E F0(,)A(or)148 412.8 Q F1(ll)2.636 E F0 2.636(.F)C .136(or inte)-2.786 F .136(ger con)-.15 F -.15(ve)-.4 G .136(rsions \() .15 F F1 -12.135 6.136(duoxXb i D U O)D F0 .137 (\), numbers are usually assumed to be)-6.136 F(whate)148 424.8 Q -.15 (ve)-.25 G 2.82(rt).15 G .32(he def)-2.82 F .32(ault inte)-.1 F .32 (ger size is on your platform \(usually 32 or 64 bits\), b)-.15 F .32 (ut you can o)-.2 F -.15(ve)-.15 G(rride).15 E(this to use instead one \ of the standard C types, as supported by the compiler used to b)148 436.8 Q(uild Perl:)-.2 E F1 54(hh interpret)166 454.8 R (integer as C type "char" or "unsigned char")6 E(on Perl 5.14 or later) 238 466.8 Q 66(hi)166 478.8 S (nterpret integer as C type "short" or "unsigned short")-66 E 66(ji)166 490.8 S(ntepret integer as C type "intmax_t" on Perl 5.14)-66 E (or later, and only with a C99 compiler \(unportable\))238 502.8 Q 66 (li)166 514.8 S(nterpret integer as C type "long" or "unsigned long")-66 E(q, L, or ll interpret integer as C type "long long", "unsigned long l\ ong",)166 526.8 Q(or "quad" \(typically 64\255bit integers\))238 538.8 Q 66(ti)166 550.8 S (ntepret integer as C type "ptrdiff_t" on Perl 5.14 or later)-66 E 66 (zi)166 562.8 S (ntepret integer as C type "size_t" on Perl 5.14 or later)-66 E F0 2.526 (As of 5.14, none of these raises an e)148 580.8 R 2.526 (xception if the)-.15 F 5.026(ya)-.15 G 2.527 (re not supported on your platform.)-5.026 F(Ho)148 592.8 Q(we)-.25 E -.15(ve)-.25 G 2.87 -.4(r, i).15 H 4.57(fw).4 G 2.07 (arnings are enabled, a w)-4.67 F 2.069(arning of the)-.1 F F1(printf) 4.569 E F0 -.1(wa)4.569 G 2.069(rning class is issued on an).1 F (unsupported con)148 604.8 Q -.15(ve)-.4 G(rsion \215ag.).15 E (Should you instead prefer an e)5 E(xception, do this:)-.15 E F1 (use warnings FATAL => "printf";)172 622.8 Q F0 .436(If you w)148 640.8 R .436(ould lik)-.1 F 2.936(et)-.1 G 2.936(ok)-2.936 G(no)-2.936 E 2.936 (wa)-.25 G .436(bout a v)-2.936 F .436(ersion dependenc)-.15 F 2.936(yb) -.15 G .437(efore you start running the program, put)-2.936 F (something lik)148 652.8 Q 2.5(et)-.1 G(his at its top:)-2.5 E F1 (use 5.014;)172 670.8 Q 6(#f)12 G(or hh/j/t/z/ printf modifiers)-6 E F0 -1.1(Yo)148 688.8 S 2.5(uc)1.1 G (an \214nd out whether your Perl supports quads via Con\214g:)-2.5 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 80)162.62 F 0 Cg EP %%Page: 81 81 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Config;)172 84 Q (if \($Config{use64bitint} eq "define" || $Config{longsize} >= 8\) {)172 96 Q(print "Nice quads!\\n";)196 108 Q(})172 120 Q F0 -.15(Fo)148 138 S 2.928<728d>.15 G .428(oating-point con)-2.928 F -.15(ve)-.4 G .428 (rsions \().15 F F1 6.428(efgEFG)C F0 .427 (\), numbers are usually assumed to be the def)-6.428 F(ault)-.1 E 1.12 (\215oating-point size on your platform \(double or long double\), b)148 150 R 1.12(ut you can force `)-.2 F 1.12(`long double')-.74 F(')-.74 E (with)148 162 Q F1(q)3.691 E F0(,)A F1(L)3.691 E F0 3.691(,o)C(r)-3.691 E F1(ll)3.691 E F0 1.191(if your platform supports them. Y)3.691 F 1.19 (ou can \214nd out whether your Perl supports)-1.1 F (long doubles via Con\214g:)148 174 Q F1(use Config;)172 192 Q (print "long doubles\\n" if $Config{d_longdbl} eq "define";)172 204 Q F0 -1.1(Yo)148 222 S 2.656(uc)1.1 G .157 (an \214nd out whether Perl considers `)-2.656 F .157(`long double')-.74 F 2.657('t)-.74 G 2.657(ob)-2.657 G 2.657(et)-2.657 G .157(he def)-2.657 F .157(ault \215oating-point size to use)-.1 F (on your platform via Con\214g:)148 234 Q F1(use Config;)172 252 Q (if \($Config{uselongdouble} eq "define"\) {)172 264 Q (print "long doubles by default\\n";)196 276 Q(})172 288 Q F0 (It can also be that long doubles and doubles are the same thing:)148 306 Q F1(use Config;)196 324 Q (\($Config{doublesize} == $Config{longdblsize}\) &&)196 336 Q (print "doubles are long doubles\\n";)244 348 Q F0 .54 (The size speci\214er)148 366 R F1(V)3.04 E F0 .54(has no ef)3.04 F .54 (fect for Perl code, b)-.25 F .54 (ut is supported for compatibility with)-.2 F/F2 9/Times-Roman@0 SF(XS) 3.039 E F0(code.)3.039 E(It means `)148 378 Q (`use the standard size for a Perl inte)-.74 E (ger or \215oating-point number')-.15 E(', which is the def)-.74 E (ault.)-.1 E(order of ar)128 394.8 Q(guments)-.18 E(Normally)148 406.8 Q (,)-.65 E/F3 10/Times-Italic@0 SF(sprintf\(\))5.024 E F0(tak)5.024 E 2.524(es the ne)-.1 F 2.524(xt unused ar)-.15 F 2.524(gument as the v) -.18 F 2.525(alue to format for each format)-.25 F 3.067 (speci\214cation. If the format speci\214cation uses)148 418.8 R F1(*) 5.567 E F0 3.066(to require additional ar)5.567 F 3.066 (guments, these are)-.18 F .869(consumed from the ar)148 430.8 R .869 (gument list in the order the)-.18 F 3.369(ya)-.15 G .87 (ppear in the format speci\214cation)-3.369 F F3(befor)3.37 E(e)-.37 E F0(the)3.37 E -.25(va)148 442.8 S 1.319(lue to format.).25 F 1.319 (Where an ar)6.319 F 1.319(gument is speci\214ed by an e)-.18 F 1.319 (xplicit inde)-.15 F 1.318(x, this does not af)-.15 F 1.318(fect the) -.25 F 1.255(normal order for the ar)148 454.8 R 1.255(guments, e)-.18 F -.15(ve)-.25 G 3.755(nw).15 G 1.255(hen the e)-3.755 F 1.255 (xplicitly speci\214ed inde)-.15 F 3.755(xw)-.15 G 1.255(ould ha)-3.855 F 1.555 -.15(ve b)-.2 H 1.255(een the).15 F(ne)148 466.8 Q(xt ar)-.15 E (gument.)-.18 E(So:)148 484.8 Q F1(printf "<%*.*s>", $a, $b, $c;)172 502.8 Q F0(uses)148 520.8 Q F1($a)2.5 E F0(for the width,)2.5 E F1($b) 2.5 E F0(for the precision, and)2.5 E F1($c)2.5 E F0(as the v)2.5 E (alue to format; while:)-.25 E F1(printf "<%*1$.*s>", $a, $b;)160 538.8 Q F0 -.1(wo)148 556.8 S(uld use).1 E F1($a)2.5 E F0 (for the width and precision, and)2.5 E F1($b)2.5 E F0(as the v)2.5 E (alue to format.)-.25 E 1.796(Here are some more e)148 574.8 R 1.796 (xamples; be a)-.15 F -.1(wa)-.15 G 1.796(re that when using an e).1 F 1.795(xplicit inde)-.15 F 1.795(x, the)-.15 F F1($)4.295 E F0 1.795 (may need)4.295 F(escaping:)148 586.8 Q F1(printf "%2\\$d %d\\n",)160 604.8 Q(12, 34;)24 E 6(#w)48 G(ill print "34 12\\n")-6 E (printf "%2\\$d %d %d\\n", 12, 34;)160 616.8 Q 6(#w)48 G (ill print "34 12 34\\n")-6 E(printf "%3\\$d %d %d\\n", 12, 34, 56;)160 628.8 Q 6(#w)24 G(ill print "56 12 34\\n")-6 E (printf "%2\\$*3\\$d %d\\n", 12, 34, 3;)160 640.8 Q 6(#w)24 G (ill print " 34 12\\n")-6 E F0(If)128 658.8 Q F1 2.176(use locale)4.676 F F0 2.176(is in ef)4.676 F 2.176(fect and)-.25 F F3 (POSIX::setlocale\(\))4.676 E F0 2.176 (has been called, the character used for the)4.676 F 1.373 (decimal separator in formatted \215oating-point numbers is af)128 670.8 R 1.373(fected by the)-.25 F F2(LC_NUMERIC)3.873 E F0 3.873(locale. See) 3.873 F(perllocale and)128 682.8 Q F2(POSIX)2.5 E F0(.)A(sqrt)108 699.6 Q F2(EXPR)2.5 E F0(sqrt)108 711.6 Q .763(Return the positi)128 711.6 R 1.064 -.15(ve s)-.25 H .764(quare root of).15 F F2(EXPR)3.264 E F0 5.764 (.I)C(f)-5.764 E F2(EXPR)3.264 E F0 .764(is omitted, uses)3.264 F F1($_) 3.264 E F0 5.764(.W)C .764(orks only for non-ne)-6.564 F -.05(ga)-.15 G (ti).05 E -.15(ve)-.25 G(operands unless you')128 723.6 Q .3 -.15(ve l) -.5 H(oaded the).15 E F1(Math::Complex)2.5 E F0(module.)2.5 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 81)162.62 F 0 Cg EP %%Page: 82 82 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Math::Complex;)152 84 Q(print sqrt\(\2554\);)152 96 Q 6(#p)24 G (rints 2i)-6 E F0(srand)108 112.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0 (srand)108 124.8 Q(Sets and returns the random number seed for the)128 136.8 Q F1(rand)2.5 E F0(operator)2.5 E(.)-.55 E 1.959 (The point of the function is to `)128 154.8 R(`seed')-.74 E 4.459('t) -.74 G(he)-4.459 E F1(rand)4.459 E F0 1.959(function so that)4.459 F F1 (rand)4.459 E F0 1.958(can produce a dif)4.459 F(ferent)-.25 E .972 (sequence each time you run your program.)128 166.8 R .972 (When called with a parameter)5.972 F(,)-.4 E F1(srand)3.472 E F0 .972 (uses that for the)3.472 F .873 (seed; otherwise it \(semi\255\)randomly chooses a seed.)128 178.8 R .872(In either case, starting with Perl 5.14, it returns)5.873 F (the seed.)128 190.8 Q(If)128 208.8 Q F1(srand\(\))3.425 E F0 .925 (is not called e)3.425 F(xplicitly)-.15 E 3.425(,i)-.65 G 3.425(ti) -3.425 G 3.425(sc)-3.425 G .926 (alled implicitly without a parameter at the \214rst use of the)-3.425 F F1(rand)128 220.8 Q F0(operator)2.943 E 5.443(.H)-.55 G -.25(ow)-5.443 G -2.15 -.25(ev e).25 H 1.243 -.4(r, t).25 H .443(his w).4 F .443 (as not true of v)-.1 F .443 (ersions of Perl before 5.004, so if your script will run)-.15 F (under older Perl v)128 232.8 Q(ersions, it should call)-.15 E F1(srand) 2.5 E F0 2.5(;o)C(therwise most programs w)-2.5 E(on')-.1 E 2.5(tc)-.18 G(all)-2.5 E F1(srand\(\))2.5 E F0(at all.)2.5 E .176 (But there are a fe)128 250.8 R 2.677(ws)-.25 G .177 (ituations in recent Perls where programs are lik)-2.677 F .177 (ely to w)-.1 F .177(ant to call)-.1 F F1(srand)2.677 E F0 5.177(.O)C .177(ne is)-5.177 F 6.823 (for generating predictable results generally for testing or deb)128 262.8 R 9.322(ugging. There,)-.2 F 6.822(you use)9.322 F F1 (srand\($seed\))128 274.8 Q F0 5.421(,w)C 2.921(ith the same)-5.421 F F1 ($seed)5.421 E F0 2.921(each time.)5.421 F 2.922 (Another other case is where you need a)7.921 F .529(cryptographically-\ strong starting point rather than the generally acceptable def)128 286.8 R .529(ault, which is based on)-.1 F 1.317(time of day)128 298.8 R 3.817 (,p)-.65 G(rocess)-3.817 E F2(ID)3.817 E F0 3.817(,a)C 1.318 (nd memory allocation, or the)-3.817 F/F3 10/Times-Italic@0 SF(/de)3.818 E(v/ur)-.15 E(andom)-.15 E F0(de)3.818 E 1.318(vice if a)-.25 F -.25(va) -.2 G 3.818(ilable. And).25 F(still)3.818 E .514 (another case is that you may w)128 310.8 R .514(ant to call)-.1 F F1 (srand\(\))3.014 E F0 .513(after a)3.013 F F1(fork\(\))3.013 E F0 .513 (to a)3.013 F -.2(vo)-.2 G .513(id child processes sharing).2 F (the same seed v)128 322.8 Q (alue as the parent \(and consequently each other\).)-.25 E(Do)128 340.8 Q/F4 10/Times-Bold@0 SF(not)3.331 E F0(call)3.331 E F1(srand\(\))3.332 E F0 .832(\(i.e., without an ar)3.332 F .832 (gument\) more than once per process.)-.18 F .832(The internal state of) 5.832 F 1.795(the random number generator should contain more entrop)128 352.8 R 4.295(yt)-.1 G 1.795(han can be pro)-4.295 F 1.794(vided by an) -.15 F 4.294(ys)-.15 G 1.794(eed, so)-4.294 F(calling)128 364.8 Q F1 (srand\(\))2.5 E F0(ag)2.5 E(ain actually)-.05 E F3(loses)2.5 E F0 (randomness.)2.5 E 1.521(Most implementations of)128 382.8 R F1(srand) 4.021 E F0(tak)4.021 E 4.021(ea)-.1 G 4.021(ni)-4.021 G(nte)-4.021 E 1.522(ger and will silently truncate decimal numbers.)-.15 F(This)6.522 E(means)128 394.8 Q F1(srand\(42\))3.974 E F0 1.474 (will usually produce the same results as)3.974 F F1(srand\(42.1\))3.974 E F0 6.474(.T)C 3.974(ob)-7.274 G 3.973(es)-3.974 G 1.473(afe, al)-3.973 F -.1(wa)-.1 G(ys).1 E(pass)128 406.8 Q F1(srand)2.5 E F0(an inte)2.5 E (ger)-.15 E(.)-.55 E .461(In v)128 424.8 R .461 (ersions of Perl prior to 5.004 the def)-.15 F .462(ault seed w)-.1 F .462(as just the current)-.1 F F1(time)2.962 E F0 5.462(.T)C .462 (his isn')-5.462 F 2.962(tap)-.18 G(articularly)-2.962 E .437 (good seed, so man)128 436.8 R 2.937(yo)-.15 G .437 (ld programs supply their o)-2.937 F .437(wn seed v)-.25 F .437 (alue \(often)-.25 F F1 .436(time ^ $$)2.937 F F0(or)2.936 E F1 .436 (time ^ \($$)2.936 F 6(+\()128 448.8 S($$ << 15\)\))-6 E F0(\), b)A (ut that isn')-.2 E 2.5(tn)-.18 G(ecessary an)-2.5 E 2.5(ym)-.15 G(ore.) -2.5 E -.15(Fo)128 466.8 S 3.272(rc).15 G .772 (ryptographic purposes, ho)-3.272 F(we)-.25 E -.15(ve)-.25 G 1.572 -.4 (r, y).15 H .772(ou need something much more random than the def).4 F .773(ault seed.)-.1 F 2.438(Checksumming the compressed output of one o\ r more rapidly changing operating system status)128 478.8 R (programs is the usual method.)128 490.8 Q -.15(Fo)5 G 2.5(re).15 G (xample:)-2.65 E F1 (srand \(time ^ $$ ^ unpack "%L*", \222ps axww | gzip \255f\222\);)152 508.8 Q F0 1.536(If you')128 526.8 R 1.536 (re particularly concerned with this, search the)-.5 F F2(CP)4.037 E(AN) -.828 E F0 1.537(for random number generator modules)4.037 F (instead of rolling out your o)128 538.8 Q(wn.)-.25 E (Frequently called programs \(lik)128 556.8 Q(e)-.1 E F2(CGI)2.5 E F0 (scripts\) that simply use)2.5 E F1(time ^ $$)152 574.8 Q F0 (for a seed can f)128 592.8 Q(all pre)-.1 E 2.5(yt)-.15 G 2.5(ot)-2.5 G (he mathematical property that)-2.5 E F1(a^b == \(a+1\)^\(b+1\))152 610.8 Q F0(one-third of the time.)128 628.8 Q(So don')5 E 2.5(td)-.18 G 2.5(ot)-2.5 G(hat.)-2.5 E 4.104(At)128 646.8 S 1.604(ypical use of the \ returned seed is for a test program which has too man)-4.104 F 4.104(yc) -.15 G 1.603(ombinations to test)-4.104 F(comprehensi)128 658.8 Q -.15 (ve)-.25 G .115(ly in the time a).15 F -.25(va)-.2 G .115 (ilable to it each run.).25 F .116 (It can test a random subset each time, and should)5.116 F 1.269 (there be a f)128 670.8 R 1.269(ailure, log the seed used for that run \ so that it can later be used to reproduce the same)-.1 F(results.)128 682.8 Q(stat)108 699.6 Q F2(FILEHANDLE)2.5 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 82)162.62 F 0 Cg EP %%Page: 83 83 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(stat)108 84 Q/F1 9 /Times-Roman@0 SF(EXPR)2.5 E F0(stat)108 96 Q F1(DIRHANDLE)2.5 E F0 (stat)108 108 Q .79(Returns a 13\255element list gi)128 108 R .79 (ving the status info for a \214le, either the \214le opened via)-.25 F F1(FILEHANDLE)3.29 E F0(or)3.291 E F1(DIRHANDLE)128 120 Q F0 3.27(,o)C 3.27(rn)-3.27 G .769(amed by)-3.27 F F1(EXPR)3.269 E F0 5.769(.I)C(f) -5.769 E F1(EXPR)3.269 E F0 .769(is omitted, it stats)3.269 F/F2 10 /Courier@0 SF($_)3.269 E F0(\(not)3.269 E F2(_)3.269 E F0 3.269 (!\). Returns)B .769(the empty list if)3.269 F F2(stat)128 132 Q F0 -.1 (fa)2.5 G 2.5(ils. T).1 F(ypically used as follo)-.8 E(ws:)-.25 E F2 (\($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,)152 150 Q ($atime,$mtime,$ctime,$blksize,$blocks\))170 162 Q 6(=s)194 174 S (tat\($filename\);)-6 E F0 (Not all \214elds are supported on all \214lesystem types.)128 192 Q (Here are the meanings of the \214elds:)5 E F2 6(0d)140 210 S 30 (ev device)-6 F(number of filesystem)6 E 6(1i)140 222 S 30(no inode)-6 F (number)6 E 6(2m)140 234 S 24(ode file)-6 F 6(mode \(type)6 F (and permissions\))6 E 6(3n)140 246 S 18(link number)-6 F (of \(hard\) links to the file)6 E 6(4u)140 258 S 30(id numeric)-6 F (user ID of file\010s owner)6 E 6(5g)140 270 S 30(id numeric)-6 F (group ID of file\010s owner)6 E 6(6r)140 282 S 24(dev the)-6 F (device identifier \(special files only\))6 E 6(7s)140 294 S 24 (ize total)-6 F(size of file, in bytes)6 E 6(8a)140 306 S 18(time last) -6 F(access time in seconds since the epoch)6 E 6(9m)140 318 S 18 (time last)-6 F(modify time in seconds since the epoch)6 E(10 ctime)134 330 Q(inode change time in seconds since the epoch \(*\))24 E (11 blksize)134 342 Q(preferred block size for file system I/O)12 E (12 blocks)134 354 Q(actual number of blocks allocated)18 E F0 (\(The epoch w)128 372 Q(as at 00:00 January 1, 1970)-.1 E F1(GMT)2.5 E F0(.\))A 1.279(\(*\) Not all \214elds are supported on all \214lesystem\ types. Notably)128 390 R 3.779(,t)-.65 G 1.279 (he ctime \214eld is non-portable.)-3.779 F(In)6.279 E(particular)128 402 Q 3.457(,y)-.4 G .957(ou cannot e)-3.457 F .957(xpect it to be a `) -.15 F .957(`creation time')-.74 F .957('; see `)-.74 F .957 (`Files and Filesystems')-.74 F 3.457('i)-.74 G 3.456(np)-3.457 G .956 (erlport for)-3.456 F(details.)128 414 Q(If)128 432 Q F2(stat)3.785 E F0 1.286(is passed the special \214lehandle consisting of an underline, no\ stat is done, b)3.785 F 1.286(ut the current)-.2 F (contents of the stat structure from the last)128 444 Q F2(stat)2.5 E F0 (,)A F2(lstat)2.5 E F0 2.5(,o)C 2.5<728c>-2.5 G(letest are returned.) -2.5 E(Example:)5 E F2 (if \(\255x $file && \(\($d\) = stat\(_\)\) && $d < 0\) {)152 462 Q (print "$file is executable NFS file\\n";)176 474 Q(})152 486 Q F0 (\(This w)128 504 Q(orks on machines only for which the de)-.1 E (vice number is ne)-.25 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve u)-.25 H (nder).15 E F1(NFS)2.5 E F0(.\))A 1.049(Because the mode contains both \ the \214le type and its permissions, you should mask of)128 522 R 3.548 (ft)-.25 G 1.048(he \214le type)-3.548 F (portion and \(s\)printf using a)128 534 Q F2("%o")2.5 E F0(if you w)2.5 E(ant to see the real permissions.)-.1 E F2 ($mode = \(stat\($filename\)\)[2];)152 552 Q (printf "Permissions are %04o\\n", $mode & 07777;)152 564 Q F0 .887 (In scalar conte)128 582 R(xt,)-.15 E F2(stat)3.387 E F0 .887 (returns a boolean v)3.387 F .887(alue indicating success or f)-.25 F .888(ailure, and, if successful, sets)-.1 F (the information associated with the special \214lehandle)128 594 Q F2 (_)2.5 E F0(.)A(The File::stat module pro)128 612 Q(vides a con)-.15 E -.15(ve)-.4 G(nient, by-name access mechanism:).15 E F2(use File::stat;) 152 630 Q($sb = stat\($filename\);)152 642 Q (printf "File is %s, size is %s, perm %04o, mtime %s\\n",)152 654 Q ($filename, $sb\255>size, $sb\255>mode & 07777,)194 666 Q (scalar localtime $sb\255>mtime;)194 678 Q F0 -1.1(Yo)128 696 S 2.5(uc) 1.1 G(an import symbolic mode constants \()-2.5 E F2(S_IF*)A F0 2.5(\)a) C(nd functions \()-2.5 E F2(S_IS*)A F0 2.5(\)f)C(rom the Fcntl module:) -2.5 E F2(use Fcntl \010:mode\010;)152 714 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 83)162.62 F 0 Cg EP %%Page: 84 84 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($mode = \(stat\($filename\)\)[2];)152 84 Q 30($user_rwx =)152 108 R (\($mode & S_IRWXU\) >> 6;)6 E 18($group_read =)152 120 R (\($mode & S_IRGRP\) >> 3;)6 E($other_execute =)152 132 Q ($mode & S_IXOTH;)12 E (printf "Permissions are %04o\\n", S_IMODE\($mode\), "\\n";)152 156 Q 24 ($is_setuid =)152 180 R($mode & S_ISUID;)12 E 6 ($is_directory = S_ISDIR\($mode\);)152 192 R F0 -1.1(Yo)128 210 S 3.312 (uc)1.1 G .812(ould write the last tw)-3.312 F 3.312(ou)-.1 G .812 (sing the)-3.312 F F13.312 E F0(and)3.312 E F13.312 E F0 3.312(operators. Commonly)3.312 F -.2(av)3.312 G(ailable)-.05 E F1 (S_IF*)3.312 E F0(constants)3.312 E(are:)128 222 Q F1 6(#P)152 240 S (ermissions: read, write, execute, for user, group, others.)-6 E (S_IRWXU S_IRUSR S_IWUSR S_IXUSR)152 264 Q (S_IRWXG S_IRGRP S_IWGRP S_IXGRP)152 276 Q (S_IRWXO S_IROTH S_IWOTH S_IXOTH)152 288 Q 6(#S)152 312 S (etuid/Setgid/Stickiness/SaveText.)-6 E 6(#N)152 324 S (ote that the exact meaning of these is system dependent.)-6 E (S_ISUID S_ISGID S_ISVTX S_ISTXT)152 348 Q 6(#F)152 372 S(ile types.)-6 E(Not necessarily all are available on your system.)12 E(S_IFREG S_IFDI\ R S_IFLNK S_IFBLK S_IFCHR S_IFIFO S_IFSOCK S_IFWHT S_ENFMT)152 396 Q 6 (#T)152 420 S (he following are compatibility aliases for S_IRUSR, S_IWUSR, S_IXUSR.) -6 E(S_IREAD S_IWRITE S_IEXEC)152 444 Q F0(and the)128 462 Q F1(S_IF*) 2.5 E F0(functions are)2.5 E F1 18(S_IMODE\($mode\) the)152 480 R (part of $mode containing the permission bits)6 E (and the setuid/setgid/sticky bits)200 492 Q 18(S_IFMT\($mode\) the)152 516 R(part of $mode containing the file type)6 E (which can be bit\255anded with \(for example\) S_IFREG)200 528 Q (or with the following functions)272 540 Q 6(#T)152 564 S (he operators \255f, \255d, \255l, \255b, \255c, \255p, and \255S.)-6 E (S_ISREG\($mode\) S_ISDIR\($mode\) S_ISLNK\($mode\))152 588 Q (S_ISBLK\($mode\) S_ISCHR\($mode\) S_ISFIFO\($mode\) S_ISSOCK\($mode\)) 152 600 Q 6(#N)152 624 S 6(od)-6 G (irect \255X operator counterpart, but for the first one)-6 E 6(#t)152 636 S(he \255g operator is often equivalent.)-6 E(The ENFMT stands for) 12 E 6(#r)152 648 S (ecord flocking enforcement, a platform\255dependent feature.)-6 E (S_ISENFMT\($mode\) S_ISWHT\($mode\))152 672 Q F0 .045(See your nati)128 690 R -.15(ve)-.25 G/F2 10/Times-Italic@0 SF -.15(ch)2.696 G(mod).15 E F0 .046(\(2\) and)1.666 F F2(stat)2.546 E F0 .046 (\(2\) documentation for more details about the)1.666 F F1(S_*)2.546 E F0 2.546(constants. T)2.546 F 2.546(og)-.8 G(et)-2.546 E (status info for a symbolic link instead of the tar)128 702 Q (get \214le behind the link, use the)-.18 E F1(lstat)2.5 E F0(function.) 2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 84)162.62 F 0 Cg EP %%Page: 85 85 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(state)108 84 Q/F1 9/Times-Roman@0 SF(EXPR)2.5 E F0(state)108 96 Q F1 .25(TYPE EXPR)2.5 F F0(state)108 108 Q F1(EXPR)2.5 E F0(:)2.5 E F1 -.999(AT)2.5 G(TRS).999 E F0(state)108 120 Q F1 .25(TYPE EXPR)2.5 F F0(:)2.5 E F1 -.999(AT)2.5 G (TRS).999 E/F2 10/Courier@0 SF(state)128 132 Q F0 .282(declares a le) 2.782 F .282(xically scoped v)-.15 F .282(ariable, just lik)-.25 F(e)-.1 E F2(my)2.782 E F0 2.782(does. Ho)2.782 F(we)-.25 E -.15(ve)-.25 G 1.082 -.4(r, t).15 H .282(hose v).4 F .282(ariables will ne)-.25 F -.15(ve) -.25 G 2.782(rb).15 G(e)-2.782 E 2.241(reinitialized, contrary to le)128 144 R 2.241(xical v)-.15 F 2.242 (ariables that are reinitialized each time their enclosing block is)-.25 F(entered.)128 156 Q F2(state)128 174 Q F0 -.25(va)3.985 G 1.485 (riables are enabled only when the).25 F F2 1.485(use feature "state") 3.985 F F0 1.485(pragma is in ef)3.985 F 3.985(fect. See)-.25 F (feature.)128 186 Q(study)108 202.8 Q F1(SCALAR)2.5 E F0(study)108 214.8 Q -.8(Ta)128 226.8 S -.1(ke).8 G 3.16(se).1 G .66(xtra time to study) -3.31 F F1(SCALAR)3.16 E F0(\()3.16 E F2($_)A F0 .66 (if unspeci\214ed\) in anticipation of doing man)3.16 F 3.161(yp)-.15 G .661(attern matches)-3.161 F .514(on the string before it is ne)128 238.8 R .514(xt modi\214ed.)-.15 F .514(This may or may not sa)5.514 F .813 -.15(ve t)-.2 H .513(ime, depending on the nature and).15 F .768 (number of patterns you are searching and the distrib)128 250.8 R .768 (ution of character frequencies in the string to be)-.2 F .803 (searched; you probably w)128 262.8 R .802 (ant to compare run times with and without it to see which is f)-.1 F (aster)-.1 E 5.802(.T)-.55 G(hose)-5.802 E .138(loops that scan for man) 128 274.8 R 2.638(ys)-.15 G .138 (hort constant strings \(including the constant parts of more comple) -2.638 F 2.638(xp)-.15 G(atterns\))-2.638 E .555(will bene\214t most.) 128 286.8 R -1.1(Yo)5.555 G 3.055(um)1.1 G .555(ay ha)-3.055 F .855 -.15 (ve o)-.2 H .555(nly one).15 F F2(study)3.055 E F0(acti)3.055 E .855 -.15(ve a)-.25 H 3.055(tat).15 G .554(ime: if you study a dif)-3.055 F .554(ferent scalar the)-.25 F .237(\214rst is `)128 298.8 R(`unstudied') -.74 E 2.737('. \(The)-.74 F -.1(wa)2.737 G(y).1 E F2(study)2.737 E F0 -.1(wo)2.737 G .237(rks is this: a link).1 F .237(ed list of e)-.1 F -.15(ve)-.25 G .238(ry character in the string to be).15 F 1.626 (searched is made, so we kno)128 310.8 R 2.926 -.65(w, f)-.25 H 1.626 (or e).65 F 1.626(xample, where all the)-.15 F F2<086b08>4.125 E F0 1.625(characters are.)4.125 F 1.625(From each search)6.625 F .353(strin\ g, the rarest character is selected, based on some static frequenc)128 322.8 R 2.854(yt)-.15 G .354(ables constructed from some C)-2.854 F (programs and English te)128 334.8 Q 2.5(xt. Only)-.15 F (those places that contain this `)2.5 E(`rarest')-.74 E 2.5('c)-.74 G (haracter are e)-2.5 E(xamined.\))-.15 E -.15(Fo)128 352.8 S 3.553(re) .15 G 1.053(xample, here is a loop that inserts inde)-3.703 F 3.552(xp) -.15 G 1.052(roducing entries before an)-3.552 F 3.552(yl)-.15 G 1.052 (ine containing a certain)-3.552 F(pattern:)128 364.8 Q F2 (while \(<>\) {)152 382.8 Q(study;)176 394.8 Q(print ".IX foo\\n")176 406.8 Q(if /\\bfoo\\b/;)24 E(print ".IX bar\\n")176 418.8 Q (if /\\bbar\\b/;)24 E(print ".IX blurfl\\n" if /\\bblurfl\\b/;)176 430.8 Q 6(#.)176 442.8 S(..)-6 E(print;)176 454.8 Q(})152 466.8 Q F0 .169 (In searching for)128 484.8 R F2(/\\bfoo\\b/)2.669 E F0 2.669(,o)C .169 (nly locations in)-2.669 F F2($_)2.669 E F0 .169(that contain)2.669 F F2 (f)2.669 E F0 .17(will be look)2.67 F .17(ed at, because)-.1 F F2(f)2.67 E F0 .17(is rarer)2.67 F(than)128 496.8 Q F2(o)2.524 E F0 5.024(.I)C 2.524(ng)-5.024 G .023(eneral, this is a big win e)-2.524 F .023 (xcept in pathological cases.)-.15 F .023 (The only question is whether it sa)5.023 F -.15(ve)-.2 G(s).15 E (you more time than it took to b)128 508.8 Q(uild the link)-.2 E (ed list in the \214rst place.)-.1 E .358(Note that if you ha)128 526.8 R .658 -.15(ve t)-.2 H 2.858(ol).15 G .358 (ook for strings that you don')-2.858 F 2.859(tk)-.18 G(no)-2.859 E 2.859(wt)-.25 G .359(ill runtime, you can b)-2.859 F .359 (uild an entire loop)-.2 F .102(as a string and)128 538.8 R F2(eval) 2.602 E F0 .102(that to a)2.602 F -.2(vo)-.2 G .102 (id recompiling all your patterns all the time.).2 F -.8(To)5.101 G .101 (gether with unde\214ning).8 F F2($/)128 550.8 Q F0 .268 (to input entire \214les as one record, this can be quite f)2.767 F .268 (ast, often f)-.1 F .268(aster than specialized programs lik)-.1 F(e)-.1 E/F3 10/Times-Italic@0 SF(fgr)128 562.8 Q(ep)-.37 E F0 3.33(\(1\). The) 1.666 F(follo)3.329 E .829(wing scans a list of \214les \()-.25 F F2 (@files)A F0 3.329(\)f)C .829(or a list of w)-3.329 F .829(ords \()-.1 F F2(@words)A F0 .829(\), and prints out)B (the names of those \214les that contain a match:)128 574.8 Q (perl v5.14.2)72 768 Q 198.17(2011-10-01 85)162.62 F 0 Cg EP %%Page: 86 86 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($search = \010while \(<>\) { study;\010;)152 84 Q (foreach $word \(@words\) {)152 96 Q ($search .= "++\\$seen{\\$ARGV} if /\\\\b$word\\\\b/;\\n";)176 108 Q(}) 152 120 Q($search .= "}";)152 132 Q(@ARGV = @files;)152 144 Q(undef $/;) 152 156 Q(eval $search;)152 168 Q 6(#t)48 G(his screams)-6 E ($/ = "\\n";)152 180 Q 6(#p)48 G(ut back to normal input delimiter)-6 E (foreach $file \(sort keys\(%seen\)\) {)152 192 Q(print $file, "\\n";) 176 204 Q(})152 216 Q F0(sub)108 232.8 Q/F2 9/Times-Roman@0 SF -.315(NA) 2.5 G .25(ME BLOCK).315 F F0(sub)108 244.8 Q F2 -.315(NA)2.5 G(ME).315 E F0(\()2.5 E F2(PR)A -1.692 -.36(OT O)-.36 H F0(\)).36 E F2(BLOCK)2.5 E F0(sub)108 256.8 Q F2 -.315(NA)2.5 G(ME).315 E F0(:)2.5 E F2 -.999(AT) 2.5 G .25(TRS BLOCK).999 F F0(sub)108 268.8 Q F2 -.315(NA)2.5 G(ME).315 E F0(\()2.5 E F2(PR)A -1.692 -.36(OT O)-.36 H F0 2.5(\):).36 G F2 -.999 (AT)C .25(TRS BLOCK).999 F F0 2.643 (This is subroutine de\214nition, not a real function)128 280.8 R/F3 10 /Times-Italic@0 SF 2.644(per se)5.144 F F0 7.644(.W)C 2.644(ithout a) -8.044 F F2(BLOCK)5.144 E F0(it')5.144 E 5.144(sj)-.55 G 2.644 (ust a forw)-5.144 F(ard)-.1 E 4.088(declaration. W)128 292.8 R 1.588 (ithout a)-.4 F F2 -.315(NA)4.088 G(ME).315 E F0 4.088(,i)C(t')-4.088 E 4.088(sa)-.55 G 4.088(na)-4.088 G(non)-4.088 E 1.588 (ymous function declaration, so does return a v)-.15 F 1.587(alue: the) -.25 F F2(CODE)128 304.8 Q F0(ref of the closure just created.)2.5 E 5.7 (See perlsub and perlref for details about subroutines and references; \ see attrib)128 322.8 R 5.7(utes and)-.2 F(Attrib)128 334.8 Q (ute::Handlers for more information about attrib)-.2 E(utes.)-.2 E (substr)108 351.6 Q F2(EXPR)2.5 E F0(,OFFSET)A(,LENGTH,REPLA)-.74 E (CEMENT)-.4 E(substr)108 363.6 Q F2(EXPR)2.5 E F0(,OFFSET)A(,LENGTH)-.74 E(substr)108 375.6 Q F2(EXPR)2.5 E F0(,OFFSET)A .706 (Extracts a substring out of)128 387.6 R F2(EXPR)3.206 E F0 .706 (and returns it.)3.206 F .706(First character is at of)5.706 F(fset)-.25 E F1(0)3.206 E F0 .706(\(or whate)3.206 F -.15(ve)-.25 G 3.205(ry).15 G (ou')-3.205 E 1.005 -.15(ve s)-.5 H(et).15 E F1($[)128 399.6 Q F0 .941 (to \(b)3.441 F(ut)-.2 E/F4 10/Times-Bold@0 SF .941(-.25 G .786(lename symbolically link)-3.286 F .786(ed to the old \214lename.)-.1 F(Returns)5.786 E F1(1)3.286 E F0 .786(for success,)3.286 F F1(0)3.286 E F0(otherwise.)3.286 E (On systems that don')128 286.8 Q 2.5(ts)-.18 G (upport symbolic links, raises an e)-2.5 E 2.5(xception. T)-.15 F 2.5 (oc)-.8 G(heck for that, use e)-2.5 E -.25(va)-.25 G(l:).25 E F1 ($symlink_exists = eval { symlink\("",""\); 1 };)152 304.8 Q F0(syscall) 108 321.6 Q F3(NUMBER)2.5 E F0(,)A F3(LIST)2.5 E F0 1.984(Calls the sys\ tem call speci\214ed as the \214rst element of the list, passing the re\ maining elements as)128 333.6 R(ar)128 345.6 Q .007 (guments to the system call.)-.18 F .006(If unimplemented, raises an e) 5.007 F 2.506(xception. The)-.15 F(ar)2.506 E .006 (guments are interpreted as)-.18 F(follo)128 357.6 Q 1.111(ws: if a gi) -.25 F -.15(ve)-.25 G 3.611(na).15 G -.18(rg)-3.611 G 1.111 (ument is numeric, the ar).18 F 1.111(gument is passed as an int.)-.18 F 1.111(If not, the pointer to the)6.111 F 1.792(string v)128 369.6 R 1.792(alue is passed.)-.25 F -1.1(Yo)6.792 G 4.291(ua)1.1 G 1.791 (re responsible to mak)-4.291 F 4.291(es)-.1 G 1.791 (ure a string is pre-e)-4.291 F 1.791(xtended long enough to)-.15 F (recei)128 381.6 Q .732 -.15(ve a)-.25 H .732 -.15(ny r).15 H .433 (esult that might be written into a string.).15 F -1.1(Yo)5.433 G 2.933 (uc)1.1 G(an')-2.933 E 2.933(tu)-.18 G .433 (se a string literal \(or other read-only)-2.933 F 1.829 (string\) as an ar)128 393.6 R 1.829(gument to)-.18 F F1(syscall)4.329 E F0 1.829(because Perl has to assume that an)4.329 F 4.328(ys)-.15 G 1.828(tring pointer might be)-4.328 F 2.304(written through.)128 405.6 R 2.304(If your inte)7.304 F 2.304(ger ar)-.15 F 2.304 (guments are not literals and ha)-.18 F 2.604 -.15(ve n)-.2 H -2.15 -.25 (ev e).15 H 4.804(rb).25 G 2.304(een interpreted in a)-4.804 F .767 (numeric conte)128 417.6 R .766(xt, you may need to add)-.15 F F1(0) 3.266 E F0 .766(to them to force them to look lik)3.266 F 3.266(en)-.1 G 3.266(umbers. This)-3.266 F(emulates)3.266 E(the)128 429.6 Q F1 (syswrite)2.5 E F0(function \(or vice v)2.5 E(ersa\):)-.15 E F1 (require \010syscall.ph\010;)152 447.6 Q 6(#m)48 G(ay need to run h2ph) -6 E($s = "hi there\\n";)152 459.6 Q (syscall\(&SYS_write, fileno\(STDOUT\), $s, length $s\);)152 471.6 Q F0 .783(Note that Perl supports passing of up to only 14 ar)128 489.6 R .784(guments to your syscall, which in practice should)-.18 F (\(usually\) suf)128 501.6 Q(\214ce.)-.25 E .52(Syscall returns whate) 128 519.6 R -.15(ve)-.25 G 3.02(rv).15 G .519 (alue returned by the system call it calls.)-3.27 F .519 (If the system call f)5.519 F(ails,)-.1 E F1(syscall)3.019 E F0(returns) 128 531.6 Q F13.235 E F0 .735(and sets)3.235 F F1($!)3.235 E F0 3.235(\(errno\). Note)3.235 F .736(that some system calls)3.236 F F2 (can)3.236 E F0(le)3.236 E .736(gitimately return)-.15 F F13.236 E F0 5.736(.T)C .736(he proper)-5.736 F -.1(wa)128 543.6 S 3.347(yt).1 G 3.347(oh)-3.347 G .847(andle such calls is to assign)-3.347 F F1($!=0) 3.346 E F0 .846(before the call, then check the v)3.346 F .846(alue of) -.25 F F1($!)3.346 E F0(if)3.346 E F1(syscall)3.346 E F0(returns)128 555.6 Q F12.5 E F0(.)A(There')128 573.6 Q 3.603(sap)-.55 G 1.103 (roblem with)-3.603 F F1(syscall\(&SYS_pipe\))3.603 E F0 3.603(:i)C 3.603(tr)-3.603 G 1.104(eturns the \214le number of the read end of the) -3.603 F 1.144(pipe it creates, b)128 585.6 R 1.144(ut there is no w)-.2 F 1.144(ay to retrie)-.1 F 1.444 -.15(ve t)-.25 H 1.144 (he \214le number of the other end.).15 F -1.1(Yo)6.144 G 3.644(uc)1.1 G 1.144(an a)-3.644 F -.2(vo)-.2 G 1.144(id this).2 F(problem by using)128 597.6 Q F1(pipe)2.5 E F0(instead.)2.5 E(sysopen)108 614.4 Q F3 (FILEHANDLE)2.5 E F0(,FILEN)A(AME,MODE)-.35 E(sysopen)108 626.4 Q F3 (FILEHANDLE)2.5 E F0(,FILEN)A(AME,MODE,PERMS)-.35 E 2.49 (Opens the \214le whose \214lename is gi)128 638.4 R -.15(ve)-.25 G 4.991(nb).15 G(y)-4.991 E F3(FILEN)4.991 E(AME)-.315 E F0 4.991(,a)C 2.491(nd associates it with)-4.991 F F3(FILEHANDLE)4.991 E F0 7.491(.I)C (f)-7.491 E F3(FILEHANDLE)128 650.4 Q F0 .289(is an e)2.789 F .289 (xpression, its v)-.15 F .289(alue is used as the real \214lehandle w) -.25 F .288(anted; an unde\214ned scalar will)-.1 F .965 (be suitably auto)128 662.4 R(vi)-.15 E .966 (vi\214ed. This function calls the underlying operating system')-.25 F (s)-.55 E F2(open)3.466 E F0 .966(\(2\) function with)B(the parameters) 128 674.4 Q F3(FILEN)2.5 E(AME)-.315 E F0(,)A F3(MODE)2.5 E F0 2.5(,a)C (nd)-2.5 E F3(PERMS)2.5 E F0(.)A .374(The possible v)128 692.4 R .374 (alues and \215ag bits of the)-.25 F F3(MODE)2.874 E F0 .373 (parameter are system-dependent; the)2.874 F 2.873(ya)-.15 G .373(re a) -2.873 F -.25(va)-.2 G .373(ilable via).25 F .146(the standard module) 128 704.4 R F1(Fcntl)2.646 E F0 5.146(.S)C .146 (ee the documentation of your operating system')-5.146 F(s)-.55 E F2 (open)2.647 E F0 .147(\(2\) syscall to see)B(which v)128 716.4 Q (alues and \215ag bits are a)-.25 E -.25(va)-.2 G 2.5(ilable. Y).25 F (ou may combine se)-1.1 E -.15(ve)-.25 G(ral \215ags using the).15 E F1 (|)2.5 E F0(\255operator)A(.)-.55 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 87)162.62 F 0 Cg EP %%Page: 88 88 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .234 (Some of the most common v)128 84 R .234(alues are)-.25 F/F1 10 /Courier@0 SF(O_RDONLY)2.734 E F0 .234 (for opening the \214le in read-only mode,)2.734 F F1(O_WRONLY)2.734 E F0(for opening the \214le in write-only mode, and)128 96 Q F1(O_RDWR)2.5 E F0(for opening the \214le in read-write mode.)2.5 E -.15(Fo)128 114 S 3.734(rh).15 G 1.234(istorical reasons, some v)-3.734 F 1.234(alues w) -.25 F 1.234(ork on almost e)-.1 F -.15(ve)-.25 G 1.234 (ry system supported by Perl: 0 means read-).15 F(only)128 126 Q 4.118 (,1m)-.65 G 1.618(eans write-only)-4.118 F 4.118(,a)-.65 G 1.618 (nd 2 means read/write.)-4.118 F 3.217 -.8(We k)6.618 H(no).8 E 4.117 (wt)-.25 G 1.617(hat these v)-4.117 F 1.617(alues do)-.25 F/F2 10 /Times-Italic@0 SF(not)4.117 E F0 -.1(wo)4.117 G 1.617(rk under).1 F/F3 9/Times-Roman@0 SF(OS/390)128 138 Q F0(&)2.5 E F3(VM/ESA)2.5 E F0 (Unix and on the Macintosh; you probably don')2.5 E 2.5(tw)-.18 G (ant to use them in ne)-2.6 E 2.5(wc)-.25 G(ode.)-2.5 E .662 (If the \214le named by)128 156 R F3(FILEN)3.162 E(AME)-.315 E F0 .662 (does not e)3.162 F .662(xist and the)-.15 F F1(open)3.162 E F0 .662 (call creates it \(typically because)3.162 F F3(MODE)3.162 E F0 .626 (includes the)128 168 R F1(O_CREAT)3.126 E F0 .625(\215ag\), then the v) 3.126 F .625(alue of)-.25 F F3(PERMS)3.125 E F0 .625 (speci\214es the permissions of the ne)3.125 F .625(wly created)-.25 F 5.555(\214le. If)128 180 R 3.056(you omit the)5.556 F F3(PERMS)5.556 E F0(ar)5.556 E 3.056(gument to)-.18 F F1(sysopen)5.556 E F0 5.556(,P)C 3.056(erl uses the octal v)-5.556 F(alue)-.25 E F1(0666)5.556 E F0 8.056 (.T)C(hese)-8.056 E(permission v)128 192 Q (alues need to be in octal, and are modi\214ed by your process')-.25 E 2.5(sc)-.55 G(urrent)-2.5 E F1(umask)2.5 E F0(.)A 2.08(In man)128 210 R 4.58(ys)-.15 G 2.08(ystems the)-4.58 F F1(O_EXCL)4.58 E F0 2.08 (\215ag is a)4.58 F -.25(va)-.2 G 2.08(ilable for opening \214les in e) .25 F(xclusi)-.15 E 2.38 -.15(ve m)-.25 H 4.58(ode. This).15 F(is)4.58 E /F4 10/Times-Bold@0 SF(not)4.58 E F0 1.422(locking: e)128 222 R(xclusi) -.15 E -.15(ve)-.25 G 1.422 (ness means here that if the \214le already e).15 F(xists,)-.15 E F2 (sysopen\(\))3.922 E F0 -.1(fa)3.922 G(ils.).1 E F1(O_EXCL)6.422 E F0 1.423(may not)3.923 F -.1(wo)128 234 S 1.923(rk on netw).1 F 1.923 (ork \214lesystems, and has no ef)-.1 F 1.923(fect unless the)-.25 F F1 (O_CREAT)4.422 E F0 1.922(\215ag is set as well.)4.422 F(Setting)6.922 E F1(O_CREAT|O_EXCL)128 246 Q F0(pre)3.373 E -.15(ve)-.25 G .874 (nts the \214le from being opened if it is a symbolic link.).15 F .874 (It does not protect)5.874 F(ag)128 258 Q (ainst symbolic links in the \214le')-.05 E 2.5(sp)-.55 G(ath.)-2.5 E .705(Sometimes you may w)128 276 R .705(ant to truncate an already-e)-.1 F .705(xisting \214le.)-.15 F .704(This can be done using the)5.705 F F1 (O_TRUNC)3.204 E F0 2.5(\215ag. The)128 288 R(beha)2.5 E(vior of)-.2 E F1(O_TRUNC)2.5 E F0(with)2.5 E F1(O_RDONLY)2.5 E F0(is unde\214ned.)2.5 E -1.1(Yo)128 306 S 3.648(us)1.1 G 1.148(hould seldom if e)-3.648 F -.15 (ve)-.25 G 3.648(ru).15 G(se)-3.648 E F1(0644)3.648 E F0 1.148(as ar) 3.648 F 1.148(gument to)-.18 F F1(sysopen)3.648 E F0 3.648(,b)C 1.148 (ecause that tak)-3.648 F 1.148(es a)-.1 F -.1(wa)-.15 G 3.649(yt).1 G 1.149(he user')-3.649 F(s)-.55 E .704(option to ha)128 318 R 1.004 -.15 (ve a m)-.2 H .703(ore permissi).15 F 1.003 -.15(ve u)-.25 H 3.203 (mask. Better).15 F .703(to omit it.)3.203 F .703(See the)5.703 F F2 (perlfunc)3.203 E F0 .703(\(1\) entry on)1.666 F F1(umask)3.203 E F0 (for)3.203 E(more on this.)128 330 Q .568(Note that)128 348 R F1 (sysopen)3.068 E F0 .568(depends on the)3.068 F F2(fdopen\(\))3.068 E F0 3.068(Cl)3.068 G .568(ibrary function.)-3.068 F .568(On man)5.568 F 3.068(yU)-.15 G .568(nix systems,)-3.068 F F2(fdopen\(\))3.068 E F0(is) 3.068 E(kno)128 360 Q 2.26(wn to f)-.25 F 2.26 (ail when \214le descriptors e)-.1 F 2.26(xceed a certain v)-.15 F 2.26 (alue, typically 255. If you need more \214le)-.25 F 3.452 (descriptors than that, consider reb)128 372 R 3.453 (uilding Perl to use the)-.2 F F1(sfio)5.953 E F0(library)5.953 E 5.953 (,o)-.65 G 5.953(rp)-5.953 G 3.453(erhaps using the)-5.953 F F2 (POSIX::open\(\))128 384 Q F0(function.)2.5 E (See perlopentut for a kinder)128 402 Q 2.5(,g)-.4 G(entler e)-2.5 E (xplanation of opening \214les.)-.15 E(sysread)108 418.8 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH,OFFSET)A(sysread)108 430.8 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH)A .204(Attempts to read)128 442.8 R F3(LENGTH)2.704 E F0 .204(bytes of data into v)2.704 F(ariable)-.25 E F3 (SCALAR)2.704 E F0 .204(from the speci\214ed)2.704 F F3(FILEHANDLE)2.704 E F0 2.703(,u)C(sing)-2.703 E(the)128 454.8 Q F2 -.37(re)2.581 G(ad).37 E F0 2.581(\(2\). It)1.666 F .082(bypasses b)2.581 F(uf)-.2 E(fered)-.25 E F3(IO)2.582 E F0 2.582(,s)C 2.582(om)-2.582 G .082 (ixing this with other kinds of reads,)-2.582 F F1(print)2.582 E F0(,)A F1(write)2.582 E F0(,)A F1(seek)2.582 E F0(,)A F1(tell)128 466.8 Q F0 2.69(,o)C(r)-2.69 E F1(eof)2.69 E F0 .189 (can cause confusion because the perlio or stdio layers usually b)2.69 F (uf)-.2 E .189(fers data.)-.25 F .189(Returns the)5.189 F .595 (number of bytes actually read,)128 478.8 R F1(0)3.095 E F0 .595 (at end of \214le, or undef if there w)3.095 F .595 (as an error \(in the latter case)-.1 F F1($!)3.095 E F0(is)3.095 E .923 (also set\).)128 490.8 R F3(SCALAR)5.923 E F0 .923(will be gro)3.423 F .923(wn or shrunk so that the last byte actually read is the last byte \ of the)-.25 F(scalar after the read.)128 502.8 Q(An)128 520.8 Q F3 (OFFSET)4.882 E F0 2.383(may be speci\214ed to place the read data at s\ ome place in the string other than the)4.882 F(be)128 532.8 Q 3.057 (ginning. A)-.15 F(ne)3.057 E -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G F3 (OFFSET)3.207 E F0 .557(speci\214es placement at that man)3.057 F 3.057 (yc)-.15 G .557(haracters counting backw)-3.057 F .556(ards from)-.1 F .214(the end of the string.)128 544.8 R 2.715(Ap)5.215 G(ositi)-2.715 E -.15(ve)-.25 G F3(OFFSET)2.865 E F0 .215(greater than the length of) 2.715 F F3(SCALAR)2.715 E F0 .215(results in the string being)2.715 F (padded to the required size with)128 556.8 Q F1("\\0")2.5 E F0 (bytes before the result of the read is appended.)2.5 E 1.417 (There is no)128 574.8 R F2(syseof\(\))3.917 E F0 1.417 (function, which is ok, since)3.917 F F2(eof\(\))3.916 E F0(doesn')3.916 E 3.916(tw)-.18 G 1.416(ork well on de)-4.016 F 1.416 (vice \214les \(lik)-.25 F 3.916(et)-.1 G(tys\))-3.916 E(an)128 586.8 Q (yw)-.15 E(ay)-.1 E 5(.U)-.65 G(se)-5 E F2(sysr)2.5 E(ead\(\))-.37 E F0 (and check for a return v)2.5 E(alue for 0 to decide whether you')-.25 E (re done.)-.5 E 1.11(Note that if the \214lehandle has been mark)128 604.8 R 1.11(ed as)-.1 F F1(:utf8)3.61 E F0 1.11 (Unicode characters are read instead of bytes)3.61 F(\(the)128 616.8 Q F3(LENGTH)6.735 E F0(,)A F3(OFFSET)6.735 E F0 6.735(,a)C 4.235 (nd the return v)-6.735 F 4.235(alue of)-.25 F F2(sysr)6.735 E(ead\(\)) -.37 E F0 4.234(are in Unicode characters\).)6.735 F(The)9.234 E F1 (:encoding\(...\))128 628.8 Q F0 .824(layer implicitly introduces the) 3.324 F F1(:utf8)3.324 E F0(layer)3.325 E 5.825(.S)-.55 G .825(ee `) -5.825 F(`binmode')-.74 E .825(', `)-.74 F(`open')-.74 E .825 (', and the)-.74 F F1(open)128 640.8 Q F0(pragma, open.)2.5 E(sysseek) 108 657.6 Q F3(FILEHANDLE)2.5 E F0(,POSITION,WHENCE)A(Sets)128 669.6 Q F3(FILEHANDLE)4.09 E F0 2.69 -.55('s s)D 1.59 (ystem position in bytes using).55 F F2(lseek)4.09 E F0(\(2\).)1.666 E F3(FILEHANDLE)6.59 E F0 1.589(may be an e)4.089 F(xpression)-.15 E .064 (whose v)128 681.6 R .064(alue gi)-.25 F -.15(ve)-.25 G 2.564(st).15 G .064(he name of the \214lehandle.)-2.564 F .064(The v)5.064 F .064 (alues for)-.25 F F3(WHENCE)2.564 E F0(are)2.564 E F1(0)2.564 E F0 .064 (to set the ne)2.564 F 2.564(wp)-.25 G .065(osition to)-2.564 F F3 (POSITION)128 693.6 Q F0(;)A F1(1)2.737 E F0 .236 (to set the it to the current position plus)2.737 F F3(POSITION)2.736 E F0 2.736(;a)C(nd)-2.736 E F1(2)2.736 E F0 .236(to set it to)2.736 F F3 (EOF)2.736 E F0(plus)2.736 E F3(POSITION)2.736 E F0(,)A(typically ne)128 705.6 Q -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G(.).15 E .095(Note the)128 723.6 R F2 .095(in bytes)2.595 F F0 2.595(:e)C -.15(ve)-2.845 G 2.595 (ni).15 G 2.595(ft)-2.595 G .095 (he \214lehandle has been set to operate on characters \(for e)-2.595 F .096(xample by using the)-.15 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 88)162.62 F 0 Cg EP %%Page: 89 89 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (:encoding\(utf8\))128 84 Q F0 3.594(I/O layer\),)6.094 F/F2 10 /Times-Italic@0 SF(tell\(\))6.094 E F0 3.594(will return byte of)6.094 F 3.593(fsets, not character of)-.25 F 3.593(fsets \(because)-.25 F (implementing that w)128 96 Q(ould render)-.1 E F2(sysseek\(\))2.5 E F0 (unacceptably slo)2.5 E(w\).)-.25 E F2(sysseek\(\))128 114 Q F0 .463 (bypasses normal b)2.963 F(uf)-.2 E(fered)-.25 E/F3 9/Times-Roman@0 SF (IO)2.963 E F0 2.963(,s)C 2.964(om)-2.963 G .464 (ixing it with reads other than)-2.964 F F1(sysread)2.964 E F0 .464 (\(for e)2.964 F(xample)-.15 E F1(<>)2.964 E F0(or)128 126 Q F2 -.37(re) 2.5 G(ad\(\)).37 E F0(\))A F1(print)2.5 E F0(,)A F1(write)2.5 E F0(,)A F1(seek)2.5 E F0(,)A F1(tell)2.5 E F0 2.5(,o)C(r)-2.5 E F1(eof)2.5 E F0 (may cause confusion.)2.5 E -.15(Fo)128 144 S(r).15 E F3(WHENCE)2.974 E F0 2.974(,y)C .474(ou may also use the constants)-2.974 F F1(SEEK_SET) 2.973 E F0(,)A F1(SEEK_CUR)2.973 E F0 2.973(,a)C(nd)-2.973 E F1 (SEEK_END)2.973 E F0 .473(\(start of the)2.973 F .051 (\214le, current position, end of the \214le\) from the Fcntl module.) 128 156 R .052(Use of the constants is also more portable)5.052 F (than relying on 0, 1, and 2.)128 168 Q -.15(Fo)5 G 2.5(re).15 G (xample to de\214ne a `)-2.65 E(`systell')-.74 E 2.5('f)-.74 G(unction:) -2.5 E F1(use Fcntl \010SEEK_CUR\010;)152 186 Q (sub systell { sysseek\($_[0], 0, SEEK_CUR\) })152 198 Q F0 .102 (Returns the ne)128 216 R 2.601(wp)-.25 G .101 (osition, or the unde\214ned v)-2.601 F .101(alue on f)-.25 F 2.601 (ailure. A)-.1 F .101(position of zero is returned as the string)2.601 F F1 .387("0 but true")128 228 R F0 2.887(;t)C(hus)-2.887 E F1(sysseek) 2.887 E F0 .387(returns true on success and f)2.887 F .387(alse on f)-.1 F .387(ailure, yet you can still easily)-.1 F(determine the ne)128 240 Q 2.5(wp)-.25 G(osition.)-2.5 E(system)108 256.8 Q F3(LIST)2.5 E F0 (system)108 268.8 Q F3(PR)2.5 E .25(OGRAM LIST)-.36 F F0 .928(Does e)128 280.8 R .928(xactly the same thing as)-.15 F F1 .928(exec LIST)3.428 F F0 3.428(,e)C .928 (xcept that a fork is done \214rst and the parent process)-3.578 F -.1 (wa)128 292.8 S .518(its for the child process to e).1 F 3.019 (xit. Note)-.15 F .519(that ar)3.019 F .519(gument processing v)-.18 F .519(aries depending on the number of)-.25 F(ar)128 304.8 Q 3.845 (guments. If)-.18 F 1.345(there is more than one ar)3.845 F 1.344 (gument in)-.18 F F3(LIST)3.844 E F0 3.844(,o)C 3.844(ri)-3.844 G(f) -3.844 E F3(LIST)3.844 E F0 1.344(is an array with more than one)3.844 F -.25(va)128 316.8 S .581(lue, starts the program gi).25 F -.15(ve)-.25 G 3.081(nb).15 G 3.081(yt)-3.081 G .582 (he \214rst element of the list with ar)-3.081 F .582(guments gi)-.18 F -.15(ve)-.25 G 3.082(nb).15 G 3.082(yt)-3.082 G .582(he rest of the) -3.082 F 2.537(list. If)128 328.8 R .037(there is only one scalar ar) 2.537 F .037(gument, the ar)-.18 F .036(gument is check)-.18 F .036 (ed for shell metacharacters, and if there)-.1 F 1.088(are an)128 340.8 R 2.388 -.65(y, t)-.15 H 1.088(he entire ar).65 F 1.088 (gument is passed to the system')-.18 F 3.588(sc)-.55 G 1.088 (ommand shell for parsing \(this is)-3.588 F F1(/bin/sh)3.589 E128 352.8 Q F0 1.752(on Unix platforms, b)4.252 F 1.752(ut v)-.2 F 1.752 (aries on other platforms\).)-.25 F 1.752 (If there are no shell metacharacters in the)6.752 F(ar)128 364.8 Q (gument, it is split into w)-.18 E(ords and passed directly to)-.1 E F1 (execvp)2.5 E F0 2.5(,w)C(hich is more ef)-2.5 E(\214cient.)-.25 E(Be) 128 382.8 Q .683(ginning with v5.6.0, Perl will attempt to \215ush all \ \214les opened for output before an)-.15 F 3.184(yo)-.15 G .684 (peration that)-3.184 F .615(may do a fork, b)128 394.8 R .614 (ut this may not be supported on some platforms \(see perlport\).)-.2 F 2.214 -.8(To b)5.614 H 3.114(es).8 G .614(afe, you may)-3.114 F .657 (need to set)128 406.8 R F1($|)3.157 E F0(\($A)3.157 E(UT)-.55 E .657 (OFLUSH in English\) or call the)-.18 F F1(autoflush\(\))3.157 E F0 .657 (method of)3.157 F F1(IO::Handle)3.158 E F0(on)3.158 E(an)128 418.8 Q 2.5(yo)-.15 G(pen handles.)-2.5 E .471(The return v)128 436.8 R .471 (alue is the e)-.25 F .471(xit status of the program as returned by the) -.15 F F1(wait)2.971 E F0 2.971(call. T)2.971 F 2.971(og)-.8 G .471 (et the actual e)-2.971 F(xit)-.15 E -.25(va)128 448.8 S .687 (lue, shift right by eight \(see belo).25 F .687(w\). See also `)-.25 F (`e)-.74 E -.15(xe)-.15 G(c').15 E 3.187('. This)-.74 F(is)3.187 E F2 (not)3.187 E F0 .688(what you w)3.188 F .688(ant to use to capture)-.1 F 1.979 (the output from a command; for that you should use merely backticks or) 128 460.8 R F1(qx//)4.478 E F0 4.478(,a)C 4.478(sd)-4.478 G 1.978 (escribed in)-4.478 F -.74(```)128 472.8 S(STRING`').74 E 3.186('i)-.74 G 3.186(np)-3.186 G 3.186(erlop. Return)-3.186 F -.25(va)3.186 G .687 (lue of \2551 indicates a f).25 F .687 (ailure to start the program or an error of the)-.1 F F2(wait)128 484.8 Q F0(\(2\) system call \(inspect $! for the reason\).)1.666 E .814 (If you')128 502.8 R 3.314(dl)-.5 G(ik)-3.314 E 3.314(et)-.1 G 3.314(om) -3.314 G(ak)-3.314 E(e)-.1 E F1(system)3.314 E F0 .814(\(and man)3.314 F 3.314(yo)-.15 G .814(ther bits of Perl\) die on error)-3.314 F 3.314(,h) -.4 G -2.25 -.2(av e)-3.314 H 3.314(al)3.514 G .814(ook at the autodie) -3.314 F(pragma.)128 514.8 Q(Lik)128 532.8 Q(e)-.1 E F1(exec)2.502 E F0 (,)A F1(system)2.502 E F0(allo)2.502 E .002 (ws you to lie to a program about its name if you use the)-.25 F F1 .003 (system PROGRAM)2.503 F(LIST)128 544.8 Q F0 2.5(syntax. Ag)2.5 F (ain, see `)-.05 E(`e)-.74 E -.15(xe)-.15 G(c').15 E('.)-.74 E(Since)128 562.8 Q F1(SIGINT)4.675 E F0(and)4.675 E F1(SIGQUIT)4.675 E F0 2.175 (are ignored during the e)4.675 F -.15(xe)-.15 G 2.175(cution of).15 F F1(system)4.675 E F0 4.675(,i)C 4.675(fy)-4.675 G 2.175(ou e)-4.675 F 2.175(xpect your)-.15 F .794(program to terminate on receipt of these s\ ignals you will need to arrange to do so yourself based on)128 574.8 R (the return v)128 586.8 Q(alue.)-.25 E F1 (@args = \("command", "arg1", "arg2"\);)152 604.8 Q (system\(@args\) == 0)152 616.8 Q(or die "system @args failed: $?")176 628.8 Q F0 1.902(If you')128 646.8 R 4.402(dl)-.5 G(ik)-4.402 E 4.402 (et)-.1 G 4.402(om)-4.402 G 1.902(anually inspect)-4.402 F F1(system) 4.401 E F0 3.001 -.55('s f)D 1.901(ailure, you can check all possible f) .45 F 1.901(ailure modes by)-.1 F(inspecting)128 658.8 Q F1($?)2.5 E F0 (lik)2.5 E 2.5(et)-.1 G(his:)-2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 89)162.62 F 0 Cg EP %%Page: 90 90 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (if \($? == \2551\) {)152 84 Q(print "failed to execute: $!\\n";)176 96 Q(})152 108 Q(elsif \($? & 127\) {)152 120 Q (printf "child died with signal %d, %s coredump\\n",)176 132 Q (\($? & 127\),)200 144 Q(\($? & 128\) ? \010with\010 : \010without\010;) 12 E(})152 156 Q(else {)152 168 Q (printf "child exited with value %d\\n", $? >> 8;)176 180 Q(})152 192 Q F0(Alternati)128 210 Q -.15(ve)-.25 G(ly).15 E 2.625(,y)-.65 G .125 (ou may inspect the v)-2.625 F .125(alue of)-.25 F F1 (${^CHILD_ERROR_NATIVE})2.625 E F0 .125(with the)2.625 F F1(W*\(\))2.625 E F0 .125(calls from)2.625 F(the)128 222 Q/F2 9/Times-Roman@0 SF(POSIX) 2.5 E F0(module.)2.5 E(When)128 240 Q F1(system)2.604 E F0 1.204 -.55 ('s a)D -.18(rg).55 G .104(uments are e).18 F -.15(xe)-.15 G .104 (cuted indirectly by the shell, results and return codes are subject to) .15 F(its quirks.)128 252 Q(See `)5 E -.74(``)-.74 G(STRING`').74 E 2.5 ('i)-.74 G 2.5(np)-2.5 G(erlop and `)-2.5 E(`e)-.74 E -.15(xe)-.15 G(c') .15 E 2.5('f)-.74 G(or details.)-2.5 E(Since)128 270 Q F1(system)2.5 E F0(does a)2.5 E F1(fork)2.5 E F0(and)2.5 E F1(wait)2.5 E F0(it may af) 2.5 E(fect a)-.25 E F1(SIGCHLD)2.5 E F0(handler)2.5 E 2.5(.S)-.55 G (ee perlipc for details.)-2.5 E(syswrite)108 286.8 Q F2(FILEHANDLE)2.5 E F0(,SCALAR,LENGTH,OFFSET)A(syswrite)108 298.8 Q F2(FILEHANDLE)2.5 E F0 (,SCALAR,LENGTH)A(syswrite)108 310.8 Q F2(FILEHANDLE)2.5 E F0(,SCALAR)A .521(Attempts to write)128 322.8 R F2(LENGTH)3.021 E F0 .521 (bytes of data from v)3.021 F(ariable)-.25 E F2(SCALAR)3.021 E F0 .521 (to the speci\214ed)3.021 F F2(FILEHANDLE)3.021 E F0 3.022(,u)C(sing) -3.022 E/F3 10/Times-Italic@0 SF(write)128 334.8 Q F0 2.989(\(2\). If) 1.666 F F2(LENGTH)2.989 E F0 .488(is not speci\214ed, writes whole)2.989 F F2(SCALAR)2.988 E F0 5.488(.I)C 2.988(tb)-5.488 G .488(ypasses b) -2.988 F(uf)-.2 E(fered)-.25 E F2(IO)2.988 E F0 2.988(,s)C 2.988(om) -2.988 G .488(ixing this)-2.988 F 1.063(with reads \(other than)128 346.8 R F1(sysread\(\)\))3.563 E F0(,)A F1(print)3.563 E F0(,)A F1 (write)3.563 E F0(,)A F1(seek)3.563 E F0(,)A F1(tell)3.563 E F0 3.563 (,o)C(r)-3.563 E F1(eof)3.563 E F0 1.063(may cause confusion)3.563 F .613(because the perlio and stdio layers usually b)128 358.8 R(uf)-.2 E .613(fer data.)-.25 F .612 (Returns the number of bytes actually written,)5.613 F(or)128 370.8 Q F1 (undef)3.971 E F0 1.472(if there w)3.972 F 1.472 (as an error \(in this case the errno v)-.1 F(ariable)-.25 E F1($!)3.972 E F0 1.472(is also set\).)3.972 F 1.472(If the)6.472 F F2(LENGTH)3.972 E F0(is)3.972 E .291(greater than the data a)128 382.8 R -.25(va)-.2 G .291(ilable in the).25 F F2(SCALAR)2.791 E F0 .291(after the)2.791 F F2 (OFFSET)2.791 E F0 2.791(,o)C .291(nly as much data as is a)-2.791 F -.25(va)-.2 G .29(ilable will).25 F(be written.)128 394.8 Q(An)128 412.8 Q F2(OFFSET)3.115 E F0 .616(may be speci\214ed to write the data from s\ ome part of the string other than the be)3.115 F(ginning.)-.15 E 3.84 (An)128 424.8 S -2.25 -.15(eg a)-3.84 H(ti).15 E -.15(ve)-.25 G F2 (OFFSET)3.99 E F0 1.34(speci\214es writing that man)3.84 F 3.839(yc)-.15 G 1.339(haracters counting backw)-3.839 F 1.339 (ards from the end of the)-.1 F 2.5(string. If)128 436.8 R F2(SCALAR)2.5 E F0(is of length zero, you can only use an)2.5 E F2(OFFSET)2.5 E F0 (of 0.)2.5 E/F4 9/Times-Bold@0 SF -1.08(WA)128 454.8 S(RNING)1.08 E F0 4.215(:I)C 4.215(ft)-4.215 G 1.715(he \214lehandle is mark)-4.215 F(ed) -.1 E F1(:utf8)4.215 E F0 4.215(,U)C 1.715(nicode characters encoded in) -4.215 F F2(UTF\2558)4.216 E F0 1.716(are written)4.216 F 1.636 (instead of bytes, and the)128 466.8 R F2(LENGTH)4.136 E F0(,)A F2 (OFFSET)4.136 E F0 4.136(,a)C 1.636(nd return v)-4.136 F 1.636(alue of) -.25 F F3(syswrite\(\))4.136 E F0 1.635(are in \(UTF8\255encoded)4.135 F 4.722(Unicode\) characters.)128 478.8 R(The)9.722 E F1(:encoding\(...\)) 7.222 E F0 4.722(layer implicitly introduces the)7.222 F F1(:utf8)7.223 E F0(layer)7.223 E(.)-.55 E(Alternately)128 490.8 Q 2.58(,i)-.65 G 2.58 (ft)-2.58 G .08(he handle is not mark)-2.58 F .079 (ed with an encoding b)-.1 F .079 (ut you attempt to write characters with code)-.2 F(points o)128 502.8 Q -.15(ve)-.15 G 2.5(r2).15 G(55, raises an e)-2.5 E 2.5(xception. See) -.15 F -.74(``)2.5 G(binmode').74 E(', `)-.74 E(`open')-.74 E (', and the)-.74 E F1(open)2.5 E F0(pragma, open.)2.5 E(tell)108 519.6 Q F2(FILEHANDLE)2.5 E F0(tell)108 531.6 Q 1.813 (Returns the current position)128 531.6 R F3 1.813(in bytes)4.313 F F0 (for)4.313 E F2(FILEHANDLE)4.313 E F0 4.313(,o)C 4.314<72ad>-4.313 G 4.314(1o)-4.314 G 4.314(ne)-4.314 G(rror)-4.314 E(.)-.55 E F2 (FILEHANDLE)6.814 E F0 1.814(may be an)4.314 F -.15(ex)128 543.6 S .59 (pression whose v).15 F .59(alue gi)-.25 F -.15(ve)-.25 G 3.09(st).15 G .589(he name of the actual \214lehandle.)-3.09 F(If)5.589 E F2 (FILEHANDLE)3.089 E F0 .589(is omitted, assumes)3.089 F (the \214le last read.)128 555.6 Q .095(Note the)128 573.6 R F3 .095 (in bytes)2.595 F F0 2.595(:e)C -.15(ve)-2.845 G 2.595(ni).15 G 2.595 (ft)-2.595 G .095 (he \214lehandle has been set to operate on characters \(for e)-2.595 F .096(xample by using the)-.15 F F1(:encoding\(utf8\))128 585.6 Q F0 1.327(open layer\),)3.827 F F3(tell\(\))3.827 E F0 1.327 (will return byte of)3.827 F 1.326(fsets, not character of)-.25 F 1.326 (fsets \(because that)-.25 F -.1(wo)128 597.6 S(uld render).1 E F3 (seek\(\))2.5 E F0(and)2.5 E F3(tell\(\))2.5 E F0(rather slo)2.5 E(w\).) -.25 E .593(The return v)128 615.6 R .593(alue of)-.25 F F3(tell\(\)) 3.093 E F0 .593(for the standard streams lik)3.093 F 3.093(et)-.1 G(he) -3.093 E F2(STDIN)3.093 E F0 .594(depends on the operating system: it) 3.093 F(may return \2551 or something else.)128 627.6 Q F3(tell\(\))5 E F0(on pipes, \214fos, and sock)2.5 E(ets usually returns \2551.)-.1 E (There is no)128 645.6 Q F1(systell)2.5 E F0 2.5(function. Use)2.5 F F1 (sysseek\(FH, 0, 1\))2.5 E F0(for that.)2.5 E 1.86(Do not use)128 663.6 R F3(tell\(\))4.36 E F0 1.86(\(or other b)4.36 F(uf)-.2 E 1.859 (fered I/O operations\) on a \214lehandle that has been manipulated by) -.25 F F3(sysr)128 675.6 Q(ead\(\))-.37 E F0(,)A F3(syswrite\(\))2.5 E F0 2.5(,o)C(r)-2.5 E F3(sysseek\(\))2.5 E F0 5(.T)C (hose functions ignore the b)-5 E(uf)-.2 E(fering, while)-.25 E F3 (tell\(\))2.5 E F0(does not.)2.5 E(telldir)108 692.4 Q F2(DIRHANDLE)2.5 E F0 2.273(Returns the current position of the)128 704.4 R F1(readdir) 4.774 E F0 2.274(routines on)4.774 F F2(DIRHANDLE)4.774 E F0 7.274(.V)C 2.274(alue may be gi)-8.384 F -.15(ve)-.25 G 4.774(nt).15 G(o)-4.774 E F1(seekdir)128 716.4 Q F0 2.474 (to access a particular location in a directory)4.974 F(.)-.65 E F1 (telldir)7.473 E F0 2.473(has the same ca)4.973 F -.15(ve)-.2 G 2.473 (ats about).15 F(possible directory compaction as the corresponding sys\ tem library routine.)128 728.4 Q(perl v5.14.2)72 768 Q 198.17 (2011-10-01 90)162.62 F 0 Cg EP %%Page: 91 91 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(tie)108 84 Q/F1 9 /Times-Roman@0 SF -1.215(VA)2.5 G(RIABLE)1.215 E F0(,CLASSN)A(AME,LIST) -.35 E .256(This function binds a v)128 96 R .256 (ariable to a package class that will pro)-.25 F .257 (vide the implementation for the v)-.15 F(ariable.)-.25 E F1 -1.215(VA) 128 108 S(RIABLE)1.215 E F0 2.81(is the name of the v)5.31 F 2.809 (ariable to be enchanted.)-.25 F F1(CLASSN)7.809 E(AME)-.315 E F0 2.809 (is the name of a class)5.309 F .422 (implementing objects of correct type.)128 120 R(An)5.422 E 2.922(ya) -.15 G .422(dditional ar)-2.922 F .422(guments are passed to the)-.18 F /F2 10/Courier@0 SF(new)2.922 E F0 .422(method of the)2.922 F 4.427 (class \(meaning)128 132 R F2(TIESCALAR)6.927 E F0(,)A F2(TIEHANDLE) 6.927 E F0(,)A F2(TIEARRAY)6.927 E F0 6.927(,o)C(r)-6.927 E F2(TIEHASH) 6.927 E F0 6.926(\). T)B 4.426(ypically these are)-.8 F(ar)128 144 Q .972(guments such as might be passed to the)-.18 F F2(dbm_open\(\))3.472 E F0 .973(function of C.)3.473 F .973(The object returned by the)5.973 F F2(new)128 156 Q F0 .518(method is also returned by the)3.018 F F2(tie) 3.017 E F0 .517(function, which w)3.017 F .517(ould be useful if you w) -.1 F .517(ant to access other)-.1 F(methods in)128 168 Q F1(CLASSN)2.5 E(AME)-.315 E F0(.)A .267(Note that functions such as)128 186 R F2(keys) 2.767 E F0(and)2.767 E F2(values)2.768 E F0 .268 (may return huge lists when used on lar)2.768 F .268(ge objects, lik) -.18 F(e)-.1 E F1(DBM)128 198 Q F0 2.5(\214les. Y)2.5 F (ou may prefer to use the)-1.1 E F2(each)2.5 E F0(function to iterate o) 2.5 E -.15(ve)-.15 G 2.5(rs).15 G 2.5(uch. Example:)-2.5 F F2 6(#p)152 216 S(rint out history file offsets)-6 E(use NDBM_File;)152 228 Q (tie\(%HIST, \010NDBM_File\010, \010/usr/lib/news/history\010, 1, 0\);) 152 240 Q(while \(\($key,$val\) = each %HIST\) {)152 252 Q (print $key, \010 = \010, unpack\(\010L\010,$val\), "\\n";)176 264 Q(}) 152 276 Q(untie\(%HIST\);)152 288 Q F0 2.5(Ac)128 306 S (lass implementing a hash should ha)-2.5 E .3 -.15(ve t)-.2 H(he follo) .15 E(wing methods:)-.25 E F2(TIEHASH classname, LIST)152 324 Q (FETCH this, key)152 336 Q(STORE this, key, value)152 348 Q (DELETE this, key)152 360 Q(CLEAR this)152 372 Q(EXISTS this, key)152 384 Q(FIRSTKEY this)152 396 Q(NEXTKEY this, lastkey)152 408 Q (SCALAR this)152 420 Q(DESTROY this)152 432 Q(UNTIE this)152 444 Q F0 2.5(Ac)128 462 S(lass implementing an ordinary array should ha)-2.5 E .3 -.15(ve t)-.2 H(he follo).15 E(wing methods:)-.25 E F2 (TIEARRAY classname, LIST)152 480 Q(FETCH this, key)152 492 Q (STORE this, key, value)152 504 Q(FETCHSIZE this)152 516 Q (STORESIZE this, count)152 528 Q(CLEAR this)152 540 Q(PUSH this, LIST) 152 552 Q(POP this)152 564 Q(SHIFT this)152 576 Q(UNSHIFT this, LIST)152 588 Q(SPLICE this, offset, length, LIST)152 600 Q(EXTEND this, count)152 612 Q(DESTROY this)152 624 Q(UNTIE this)152 636 Q F0 2.5(Ac)128 654 S (lass implementing a \214lehandle should ha)-2.5 E .3 -.15(ve t)-.2 H (he follo).15 E(wing methods:)-.25 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 91)162.62 F 0 Cg EP %%Page: 92 92 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (TIEHANDLE classname, LIST)152 84 Q(READ this, scalar, length, offset) 152 96 Q(READLINE this)152 108 Q(GETC this)152 120 Q (WRITE this, scalar, length, offset)152 132 Q(PRINT this, LIST)152 144 Q (PRINTF this, format, LIST)152 156 Q(BINMODE this)152 168 Q(EOF this)152 180 Q(FILENO this)152 192 Q(SEEK this, position, whence)152 204 Q (TELL this)152 216 Q(OPEN this, mode, LIST)152 228 Q(CLOSE this)152 240 Q(DESTROY this)152 252 Q(UNTIE this)152 264 Q F0 2.5(Ac)128 282 S (lass implementing a scalar should ha)-2.5 E .3 -.15(ve t)-.2 H (he follo).15 E(wing methods:)-.25 E F1(TIESCALAR classname, LIST)152 300 Q(FETCH this,)152 312 Q(STORE this, value)152 324 Q(DESTROY this)152 336 Q(UNTIE this)152 348 Q F0 .326(Not all methods indicated abo)128 366 R .626 -.15(ve n)-.15 H .326(eed be implemented.).15 F .326 (See perltie, T)5.326 F .325(ie::Hash, T)-.35 F(ie::Array)-.35 E 2.825 (,T)-.65 G(ie::Scalar)-3.175 E(,)-.4 E(and T)128 378 Q(ie::Handle.)-.35 E(Unlik)128 396 Q(e)-.1 E F1(dbmopen)2.756 E F0 2.756(,t)C(he)-2.756 E F1(tie)2.756 E F0 .256(function will not)2.756 F F1(use)2.757 E F0(or) 2.757 E F1(require)2.757 E F0 2.757(am)2.757 G .257 (odule for you; you need to do that)-2.757 F -.15(ex)128 408 S (plicitly yourself.).15 E(See DB_File or the)5 E/F2 10/Times-Italic@0 SF (Con\214g)2.5 E F0(module for interesting)2.5 E F1(tie)2.5 E F0 (implementations.)2.5 E -.15(Fo)128 426 S 2.5(rf).15 G (urther details see perltie, `)-2.5 E(`tied)-.74 E/F3 9/Times-Roman@0 SF -1.215(VA)2.5 G(RIABLE)1.215 E F0 -.74('')C(.).74 E(tied)108 442.8 Q F3 -1.215(VA)2.5 G(RIABLE)1.215 E F0 .86 (Returns a reference to the object underlying)128 454.8 R F3 -1.215(VA) 3.36 G(RIABLE)1.215 E F0 .86(\(the same v)3.36 F .86(alue that w)-.25 F .86(as originally returned)-.1 F .304(by the)128 466.8 R F1(tie)2.804 E F0 .304(call that bound the v)2.804 F .305(ariable to a package.\))-.25 F .305(Returns the unde\214ned v)5.305 F .305(alue if)-.25 F F3 -1.215 (VA)2.805 G(RIABLE)1.215 E F0(isn')2.805 E(t)-.18 E(tied to a package.) 128 478.8 Q(time)108 495.6 Q 1.165 (Returns the number of non-leap seconds since whate)128 507.6 R -.15(ve) -.25 G 3.665(rt).15 G 1.164(ime the system considers to be the epoch,) -3.665 F 1.953(suitable for feeding to)128 519.6 R F1(gmtime)4.453 E F0 (and)4.453 E F1(localtime)4.453 E F0 4.454(.O)C 4.454(nm)-4.454 G 1.954 (ost systems the epoch is 00:00:00)-4.454 F F3(UTC)4.454 E F0(,)A .676 (January 1, 1970; a prominent e)128 531.6 R .676(xception being Mac)-.15 F F3(OS)3.176 E F0 .676(Classic which uses 00:00:00, January 1, 1904) 3.176 F(in the current local time zone for its epoch.)128 543.6 Q -.15 (Fo)128 561.6 S 3.169(rm).15 G .669 (easuring time in better granularity than one second, use the T)-3.169 F .67(ime::HiRes module from Perl 5.8)-.35 F(onw)128 573.6 Q 1.397 (ards \(or from)-.1 F F3(CP)3.897 E(AN)-.828 E F0 1.397 (before then\), or)3.897 F 3.897(,i)-.4 G 3.897(fy)-3.897 G 1.397(ou ha) -3.897 F -.15(ve)-.2 G F2 -.1(ge)4.047 G(ttimeofday).1 E F0 1.397 (\(2\), you may be able to use the)1.666 F F1(syscall)128 585.6 Q F0 (interf)2.5 E(ace of Perl.)-.1 E(See perlf)5 E(aq8 for details.)-.1 E -.15(Fo)128 603.6 S 3.316(rd).15 G .816 (ate and time processing look at the man)-3.316 F 3.317(yr)-.15 G .817 (elated modules on)-3.317 F F3(CP)3.317 E(AN)-.828 E F0 5.817(.F)C .817 (or a comprehensi)-5.967 F 1.117 -.15(ve d)-.25 H(ate).15 E (and time representation look at the DateT)128 615.6 Q(ime module.)-.35 E(times)108 632.4 Q .214(Returns a four)128 644.4 R .214 (-element list gi)-.2 F .213 (ving the user and system times in seconds for this process and an)-.25 F 2.713(ye)-.15 G(xited)-2.863 E(children of this process.)128 656.4 Q F1(\($user,$system,$cuser,$csystem\) = times;)152 674.4 Q F0 (In scalar conte)128 692.4 Q(xt,)-.15 E F1(times)2.5 E F0(returns)2.5 E F1($user)2.5 E F0(.)A(Children')128 710.4 Q 2.5(st)-.55 G (imes are only included for terminated children.)-2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 92)162.62 F 0 Cg EP %%Page: 93 93 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(tr///)108 84 Q (The transliteration operator)128 84 Q 5(.S)-.55 G(ame as)-5 E/F1 10 /Courier@0 SF(y///)2.5 E F0 5(.S)C(ee `)-5 E(`Quote and Quote-lik)-.74 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E (truncate)108 100.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(,LENGTH) A(truncate)108 112.8 Q F2(EXPR)2.5 E F0(,LENGTH)A -.35(Tr)128 124.8 S 1.43(uncates the \214le opened on).35 F F2(FILEHANDLE)3.93 E F0 3.93(,o) C 3.93(rn)-3.93 G 1.43(amed by)-3.93 F F2(EXPR)3.931 E F0 3.931(,t)C 3.931(ot)-3.931 G 1.431(he speci\214ed length.)-3.931 F 1.431(Raises an) 6.431 F -.15(ex)128 136.8 S(ception if truncate isn').15 E 2.5(ti)-.18 G (mplemented on your system.)-2.5 E(Returns true if successful,)5 E F1 (undef)2.5 E F0(on error)2.5 E(.)-.55 E(The beha)128 154.8 Q (vior is unde\214ned if)-.2 E F2(LENGTH)2.5 E F0 (is greater than the length of the \214le.)2.5 E .542 (The position in the \214le of)128 172.8 R F2(FILEHANDLE)3.041 E F0 .541 (is left unchanged.)3.041 F -1.1(Yo)5.541 G 3.041(um)1.1 G .541(ay w) -3.041 F .541(ant to call seek before writing)-.1 F(to the \214le.)128 184.8 Q(uc)108 201.6 Q F2(EXPR)2.5 E F0(uc)108 213.6 Q .572 (Returns an uppercased v)128 213.6 R .572(ersion of)-.15 F F2(EXPR)3.072 E F0 5.572(.T)C .572(his is the internal function implementing the) -5.572 F F1(\\U)3.073 E F0 .573(escape in)3.073 F .438 (double-quoted strings.)128 225.6 R .438 (It does not attempt to do titlecase mapping on initial letters.)5.438 F .438(See `)5.438 F(`uc\214rst')-.74 E 2.938('f)-.74 G(or)-2.938 E(that.) 128 237.6 Q(If)128 255.6 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1 ($_)2.5 E F0(.)A(This function beha)128 273.6 Q -.15(ve)-.2 G 2.5(st).15 G(he same w)-2.5 E(ay under v)-.1 E (arious pragma, such as in a locale, as `)-.25 E(`lc')-.74 E 2.5('d)-.74 G(oes.)-2.5 E(uc\214rst)108 290.4 Q F2(EXPR)2.5 E F0(uc\214rst)108 302.4 Q 1.45(Returns the v)128 314.4 R 1.45(alue of)-.25 F F2(EXPR)3.95 E F0 1.45(with the \214rst character in uppercase \(titlecase in Unicode\).) 3.95 F 1.451(This is the)6.451 F(internal function implementing the)128 326.4 Q F1(\\u)2.5 E F0(escape in double-quoted strings.)2.5 E(If)128 344.4 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A (This function beha)128 362.4 Q -.15(ve)-.2 G 2.5(st).15 G(he same w) -2.5 E(ay under v)-.1 E(arious pragma, such as in a locale, as `)-.25 E (`lc')-.74 E 2.5('d)-.74 G(oes.)-2.5 E(umask)108 379.2 Q F2(EXPR)2.5 E F0(umask)108 391.2 Q 1.039(Sets the umask for the process to)128 403.2 R F2(EXPR)3.538 E F0 1.038(and returns the pre)3.538 F 1.038(vious v)-.25 F 3.538(alue. If)-.25 F F2(EXPR)3.538 E F0 1.038(is omitted, merely) 3.538 F(returns the current umask.)128 415.2 Q .027(The Unix permission) 128 433.2 R F1<72777872ad78adadad>2.527 E F0 .028 (is represented as three sets of three bits, or three octal digits:) 2.527 F F1(0750)2.528 E F0 2.352 (\(the leading 0 indicates octal and isn')128 445.2 R 4.852(to)-.18 G 2.352(ne of the digits\).)-4.852 F(The)7.352 E F1(umask)4.852 E F0 -.25 (va)4.852 G 2.351(lue is such a number).25 F 2.305 (representing disabled permissions bits.)128 457.2 R 2.306 (The permission \(or `)7.306 F(`mode')-.74 E 2.306('\) v)-.74 F 2.306 (alues you pass)-.25 F F1(mkdir)4.806 E F0(or)4.806 E F1(sysopen)128 469.2 Q F0 .3(are modi\214ed by your umask, so e)2.8 F -.15(ve)-.25 G 2.8(ni).15 G 2.8(fy)-2.8 G .3(ou tell)-2.8 F F1(sysopen)2.8 E F0 .3 (to create a \214le with permissions)2.8 F F1(0777)128 481.2 Q F0 3.204 (,i)C 3.204(fy)-3.204 G .704(our umask is)-3.204 F F1(0022)3.204 E F0 3.205(,t)C .705 (hen the \214le will actually be created with permissions)-3.205 F F1 (0755)3.205 E F0 5.705(.I)C 3.205(fy)-5.705 G(our)-3.205 E F1(umask)128 493.2 Q F0(were)3.439 E F1(0027)3.439 E F0 .939(\(group can')3.439 F 3.439(tw)-.18 G .939(rite; others can')-3.439 F 3.439(tr)-.18 G .938 (ead, write, or e)-3.439 F -.15(xe)-.15 G .938(cute\), then passing).15 F F1(sysopen)3.438 E(0666)128 505.2 Q F0 -.1(wo)2.5 G (uld create a \214le with mode).1 E F1(0640)2.5 E F0(\(because)2.5 E F1 (0666 &~ 027)2.5 E F0(is)2.5 E F1(0640)2.5 E F0(\).)A(Here')128 523.2 Q 2.581(ss)-.55 G .081(ome advice: supply a creation mode of)-2.581 F F1 (0666)2.582 E F0 .082(for re)2.582 F .082(gular \214les \(in)-.15 F F1 (sysopen)2.582 E F0 2.582(\)a)C .082(nd one of)-2.582 F F1(0777)2.582 E F0 .676(for directories \(in)128 535.2 R F1(mkdir)3.176 E F0 3.176(\)a)C .676(nd e)-3.176 F -.15(xe)-.15 G .676(cutable \214les.).15 F .676 (This gi)5.676 F -.15(ve)-.25 G 3.176(su).15 G .675 (sers the freedom of choice: if the)-3.176 F 3.175(yw)-.15 G(ant)-3.275 E 1.404(protected \214les, the)128 547.2 R 3.904(ym)-.15 G 1.404 (ight choose process umasks of)-3.904 F F1(022)3.904 E F0(,)A F1(027) 3.904 E F0 3.904(,o)C 3.905(re)-3.904 G -.15(ve)-4.155 G 3.905(nt).15 G 1.405(he particularly antisocial)-3.905 F 1.996(mask of)128 559.2 R F1 (077)4.496 E F0 6.996(.P)C 1.996(rograms should rarely if e)-6.996 F -.15(ve)-.25 G 4.496(rm).15 G(ak)-4.496 E 4.496(ep)-.1 G(olic)-4.496 E 4.496(yd)-.15 G 1.995(ecisions better left to the user)-4.496 F 6.995 (.T)-.55 G(he)-6.995 E -.15(ex)128 571.2 S 1.265 (ception to this is when writing \214les that should be k).15 F 1.266 (ept pri)-.1 F -.25(va)-.25 G 1.266(te: mail \214les, web bro).25 F 1.266(wser cookies,)-.25 F/F3 10/Times-Italic@0 SF(.rhosts)128 583.2 Q F0(\214les, and so on.)2.5 E(If)128 601.2 Q F3(umask)2.955 E F0 .454(\(\ 2\) is not implemented on your system and you are trying to restrict ac\ cess for)1.666 F F3(your)2.954 E(self)-.1 E F0(\(i.e.,)2.954 E F1 .012 (\(EXPR & 0700\) > 0)128 613.2 R F0 .012(\), raises an e)B 2.512 (xception. If)-.15 F F3(umask)2.512 E F0 .012 (\(2\) is not implemented and you are not trying)1.666 F (to restrict access for yourself, returns)128 625.2 Q F1(undef)2.5 E F0 (.)A .516(Remember that a umask is a number)128 643.2 R 3.016(,u)-.4 G .516(sually gi)-3.016 F -.15(ve)-.25 G 3.016(ni).15 G 3.016(no)-3.016 G .516(ctal; it is)-3.016 F F3(not)3.016 E F0 3.016(as)3.016 G .516 (tring of octal digits.)-3.016 F .516(See also)5.516 F -.74(``)128 655.2 S(oct').74 E(', if all you ha)-.74 E .3 -.15(ve i)-.2 H 2.5(sas).15 G (tring.)-2.5 E(undef)108 672 Q F2(EXPR)2.5 E F0(undef)108 684 Q .142 (Unde\214nes the v)128 696 R .143(alue of)-.25 F F2(EXPR)2.643 E F0 2.643(,w)C .143(hich must be an lv)-2.643 F 2.643(alue. Use)-.25 F .143 (only on a scalar v)2.643 F .143(alue, an array \(using)-.25 F F1(@) 2.643 E F0(\),)A 3.646(ah)128 708 S 1.146(ash \(using)-3.646 F F1(%) 3.646 E F0 1.146(\), a subroutine \(using)B F1(&)3.645 E F0 1.145 (\), or a type)B 1.145(glob \(using)-.15 F F1(*)3.645 E F0 3.645 (\). Saying)B F1 1.145(undef $hash{$key})3.645 F F0 1.119 (will probably not do what you e)128 720 R 1.119 (xpect on most prede\214ned v)-.15 F 1.119(ariables or)-.25 F F2(DBM) 3.619 E F0 1.12(list v)3.62 F 1.12(alues, so don')-.25 F 3.62(td)-.18 G (o)-3.62 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 93)162.62 F 0 Cg EP %%Page: 94 94 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .068 (that; see delete.)128 84 R(Al)5.068 E -.1(wa)-.1 G .068 (ys returns the unde\214ned v).1 F 2.568(alue. Y)-.25 F .068 (ou can omit the)-1.1 F/F1 9/Times-Roman@0 SF(EXPR)2.568 E F0 2.568(,i)C 2.568(nw)-2.568 G .068(hich case nothing is)-2.568 F .676 (unde\214ned, b)128 96 R .677(ut you still get an unde\214ned v)-.2 F .677(alue that you could, for instance, return from a subroutine,)-.25 F (assign to a v)128 108 Q(ariable, or pass as a parameter)-.25 E 5(.E) -.55 G(xamples:)-5 E/F2 10/Courier@0 SF(undef $foo;)152 126 Q (undef $bar{\010blurfl\010};)152 138 Q 6(#C)36 G (ompare to: delete $bar{\010blurfl\010};)-6 E(undef @ary;)152 150 Q (undef %hash;)152 162 Q(undef &mysub;)152 174 Q(undef *xyz;)152 186 Q 6 (#d)42 G(estroys $xyz, @xyz, %xyz, &xyz, etc.)-6 E (return \(wantarray ? \(undef, $errmsg\) : undef\) if $they_blew_it;)152 198 Q(select undef, undef, undef, 0.25;)152 210 Q (\($a, $b, undef, $c\) = &foo;)152 222 Q 6(#I)42 G (gnore third value returned)-6 E F0(Note that this is a unary operator) 128 240 Q 2.5(,n)-.4 G(ot a list operator)-2.5 E(.)-.55 E(unlink)108 256.8 Q F1(LIST)2.5 E F0(unlink)108 268.8 Q .829(Deletes a list of \214\ les. On success, it returns the number of \214les it successfully delet\ ed. On f)128 280.8 R .829(ailure, it)-.1 F(returns f)128 292.8 Q (alse and sets)-.1 E F2($!)2.5 E F0(\(errno\):)5 E F2 (my $unlinked = unlink \010a\010, \010b\010, \010c\010;)152 310.8 Q (unlink @goners;)152 322.8 Q(unlink glob "*.bak";)152 334.8 Q F0 .547 (On error)128 352.8 R(,)-.4 E F2(unlink)3.047 E F0 .548 (will not tell you which \214les it could not remo)3.048 F -.15(ve)-.15 G 5.548(.I).15 G 3.048(fy)-5.548 G .548(ou w)-3.048 F .548(ant to kno) -.1 F 3.048(ww)-.25 G .548(hich \214les)-3.048 F(you could not remo)128 364.8 Q -.15(ve)-.15 G 2.5(,t).15 G(ry them one at a time:)-2.5 E F2 (foreach my $file \( @goners \) {)158 382.8 Q (unlink $file or warn "Could not unlink $file: $!";)182 394.8 Q(})158 406.8 Q F0(Note:)128 424.8 Q F2(unlink)4.362 E F0 1.862(will not attemp\ t to delete directories unless you are superuser and the)4.362 F/F3 10 /Times-Bold@0 SF4.362 E F0 1.861(\215ag is)4.361 F 1.463 (supplied to Perl. Ev)128 436.8 R 1.463 (en if these conditions are met, be w)-.15 F 1.463 (arned that unlinking a directory can in\215ict)-.1 F .23 (damage on your \214lesystem.)128 448.8 R(Finally)5.23 E 2.729(,u)-.65 G (sing)-2.729 E F2(unlink)2.729 E F0 .229 (on directories is not supported on man)2.729 F 2.729(yo)-.15 G (perating)-2.729 E 2.5(systems. Use)128 460.8 R F2(rmdir)2.5 E F0 (instead.)2.5 E(If)128 478.8 Q F1(LIST)2.5 E F0(is omitted,)2.5 E F2 (unlink)2.5 E F0(uses)2.5 E F2($_)2.5 E F0(.)A(unpack)108 495.6 Q F1 (TEMPLA)2.5 E(TE)-.999 E F0(,EXPR)A(unpack)108 507.6 Q F1(TEMPLA)2.5 E (TE)-.999 E F2(unpack)128 519.6 Q F0 .37(does the re)2.87 F -.15(ve)-.25 G .37(rse of).15 F F2(pack)2.87 E F0 2.87(:i)C 2.87(tt)-2.87 G(ak)-2.87 E .37(es a string and e)-.1 F .37(xpands it out into a list of v)-.15 F 2.87(alues. \(In)-.25 F(scalar)2.87 E(conte)128 531.6 Q (xt, it returns merely the \214rst v)-.15 E(alue produced.\))-.25 E(If) 128 549.6 Q F1(EXPR)2.5 E F0(is omitted, unpacks the)2.5 E F2($_)2.5 E F0 2.5(string. See)2.5 F (perlpacktut for an introduction to this function.)2.5 E .073 (The string is brok)128 567.6 R .073(en into chunks described by the)-.1 F F1(TEMPLA)2.573 E(TE)-.999 E F0 5.072(.E)C .072(ach chunk is con) -5.072 F -.15(ve)-.4 G .072(rted separately to a).15 F -.25(va)128 579.6 S 3.783(lue. T).25 F(ypically)-.8 E 3.783(,e)-.65 G 1.284 (ither the string is a result of)-3.783 F F2(pack)3.784 E F0 3.784(,o)C 3.784(rt)-3.784 G 1.284(he characters of the string represent a C)-3.784 F(structure of some kind.)128 591.6 Q(The)128 609.6 Q F1(TEMPLA)2.5 E (TE)-.999 E F0(has the same format as in the)2.5 E F2(pack)2.5 E F0 2.5 (function. Here')2.5 F 2.5(sas)-.55 G(ubroutine that does substring:) -2.5 E F2(sub substr {)152 627.6 Q(my\($what,$where,$howmuch\) = @_;)176 639.6 Q(unpack\("x$where a$howmuch", $what\);)176 651.6 Q(})152 663.6 Q F0(and then there')128 681.6 Q(s)-.55 E F2 (sub ordinal { unpack\("W",$_[0]\); } # same as ord\(\))152 699.6 Q F0 .546(In addition to \214elds allo)128 717.6 R .546(wed in)-.25 F/F4 10 /Times-Italic@0 SF(pac)3.046 E(k\(\))-.2 E F0 3.046(,y)C .545 (ou may pre\214x a \214eld with a % to indicate that you)-3.046 F -.1(wa)128 729.6 S 1.563(nt a \255bit checksum of the items i\ nstead of the items themselv).1 F 4.063(es. Def)-.15 F 1.563 (ault is a 16\255bit)-.1 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 94) 162.62 F 0 Cg EP %%Page: 95 95 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 3.157 (checksum. Checksum)128 84 R .657(is calculated by summing numeric v) 3.157 F .657(alues of e)-.25 F .657(xpanded v)-.15 F .657 (alues \(for string \214elds)-.25 F(the sum of)128 96 Q/F1 10/Courier@0 SF(ord\($char\))2.5 E F0(is tak)2.5 E (en; for bit \214elds the sum of zeroes and ones\).)-.1 E -.15(Fo)128 114 S 2.5(re).15 G(xample, the follo)-2.65 E (wing computes the same number as the System V sum program:)-.25 E F1 ($checksum = do {)152 132 Q(local $/;)176 144 Q 6(#s)12 G(lurp!)-6 E (unpack\("%32W*",<>\) % 65535;)176 156 Q(};)152 168 Q F0(The follo)128 186 Q(wing ef)-.25 E (\214ciently counts the number of set bits in a bit v)-.25 E(ector:)-.15 E F1($setbits = unpack\("%32b*", $selectmask\);)152 204 Q F0(The)128 222 Q F1(p)3.005 E F0(and)3.005 E F1(P)3.005 E F0 .505 (formats should be used with care.)3.005 F .505(Since Perl has no w) 5.505 F .506(ay of checking whether the v)-.1 F(alue)-.25 E 1.971 (passed to)128 234 R F1(unpack\(\))4.471 E F0 1.971(corresponds to a v) 4.471 F 1.971(alid memory location, passing a pointer v)-.25 F 1.97 (alue that')-.25 F 4.47(sn)-.55 G(ot)-4.47 E(kno)128 246 Q(wn to be v) -.25 E(alid is lik)-.25 E(ely to ha)-.1 E .3 -.15(ve d)-.2 H (isastrous consequences.).15 E 1.895(If there are more pack codes or if\ the repeat count of a \214eld or a group is lar)128 264 R 1.895 (ger than what the)-.18 F .349(remainder of the input string allo)128 276 R .349(ws, the result is not well de\214ned: the repeat count may b\ e decreased,)-.25 F(or)128 288 Q F1(unpack\(\))2.81 E F0 .31 (may produce empty strings or zeros, or it may raise an e)2.81 F 2.811 (xception. If)-.15 F .311(the input string is)2.811 F (longer than one described by the)128 300 Q/F2 9/Times-Roman@0 SF (TEMPLA)2.5 E(TE)-.999 E F0 2.5(,t)C (he remainder of that input string is ignored.)-2.5 E(See `)128 318 Q (`pack')-.74 E 2.5('f)-.74 G(or more e)-2.5 E(xamples and notes.)-.15 E (untie)108 334.8 Q F2 -1.215(VA)2.5 G(RIABLE)1.215 E F0 .455 (Breaks the binding between a v)128 346.8 R .455(ariable and a package.) -.25 F(\(See)5.455 E F1(tie)2.955 E F0 2.955(.\) Has)B .455(no ef)2.955 F .455(fect if the v)-.25 F .455(ariable is not)-.25 F(tied.)128 358.8 Q (unshift)108 375.6 Q F2(ARRA)2.5 E(Y)-.945 E F0(,LIST)A(unshift)108 387.6 Q F2(EXPR)2.5 E F0(,LIST)A 2.219(Does the opposite of a)128 399.6 R F1(shift)4.719 E F0 7.219(.O)C 4.719(rt)-7.219 G 2.219 (he opposite of a)-4.719 F F1(push)4.72 E F0 4.72(,d)C 2.22 (epending on ho)-4.72 F 4.72(wy)-.25 G 2.22(ou look at it.)-4.72 F (Prepends list to the front of the array and returns the ne)128 411.6 Q 2.5(wn)-.25 G(umber of elements in the array)-2.5 E(.)-.65 E F1 (unshift\(@ARGV, \010\255e\010\) unless $ARGV[0] =~ /^\255/;)152 429.6 Q F0 .881(Note the)128 447.6 R F2(LIST)3.38 E F0 .88(is prepended whole, \ not one element at a time, so the prepended elements stay in the)3.38 F (same order)128 459.6 Q 5(.U)-.55 G(se)-5 E F1(reverse)2.5 E F0 (to do the re)2.5 E -.15(ve)-.25 G(rse.).15 E 2.513 (Starting with Perl 5.14,)128 477.6 R F1(unshift)5.013 E F0 2.513 (can tak)5.013 F 5.013(eas)-.1 G(calar)-5.013 E F2(EXPR)5.014 E F0 5.014 (,w)C 2.514(hich must hold a reference to an)-5.014 F 2.445 (unblessed array)128 489.6 R 7.445(.T)-.65 G 2.445(he ar)-7.445 F 2.445 (gument will be dereferenced automatically)-.18 F 7.445(.T)-.65 G 2.445 (his aspect of)-7.445 F F1(unshift)4.945 E F0(is)4.945 E (considered highly e)128 501.6 Q 2.5(xperimental. The)-.15 F -.15(ex)2.5 G(act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(use Module)108 518.4 Q F2 .25(VERSION LIST)2.5 F F0(use Module) 108 530.4 Q F2(VERSION)2.5 E F0(use Module)108 542.4 Q F2(LIST)2.5 E F0 (use Module)108 554.4 Q(use)108 566.4 Q F2(VERSION)2.5 E F0 .009(Import\ s some semantics into the current package from the named module, genera\ lly by aliasing certain)128 578.4 R(subroutine or v)128 590.4 Q (ariable names into your package.)-.25 E(It is e)5 E(xactly equi)-.15 E -.25(va)-.25 G(lent to).25 E F1 (BEGIN { require Module; Module\255>import\( LIST \); })152 608.4 Q F0 -.15(ex)128 626.4 S(cept that Module).15 E/F3 10/Times-Italic@0 SF(must) 2.5 E F0(be a bare)2.5 E -.1(wo)-.25 G 2.5(rd. The).1 F (importation can be made conditional; see if.)2.5 E 1.517 (In the peculiar)128 644.4 R F1 1.516(use VERSION)4.017 F F0(form,)4.016 E F2(VERSION)4.016 E F0 1.516(may be either a positi)4.016 F 1.816 -.15 (ve d)-.25 H 1.516(ecimal fraction such as).15 F .001 (5.006, which will be compared to)128 656.4 R F1($])2.501 E F0 2.501(,o) C 2.501(rav)-2.501 G .001 (\255string of the form v5.6.1, which will be compared to)-2.501 F F1 ($^V)2.502 E F0(\(aka)128 668.4 Q F1($PERL_VERSION)2.655 E F0 2.655 (\). An)B -.15(ex)2.655 G .155(ception is raised if).15 F F2(VERSION) 2.655 E F0 .155(is greater than the v)2.655 F .154 (ersion of the current)-.15 F .307(Perl interpreter; Perl will not atte\ mpt to parse the rest of the \214le.)128 680.4 R .307(Compare with `) 5.307 F(`require')-.74 E .307(', which can)-.74 F .653 (do a similar check at run time.)128 692.4 R(Symmetrically)5.652 E(,) -.65 E F1 .652(no VERSION)3.152 F F0(allo)3.152 E .652 (ws you to specify that you w)-.25 F .652(ant a)-.1 F -.15(ve)128 704.4 S(rsion of Perl older than the speci\214ed one.).15 E(Specifying)128 722.4 Q F2(VERSION)3.497 E F0 .998 (as a literal of the form v5.6.1 should generally be a)3.497 F -.2(vo) -.2 G .998(ided, because it leads to).2 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 95)162.62 F 0 Cg EP %%Page: 96 96 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .13 (misleading error messages under earlier v)128 84 R .129 (ersions of Perl \(that is, prior to 5.6.0\) that do not support this) -.15 F 2.5(syntax. The)128 96 R(equi)2.5 E -.25(va)-.25 G (lent numeric v).25 E(ersion should be used instead.)-.15 E/F1 10 /Courier@0 SF(use v5.6.1;)152 114 Q 6(#c)30 G(ompile time version check) -6 E(use 5.6.1;)152 126 Q 6(#d)36 G(itto)-6 E(use 5.006_001;)152 138 Q 6 (#d)12 G(itto; preferred for backwards compatibility)-6 E F0 .656 (This is often useful if you need to check the current Perl v)128 156 R .657(ersion before)-.15 F F1(use)3.157 E F0 .657 (ing library modules that)B -.1(wo)128 168 S(n').1 E 2.5(tw)-.18 G (ork with older v)-2.6 E(ersions of Perl.)-.15 E(\(W)5 E 2.5(et)-.8 G (ry not to do this more than we ha)-2.5 E .3 -.15(ve t)-.2 H(o.\)).15 E .545(Also, if the speci\214ed Perl v)128 186 R .544 (ersion is greater than or equal to 5.9.5,)-.15 F F1 .544(use VERSION) 3.044 F F0 .544(will also load the)3.044 F F1(feature)128 198 Q F0 .155 (pragma and enable all features a)2.655 F -.25(va)-.2 G .155 (ilable in the requested v).25 F 2.655(ersion. See)-.15 F 2.655 (feature. Similarly)2.655 F 2.655(,i)-.65 G(f)-2.655 E .062 (the speci\214ed Perl v)128 210 R .061 (ersion is greater than or equal to 5.11.0, strictures are enabled le) -.15 F .061(xically as with)-.15 F F1(use)2.561 E(strict)128 222 Q F0 (\(e)2.5 E(xcept that the)-.15 E/F2 10/Times-Italic@0 SF(strict.pm)2.5 E F0(\214le is not actually loaded\).)2.5 E(The)128 240 Q F1(BEGIN)2.588 E F0 .088(forces the)2.588 F F1(require)2.588 E F0(and)2.588 E F1(import) 2.588 E F0 .088(to happen at compile time.)2.588 F(The)5.088 E F1 (require)2.588 E F0(mak)2.588 E .088(es sure)-.1 F 1.462 (the module is loaded into memory if it hasn')128 252 R 3.962(tb)-.18 G 1.462(een yet.)-3.962 F(The)6.462 E F1(import)3.961 E F0 1.461 (is not a b)3.961 F 1.461(uiltin; it')-.2 F 3.961(sj)-.55 G 1.461 (ust an)-3.961 F .698(ordinary static method call into the)128 264 R F1 (Module)3.198 E F0 .698 (package to tell the module to import the list of features)3.198 F 1.76 (back into the current package.)128 276 R 1.76 (The module can implement its)6.76 F F1(import)4.26 E F0 1.76(method an) 4.26 F 4.26(yw)-.15 G 1.76(ay it lik)-4.36 F(es,)-.1 E .046 (though most modules just choose to deri)128 288 R .346 -.15(ve t)-.25 H (heir).15 E F1(import)2.546 E F0 .047(method via inheritance from the) 2.547 F F1(Exporter)2.547 E F0 .954(class that is de\214ned in the)128 300 R F1(Exporter)3.454 E F0 3.454(module. See)3.454 F(Exporter)3.454 E 5.954(.I)-.55 G 3.454(fn)-5.954 G(o)-3.454 E F1(import)3.454 E F0 .953 (method can be found)3.453 F(then the call is skipped, e)128 312 Q -.15 (ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(here is an)-2.5 E/F3 9 /Times-Roman@0 SF -.495(AU)2.5 G -.162(TO).495 G(LO).162 E(AD)-.315 E F0 (method.)2.5 E .558(If you do not w)128 330 R .559 (ant to call the package')-.1 F(s)-.55 E F1(import)3.059 E F0 .559 (method \(for instance, to stop your namespace from)3.059 F (being altered\), e)128 342 Q(xplicitly supply the empty list:)-.15 E F1 (use Module \(\);)152 360 Q F0(That is e)128 378 Q(xactly equi)-.15 E -.25(va)-.25 G(lent to).25 E F1(BEGIN { require Module })152 396 Q F0 .748(If the)128 414 R F3(VERSION)3.248 E F0(ar)3.248 E .747 (gument is present between Module and)-.18 F F3(LIST)3.247 E F0 3.247 (,t)C .747(hen the)-3.247 F F1(use)3.247 E F0 .747(will call the)3.247 F F3(VERSION)3.247 E F0 2.32(method in class Module with the gi)128 426 R -.15(ve)-.25 G 4.82(nv).15 G 2.32(ersion as an ar)-4.97 F 4.82 (gument. The)-.18 F(def)4.821 E(ault)-.1 E F3(VERSION)4.821 E F0 (method,)4.821 E .038(inherited from the)128 438 R F3(UNIVERSAL)2.538 E F0 .038(class, croaks if the gi)2.538 F -.15(ve)-.25 G 2.538(nv).15 G .038(ersion is lar)-2.688 F .038(ger than the v)-.18 F .038 (alue of the v)-.25 F(ariable)-.25 E F1($Module::VERSION)128 450 Q F0(.) A(Ag)128 468 Q 2.205(ain, there is a distinction between omitting)-.05 F F3(LIST)4.706 E F0(\()4.706 E F1(import)A F0 2.206(called with no ar) 4.706 F 2.206(guments\) and an)-.18 F -.15(ex)128 480 S(plicit empty).15 E F3(LIST)2.5 E F1(\(\))2.5 E F0(\()2.5 E F1(import)A F0(not called\).) 2.5 E(Note that there is no comma after)5 E F3(VERSION)2.5 E F0(!)A 1.005(Because this is a wide-open interf)128 498 R 1.005 (ace, pragmas \(compiler directi)-.1 F -.15(ve)-.25 G 1.004 (s\) are also implemented this w).15 F(ay)-.1 E(.)-.65 E (Currently implemented pragmas are:)128 510 Q F1(use constant;)152 528 Q (use diagnostics;)152 540 Q(use integer;)152 552 Q(use sigtrap)152 564 Q (qw\(SEGV BUS\);)12 E(use strict)152 576 Q(qw\(subs vars refs\);)18 E (use subs)152 588 Q(qw\(afunc blurfl\);)30 E(use warnings qw\(all\);)152 600 Q(use sort)152 612 Q(qw\(stable _quicksort _mergesort\);)30 E F0 2.502(Some of these pseudo-modules import semantics into the current bl\ ock scope \(lik)128 630 R(e)-.1 E F1(strict)5.003 E F0(or)5.003 E F1 (integer)128 642 Q F0 4.92(,u)C(nlik)-4.92 E 4.92(eo)-.1 G 2.42(rdinary\ modules, which import symbols into the current package \(which are) -4.92 F(ef)128 654 Q(fecti)-.25 E .3 -.15(ve t)-.25 H (hrough the end of the \214le\).).15 E(Because)128 672 Q F1(use)3.966 E F0(tak)3.966 E 1.467(es ef)-.1 F 1.467(fect at compile time, it doesn') -.25 F 3.967(tr)-.18 G 1.467(espect the ordinary \215o)-3.967 F 3.967 (wc)-.25 G 1.467(ontrol of the code)-3.967 F .235(being compiled.)128 684 R .235(In particular)5.235 F 2.735(,p)-.4 G .235(utting a)-2.735 F F1(use)2.735 E F0 .234(inside the f)2.734 F .234 (alse branch of a conditional doesn')-.1 F 2.734(tp)-.18 G(re)-2.734 E -.15(ve)-.25 G .234(nt it).15 F .454(from being processed.)128 696 R .454(If a module or pragma only needs to be loaded conditionally)5.454 F 2.954(,t)-.65 G .455(his can be done)-2.954 F(using the if pragma:)128 708 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 96)162.62 F 0 Cg EP %%Page: 97 97 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use if $] < 5.008, "utf8";)152 84 Q (use if WANT_WARNINGS, warnings => qw\(all\);)152 96 Q F0(There')128 114 Q 4.987(sac)-.55 G(orresponding)-4.987 E F1(no)4.986 E F0 2.486 (declaration that unimports meanings imported by)4.986 F F1(use)4.986 E F0 4.986(,i)C 2.486(.e., it calls)-4.986 F F1 .038(unimport Module LIST) 128 126 R F0 .039(instead of)2.538 F F1(import)2.539 E F0 5.039(.I)C 2.539(tb)-5.039 G(eha)-2.539 E -.15(ve)-.2 G 2.539(sj).15 G .039(ust as) -2.539 F F1(import)2.539 E F0 .039(does with)2.539 F/F2 9/Times-Roman@0 SF(VERSION)2.539 E F0 2.539(,a)C(n)-2.539 E(omitted or empty)128 138 Q F2(LIST)2.5 E F0 2.5(,o)C 2.5(rn)-2.5 G 2.5(ou)-2.5 G (nimport method being found.)-2.5 E F1(no integer;)152 156 Q (no strict \010refs\010;)152 168 Q(no warnings;)152 180 Q F0 .355 (Care should be tak)128 198 R .355(en when using the)-.1 F F1 .355 (no VERSION)2.855 F F0 .355(form of)2.855 F F1(no)2.854 E F0 5.354(.I)C 2.854(ti)-5.354 G(s)-2.854 E/F3 10/Times-Italic@0 SF(only)2.854 E F0 .354(meant to be used to assert)2.854 F .287 (that the running Perl is of a earlier v)128 210 R .287 (ersion than its ar)-.15 F .287(gument and)-.18 F F3(not)2.787 E F0 .288 (to undo the feature-enabling side)2.787 F(ef)128 222 Q(fects of)-.25 E F1(use VERSION)2.5 E F0(.)A .295 (See perlmodlib for a list of standard modules and pragmas.)128 240 R .295(See perlrun for the)5.295 F F12.794 E F0(and)2.794 E F1 2.794 E F0(command-)2.794 E(line options to Perl that gi)128 252 Q -.15 (ve)-.25 G F1(use)2.65 E F0(functionality from the command-line.)2.5 E (utime)108 268.8 Q F2(LIST)2.5 E F0 .39(Changes the access and modi\214\ cation times on each \214le of a list of \214les.)128 280.8 R .391 (The \214rst tw)5.391 F 2.891(oe)-.1 G .391(lements of the)-2.891 F .953 (list must be the)128 292.8 R F2(NUMERIC)3.453 E F0 .953 (access and modi\214cation times, in that order)3.453 F 5.952(.R)-.55 G .952(eturns the number of \214les)-5.952 F .335(successfully changed.) 128 304.8 R .335 (The inode change time of each \214le is set to the current time.)5.335 F -.15(Fo)5.336 G 2.836(re).15 G .336(xample, this)-2.986 F .201 (code has the same ef)128 316.8 R .2(fect as the Unix)-.25 F F3(touc)2.7 E(h)-.15 E F0 .2(\(1\) command when the \214les)1.666 F F3(alr)2.7 E .2 (eady e)-.37 F(xist)-.2 E F0 .2(and belong to the)2.7 F (user running the program:)128 328.8 Q F1(#!/usr/bin/perl)152 346.8 Q ($atime = $mtime = time;)152 358.8 Q(utime $atime, $mtime, @ARGV;)152 370.8 Q F0 1.384(Since Perl 5.7.2, if the \214rst tw)128 388.8 R 3.884 (oe)-.1 G 1.384(lements of the list are)-3.884 F F1(undef)3.884 E F0 3.884(,t)C(he)-3.884 E F3(utime)3.884 E F0 1.384 (\(2\) syscall from your C)1.666 F 1.65 (library is called with a null second ar)128 400.8 R 1.649 (gument. On most systems, this will set the \214le')-.18 F 4.149(sa)-.55 G 1.649(ccess and)-4.149 F .93 (modi\214cation times to the current time \(i.e., equi)128 412.8 R -.25 (va)-.25 G .931(lent to the e).25 F .931(xample abo)-.15 F -.15(ve)-.15 G 3.431(\)a).15 G .931(nd will w)-3.431 F .931(ork e)-.1 F -.15(ve)-.25 G 3.431(no).15 G(n)-3.431 E(\214les you don')128 424.8 Q 2.5(to)-.18 G (wn pro)-2.75 E(vided you ha)-.15 E .3 -.15(ve w)-.2 H(rite permission:) .15 E F1(for $file \(@ARGV\) {)152 442.8 Q(utime\(undef, undef, $file\)) 176 454.8 Q(|| warn "couldn\010t touch $file: $!";)200 466.8 Q(})152 478.8 Q F0(Under)128 496.8 Q F2(NFS)2.57 E F0 .07 (this will use the time of the)2.57 F F2(NFS)2.57 E F0(serv)2.57 E(er) -.15 E 2.57(,n)-.4 G .07(ot the time of the local machine.)-2.57 F .07 (If there is a time)5.07 F 2.194(synchronization problem, the)128 508.8 R F2(NFS)4.695 E F0(serv)4.695 E 2.195(er and local machine will ha)-.15 F 2.495 -.15(ve d)-.2 H(if).15 E 2.195(ferent times.)-.25 F 2.195 (The Unix)7.195 F F3(touc)128 520.8 Q(h)-.15 E F0 (\(1\) command will in f)1.666 E (act normally use this form instead of the one sho)-.1 E (wn in the \214rst e)-.25 E(xample.)-.15 E -.15(Pa)128 538.8 S .295 (ssing only one of the \214rst tw).15 F 2.795(oe)-.1 G .295(lements as) -2.795 F F1(undef)2.795 E F0 .295(is equi)2.795 F -.25(va)-.25 G .295 (lent to passing a 0 and will not ha).25 F .595 -.15(ve t)-.2 H(he).15 E (ef)128 550.8 Q(fect described when both are)-.25 E F1(undef)2.5 E F0 5 (.T)C(his also triggers an uninitialized w)-5 E(arning.)-.1 E .479 (On systems that support)128 568.8 R F3(futimes)2.979 E F0 .48 (\(2\), you may pass \214lehandles among the \214les.)1.666 F .48 (On systems that don')5.48 F(t)-.18 E(support)128 580.8 Q F3(futimes) 3.695 E F0 1.194(\(2\), passing \214lehandles raises an e)1.666 F 3.694 (xception. Filehandles)-.15 F 1.194(must be passed as globs or)3.694 F (glob references to be recognized; bare)128 592.8 Q -.1(wo)-.25 G (rds are considered \214lenames.).1 E -.25(va)108 609.6 S(lues).25 E F2 (HASH)2.5 E F0 -.25(va)108 621.6 S(lues).25 E F2(ARRA)2.5 E(Y)-.945 E F0 -.25(va)108 633.6 S(lues).25 E F2(EXPR)2.5 E F0 1.646 (Returns a list consisting of all the v)128 645.6 R 1.646 (alues of the named hash, or the v)-.25 F 1.647(alues of an array)-.25 F 4.147(.\()-.65 G 1.647(In scalar)-4.147 F(conte)128 657.6 Q (xt, returns the number of v)-.15 E(alues.\))-.25 E .495(The v)128 675.6 R .495(alues are returned in an apparently random order)-.25 F 5.494(.T) -.55 G .494(he actual random order is subject to change)-5.494 F 1.752 (in future v)128 687.6 R 1.752(ersions of Perl, b)-.15 F 1.753 (ut it is guaranteed to be the same order as either the)-.2 F F1(keys) 4.253 E F0(or)4.253 E F1(each)4.253 E F0 .132(function w)128 699.6 R .132(ould produce on the same \(unmodi\214ed\) hash.)-.1 F .132 (Since Perl 5.8.1 the ordering is dif)5.132 F .132(ferent e)-.25 F -.15 (ve)-.25 G(n).15 E(between dif)128 711.6 Q (ferent runs of Perl for security reasons \(see `)-.25 E -.8(`A)-.74 G (lgorithmic Comple).8 E(xity Attacks')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlsec\).)-2.5 E 2.27(As a side ef)128 729.6 R 2.27(fect, calling)-.25 F F3(values\(\))4.77 E F0 2.27(resets the)4.77 F F2(HASH)4.77 E F0(or) 4.771 E F2(ARRA)4.771 E(Y)-.945 E F0 3.371 -.55('s i)D 2.271 (nternal iterator; see `).55 F(`each')-.74 E 2.271('. \(In)-.74 F (perl v5.14.2)72 768 Q 198.17(2011-10-01 97)162.62 F 0 Cg EP %%Page: 98 98 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(particular)128 84 Q 4.589(,c)-.4 G(alling)-4.589 E/F1 10/Times-Italic@0 SF(values\(\)) 4.589 E F0 2.089(in v)4.589 F 2.089(oid conte)-.2 F 2.088 (xt resets the iterator with no other o)-.15 F -.15(ve)-.15 G 2.088 (rhead. Apart from).15 F .2(resetting the iterator)128 96 R(,)-.4 E/F2 10/Courier@0 SF .2(values @array)2.7 F F0 .2(in list conte)2.7 F .2 (xt is the same as plain)-.15 F F2(@array)2.7 E F0 5.2(.W)C 2.7(er)-6 G (ecommend)-2.7 E .484(that you use v)128 108 R .483(oid conte)-.2 F(xt) -.15 E F2 .483(keys @array)2.983 F F0 .483(for this, b)2.983 F .483 (ut reasoned that it taking)-.2 F F2 .483(values @array)2.983 F F0(out) 2.983 E -.1(wo)128 120 S(uld require more documentation than lea).1 E (ving it in.\))-.2 E(Note that the v)128 138 Q(alues are not copied, wh\ ich means modifying them will modify the contents of the hash:)-.25 E F2 (for \(values %hash\))152 156 Q 6({s)36 G(/foo/bar/g })-6 E 6(#m)18 G (odifies %hash values)-6 E(for \(@hash{keys %hash}\) { s/foo/bar/g })152 168 Q 6(#s)18 G(ame)-6 E F0 .251(Starting with Perl 5.14,)128 186 R F2 (values)2.751 E F0 .251(can tak)2.751 F 2.751(eas)-.1 G(calar)-2.751 E /F3 9/Times-Roman@0 SF(EXPR)2.752 E F0 2.752(,w)C .252 (hich must hold a reference to an unblessed)-2.752 F 3.51(hash or array) 128 198 R 8.51(.T)-.65 G 3.509(he ar)-8.51 F 3.509 (gument will be dereferenced automatically)-.18 F 8.509(.T)-.65 G 3.509 (his aspect of)-8.509 F F2(values)6.009 E F0(is)6.009 E (considered highly e)128 210 Q 2.5(xperimental. The)-.15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E F2(for \(values $hashref\) { ... })152 228 Q (for \(values $obj\255>get_arrayref\) { ... })152 240 Q F0(See also)128 258 Q F2(keys)2.5 E F0(,)A F2(each)2.5 E F0 2.5(,a)C(nd)-2.5 E F2(sort) 2.5 E F0(.)A -.15(ve)108 274.8 S(c).15 E F3(EXPR)2.5 E F0(,OFFSET)A (,BITS)-.74 E -.35(Tr)128 286.8 S .654(eats the string in).35 F F3(EXPR) 3.154 E F0 .654(as a bit v)3.154 F .654 (ector made up of elements of width)-.15 F F3(BITS)3.154 E F0 .655 (and returns the v)3.154 F .655(alue of)-.25 F .736 (the element speci\214ed by)128 298.8 R F3(OFFSET)3.236 E F0 .735 (as an unsigned inte)3.235 F(ger)-.15 E(.)-.55 E F3(BITS)5.735 E F0 .735 (therefore speci\214es the number of bits)3.235 F .022(that are reserv) 128 310.8 R .022(ed for each element in the bit v)-.15 F(ector)-.15 E 5.022(.T)-.55 G .022(his must be a po)-5.022 F .022(wer of tw)-.25 F 2.522(of)-.1 G .023(rom 1 to 32 \(or 64, if)-2.522 F (your platform supports that\).)128 322.8 Q(If)128 340.8 Q F3(BITS)2.5 E F0(is 8, `)2.5 E(`elements')-.74 E 2.5('c)-.74 G (oincide with bytes of the input string.)-2.5 E(If)128 358.8 Q F3(BITS) 2.748 E F0 .247(is 16 or more, bytes of the input string are grouped in\ to chunks of size)2.748 F F3(BITS/8)2.747 E F0 2.747(,a)C .247 (nd each group)-2.747 F 1.105(is con)128 370.8 R -.15(ve)-.4 G 1.105 (rted to a number as with).15 F F1(pac)3.605 E(k\(\))-.2 E F0(/)A F1 (unpac)A(k\(\))-.2 E F0 1.105(with big-endian formats)3.605 F F2(n)3.605 E F0(/)A F2(N)A F0 1.105(\(and analogously for)3.605 F 2.5 (BITS==64\). See)128 382.8 R -.74(``)2.5 G(pack').74 E 2.5('f)-.74 G (or details.)-2.5 E .94(If bits is 4 or less, the string is brok)128 400.8 R .939(en into bytes, then the bits of each byte are brok)-.1 F .939(en into 8/BITS)-.1 F 4.087(groups. Bits)128 412.8 R 1.587 (of a byte are numbered in a little-endian-ish w)4.087 F(ay)-.1 E 4.088 (,a)-.65 G 4.088(si)-4.088 G(n)-4.088 E F2(0x01)4.088 E F0(,)A F2(0x02) 4.088 E F0(,)A F2(0x04)4.088 E F0(,)A F2(0x08)4.088 E F0(,)A F2(0x10)128 424.8 Q F0(,)A F2(0x20)4.63 E F0(,)A F2(0x40)4.63 E F0(,)A F2(0x80)4.63 E F0 7.13(.F)C 2.13(or e)-7.28 F 2.13 (xample, breaking the single input byte)-.15 F F2(chr\(0x36\))4.63 E F0 2.13(into tw)4.63 F(o)-.1 E(groups gi)128 436.8 Q -.15(ve)-.25 G 2.5 (sal).15 G(ist)-2.5 E F2(\(0x6, 0x3\))2.5 E F0 2.5(;b)C (reaking it into 4 groups gi)-2.5 E -.15(ve)-.25 G(s).15 E F2 (\(0x2, 0x1, 0x3, 0x0\))2.5 E F0(.)A F2(vec)128 454.8 Q F0 .469 (may also be assigned to, in which case parentheses are needed to gi) 2.969 F .77 -.15(ve t)-.25 H .47(he e).15 F .47(xpression the correct) -.15 F(precedence as in)128 466.8 Q F2 (vec\($image, $max_x * $x + $y, 8\) = 3;)152 484.8 Q F0 .81 (If the selected element is outside the string, the v)128 502.8 R .809 (alue 0 is returned.)-.25 F .809(If an element of)5.809 F 3.309(ft)-.25 G .809(he end of the)-3.309 F .413 (string is written to, Perl will \214rst e)128 514.8 R .413 (xtend the string with suf)-.15 F .413(\214ciently man)-.25 F 2.913(yz) -.15 G .413(ero bytes.)-2.913 F .414(It is an error to)7.913 F (try to write of)128 526.8 Q 2.5(ft)-.25 G(he be)-2.5 E (ginning of the string \(i.e., ne)-.15 E -.05(ga)-.15 G(ti).05 E -.15 (ve)-.25 G F3(OFFSET)2.65 E F0(\).)A .063 (If the string happens to be encoded as)128 544.8 R F3(UTF\2558)2.563 E F0 .063(internally \(and thus has the)2.563 F F3(UTF8)2.563 E F0 .062 (\215ag set\), this is ignored)2.562 F(by)128 556.8 Q F2(vec)2.516 E F0 2.516(,a)C .017(nd it operates on the internal byte string, not the con\ ceptual character string, e)-2.516 F -.15(ve)-.25 G 2.517(ni).15 G 2.517 (fy)-2.517 G .017(ou only)-2.517 F(ha)128 568.8 Q .3 -.15(ve c)-.2 H (haracters with v).15 E(alues less than 256.)-.25 E 1.082 (Strings created with)128 586.8 R F2(vec)3.582 E F0 1.082 (can also be manipulated with the logical operators)3.582 F F2(|)3.582 E F0(,)A F2(&)3.582 E F0(,)A F2(^)3.581 E F0 3.581(,a)C(nd)-3.581 E F2(~) 3.581 E F0 6.081(.T)C(hese)-6.081 E .586(operators will assume a bit v) 128 598.8 R .586 (ector operation is desired when both operands are strings.)-.15 F .586 (See `)5.586 F(`Bitwise)-.74 E(String Operators')128 610.8 Q 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E .936(The follo)128 628.8 R .936 (wing code will b)-.25 F .936(uild up an)-.2 F F3(ASCII)3.435 E F0 .935 (string saying)3.435 F F2(\010PerlPerlPerl\010)3.435 E F0 5.935(.T)C .935(he comments sho)-5.935 F(w)-.25 E 1.064 (the string after each step.)128 640.8 R 1.065(Note that this code w) 6.064 F 1.065(orks in the same w)-.1 F 1.065 (ay on big-endian or little-endian)-.1 F(machines.)128 652.8 Q F2 (my $foo = \010\010;)152 670.8 Q 6(vec\($foo, 0,)152 682.8 R (32\) = 0x5065726C; # \010Perl\010)6 E 6(#$)152 706.8 S (foo eq "Perl" eq "\\x50\\x65\\x72\\x6C", 32 bits)-6 E (print vec\($foo, 0, 8\);)152 718.8 Q 6(#p)12 G (rints 80 == 0x50 == ord\(\010P\010\))-6 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 98)162.62 F 0 Cg EP %%Page: 99 99 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(vec\($foo, 2,)152 84 R(16\) = 0x5065; # \010PerlPe\010)6 E 6 (vec\($foo, 3,)152 96 R(16\) = 0x726C; # \010PerlPerl\010)6 E 6 (vec\($foo, 8, 8\))152 108 R 6(=0)6 G 12(x50; #)-6 F(\010PerlPerlP\010)6 E 6(vec\($foo, 9, 8\))152 120 R 6(=0)6 G 12(x65; #)-6 F (\010PerlPerlPe\010)6 E(vec\($foo, 20,)152 132 Q(4\) = 2;)12 E 6<2308>36 G 12(PerlPerlPe\010 .)-6 F("\\x02")6 E(vec\($foo, 21,)152 144 Q (4\) = 7;)12 E 6<2308>36 G(PerlPerlPer\010)-6 E 6<2308>338 156 S (r\010 is "\\x72")-6 E(vec\($foo, 45,)152 168 Q(2\) = 3;)12 E 6<2308>36 G 6(PerlPerlPer\010 .)-6 F("\\x0c")6 E(vec\($foo, 93,)152 180 Q (1\) = 1;)12 E 6<2308>36 G 6(PerlPerlPer\010 .)-6 F("\\x2c")6 E (vec\($foo, 94,)152 192 Q(1\) = 1;)12 E 6<2308>36 G(PerlPerlPerl\010)-6 E 6<2308>338 204 S(l\010 is "\\x6c")-6 E F0 1.6 -.8(To t)128 222 T (ransform a bit v).8 E(ector into a string or list of 0')-.15 E 2.5(sa) -.55 G(nd 1')-2.5 E(s, use these:)-.55 E F1 ($bits = unpack\("b*", $vector\);)152 240 Q (@bits = split\(//, unpack\("b*", $vector\)\);)152 252 Q F0(If you kno) 128 270 Q 2.5(wt)-.25 G(he e)-2.5 E (xact length in bits, it can be used in place of the)-.15 E F1(*)2.5 E F0(.)A(Here is an e)128 288 Q(xample to illustrate ho)-.15 E 2.5(wt)-.25 G(he bits actually f)-2.5 E(all in place:)-.1 E F1 (#!/usr/bin/perl \255wl)152 306 Q(print <<\010EOT\010;)152 330 Q 54 (0123)356 342 S(unpack\("V",$_\) 01234567890123456789012345678901)266 354 Q152 366 Q(EOT)152 378 Q(for $w \(0..3\) {)152 402 Q($width = 2**$w;)176 414 Q(for \($shift=0; $shift < $width; ++$shift\) {)176 426 Q (for \($off=0; $off < 32/$width; ++$off\) {)200 438 Q ($str = pack\("B*", "0"x32\);)224 450 Q($bits = \(1<<$shift\);)224 462 Q (vec\($str, $off, $width\) = $bits;)224 474 Q ($res = unpack\("b*",$str\);)224 486 Q($val = unpack\("V", $str\);)224 498 Q(write;)224 510 Q(})200 522 Q(})176 534 Q(})152 546 Q (format STDOUT =)152 570 Q (vec\($_,@#,@#\) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>) 152 582 Q($off, $width, $bits, $val, $res)152 594 Q(.)152 606 Q 1.666 (__)152 618 S -4.334(END_ _)-1.666 F F0(Re)128 636 Q -.05(ga)-.15 G .235 (rdless of the machine architecture on which it runs, the e).05 F .234 (xample abo)-.15 F .534 -.15(ve s)-.15 H .234(hould print the follo).15 F(wing)-.25 E(table:)128 648 Q(perl v5.14.2)72 768 Q 198.17 (2011-10-01 99)162.62 F 0 Cg EP %%Page: 100 100 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 54(0123)356 84 S(unpack\("V",$_\) 01234567890123456789012345678901)266 96 Q152 108 Q(vec\($_, 0, 1\) = 1)152 120 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 1\) = 1)152 132 Q 54 (== 2)18 F(01000000000000000000000000000000)6 E(vec\($_, 2, 1\) = 1)152 144 Q 54(== 4)18 F(00100000000000000000000000000000)6 E (vec\($_, 3, 1\) = 1)152 156 Q 54(== 8)18 F (00010000000000000000000000000000)6 E(vec\($_, 4, 1\) = 1)152 168 Q 48 (== 16)18 F(00001000000000000000000000000000)6 E(vec\($_, 5, 1\) = 1)152 180 Q 48(== 32)18 F(00000100000000000000000000000000)6 E (vec\($_, 6, 1\) = 1)152 192 Q 48(== 64)18 F (00000010000000000000000000000000)6 E(vec\($_, 7, 1\) = 1)152 204 Q 42 (== 128)18 F(00000001000000000000000000000000)6 E(vec\($_, 8, 1\) = 1) 152 216 Q 42(== 256)18 F(00000000100000000000000000000000)6 E (vec\($_, 9, 1\) = 1)152 228 Q 42(== 512)18 F (00000000010000000000000000000000)6 E(vec\($_,10, 1\) = 1)152 240 Q 36 (== 1024)18 F(00000000001000000000000000000000)6 E(vec\($_,11, 1\) = 1) 152 252 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_,12, 1\) = 1)152 264 Q 36(== 4096)18 F (00000000000010000000000000000000)6 E(vec\($_,13, 1\) = 1)152 276 Q 36 (== 8192)18 F(00000000000001000000000000000000)6 E(vec\($_,14, 1\) = 1) 152 288 Q 30(== 16384)18 F(00000000000000100000000000000000)6 E (vec\($_,15, 1\) = 1)152 300 Q 30(== 32768)18 F (00000000000000010000000000000000)6 E(vec\($_,16, 1\) = 1)152 312 Q 30 (== 65536)18 F(00000000000000001000000000000000)6 E(vec\($_,17, 1\) = 1) 152 324 Q 24(== 131072)18 F(00000000000000000100000000000000)6 E (vec\($_,18, 1\) = 1)152 336 Q 24(== 262144)18 F (00000000000000000010000000000000)6 E(vec\($_,19, 1\) = 1)152 348 Q 24 (== 524288)18 F(00000000000000000001000000000000)6 E (vec\($_,20, 1\) = 1)152 360 Q 18(== 1048576)18 F (00000000000000000000100000000000)6 E(vec\($_,21, 1\) = 1)152 372 Q 18 (== 2097152)18 F(00000000000000000000010000000000)6 E (vec\($_,22, 1\) = 1)152 384 Q 18(== 4194304)18 F (00000000000000000000001000000000)6 E(vec\($_,23, 1\) = 1)152 396 Q 18 (== 8388608)18 F(00000000000000000000000100000000)6 E (vec\($_,24, 1\) = 1)152 408 Q 12(== 16777216)18 F (00000000000000000000000010000000)6 E(vec\($_,25, 1\) = 1)152 420 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_,26, 1\) = 1)152 432 Q 12(== 67108864)18 F (00000000000000000000000000100000)6 E(vec\($_,27, 1\) = 1)152 444 Q 6 (== 134217728)18 F(00000000000000000000000000010000)6 E (vec\($_,28, 1\) = 1)152 456 Q 6(== 268435456)18 F (00000000000000000000000000001000)6 E(vec\($_,29, 1\) = 1)152 468 Q 6 (== 536870912)18 F(00000000000000000000000000000100)6 E (vec\($_,30, 1\) = 1)152 480 Q (== 1073741824 00000000000000000000000000000010)18 E (vec\($_,31, 1\) = 1)152 492 Q (== 2147483648 00000000000000000000000000000001)18 E (vec\($_, 0, 2\) = 1)152 504 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 2\) = 1)152 516 Q 54 (== 4)18 F(00100000000000000000000000000000)6 E(vec\($_, 2, 2\) = 1)152 528 Q 48(== 16)18 F(00001000000000000000000000000000)6 E (vec\($_, 3, 2\) = 1)152 540 Q 48(== 64)18 F (00000010000000000000000000000000)6 E(vec\($_, 4, 2\) = 1)152 552 Q 42 (== 256)18 F(00000000100000000000000000000000)6 E(vec\($_, 5, 2\) = 1) 152 564 Q 36(== 1024)18 F(00000000001000000000000000000000)6 E (vec\($_, 6, 2\) = 1)152 576 Q 36(== 4096)18 F (00000000000010000000000000000000)6 E(vec\($_, 7, 2\) = 1)152 588 Q 30 (== 16384)18 F(00000000000000100000000000000000)6 E(vec\($_, 8, 2\) = 1) 152 600 Q 30(== 65536)18 F(00000000000000001000000000000000)6 E (vec\($_, 9, 2\) = 1)152 612 Q 24(== 262144)18 F (00000000000000000010000000000000)6 E(vec\($_,10, 2\) = 1)152 624 Q 18 (== 1048576)18 F(00000000000000000000100000000000)6 E (vec\($_,11, 2\) = 1)152 636 Q 18(== 4194304)18 F (00000000000000000000001000000000)6 E(vec\($_,12, 2\) = 1)152 648 Q 12 (== 16777216)18 F(00000000000000000000000010000000)6 E (vec\($_,13, 2\) = 1)152 660 Q 12(== 67108864)18 F (00000000000000000000000000100000)6 E(vec\($_,14, 2\) = 1)152 672 Q 6 (== 268435456)18 F(00000000000000000000000000001000)6 E (vec\($_,15, 2\) = 1)152 684 Q (== 1073741824 00000000000000000000000000000010)18 E (vec\($_, 0, 2\) = 2)152 696 Q 54(== 2)18 F (01000000000000000000000000000000)6 E(vec\($_, 1, 2\) = 2)152 708 Q 54 (== 8)18 F(00010000000000000000000000000000)6 E(vec\($_, 2, 2\) = 2)152 720 Q 48(== 32)18 F(00000100000000000000000000000000)6 E F0 (perl v5.14.2)72 768 Q 193.17(2011-10-01 100)162.62 F 0 Cg EP %%Page: 101 101 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (vec\($_, 3, 2\) = 2)152 84 Q 42(== 128)18 F (00000001000000000000000000000000)6 E(vec\($_, 4, 2\) = 2)152 96 Q 42 (== 512)18 F(00000000010000000000000000000000)6 E(vec\($_, 5, 2\) = 2) 152 108 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_, 6, 2\) = 2)152 120 Q 36(== 8192)18 F (00000000000001000000000000000000)6 E(vec\($_, 7, 2\) = 2)152 132 Q 30 (== 32768)18 F(00000000000000010000000000000000)6 E(vec\($_, 8, 2\) = 2) 152 144 Q 24(== 131072)18 F(00000000000000000100000000000000)6 E (vec\($_, 9, 2\) = 2)152 156 Q 24(== 524288)18 F (00000000000000000001000000000000)6 E(vec\($_,10, 2\) = 2)152 168 Q 18 (== 2097152)18 F(00000000000000000000010000000000)6 E (vec\($_,11, 2\) = 2)152 180 Q 18(== 8388608)18 F (00000000000000000000000100000000)6 E(vec\($_,12, 2\) = 2)152 192 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_,13, 2\) = 2)152 204 Q 6(== 134217728)18 F (00000000000000000000000000010000)6 E(vec\($_,14, 2\) = 2)152 216 Q 6 (== 536870912)18 F(00000000000000000000000000000100)6 E (vec\($_,15, 2\) = 2)152 228 Q (== 2147483648 00000000000000000000000000000001)18 E (vec\($_, 0, 4\) = 1)152 240 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 4\) = 1)152 252 Q 48 (== 16)18 F(00001000000000000000000000000000)6 E(vec\($_, 2, 4\) = 1)152 264 Q 42(== 256)18 F(00000000100000000000000000000000)6 E (vec\($_, 3, 4\) = 1)152 276 Q 36(== 4096)18 F (00000000000010000000000000000000)6 E(vec\($_, 4, 4\) = 1)152 288 Q 30 (== 65536)18 F(00000000000000001000000000000000)6 E(vec\($_, 5, 4\) = 1) 152 300 Q 18(== 1048576)18 F(00000000000000000000100000000000)6 E (vec\($_, 6, 4\) = 1)152 312 Q 12(== 16777216)18 F (00000000000000000000000010000000)6 E(vec\($_, 7, 4\) = 1)152 324 Q 6 (== 268435456)18 F(00000000000000000000000000001000)6 E (vec\($_, 0, 4\) = 2)152 336 Q 54(== 2)18 F (01000000000000000000000000000000)6 E(vec\($_, 1, 4\) = 2)152 348 Q 48 (== 32)18 F(00000100000000000000000000000000)6 E(vec\($_, 2, 4\) = 2)152 360 Q 42(== 512)18 F(00000000010000000000000000000000)6 E (vec\($_, 3, 4\) = 2)152 372 Q 36(== 8192)18 F (00000000000001000000000000000000)6 E(vec\($_, 4, 4\) = 2)152 384 Q 24 (== 131072)18 F(00000000000000000100000000000000)6 E (vec\($_, 5, 4\) = 2)152 396 Q 18(== 2097152)18 F (00000000000000000000010000000000)6 E(vec\($_, 6, 4\) = 2)152 408 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_, 7, 4\) = 2)152 420 Q 6(== 536870912)18 F (00000000000000000000000000000100)6 E(vec\($_, 0, 4\) = 4)152 432 Q 54 (== 4)18 F(00100000000000000000000000000000)6 E(vec\($_, 1, 4\) = 4)152 444 Q 48(== 64)18 F(00000010000000000000000000000000)6 E (vec\($_, 2, 4\) = 4)152 456 Q 36(== 1024)18 F (00000000001000000000000000000000)6 E(vec\($_, 3, 4\) = 4)152 468 Q 30 (== 16384)18 F(00000000000000100000000000000000)6 E(vec\($_, 4, 4\) = 4) 152 480 Q 24(== 262144)18 F(00000000000000000010000000000000)6 E (vec\($_, 5, 4\) = 4)152 492 Q 18(== 4194304)18 F (00000000000000000000001000000000)6 E(vec\($_, 6, 4\) = 4)152 504 Q 12 (== 67108864)18 F(00000000000000000000000000100000)6 E (vec\($_, 7, 4\) = 4)152 516 Q (== 1073741824 00000000000000000000000000000010)18 E (vec\($_, 0, 4\) = 8)152 528 Q 54(== 8)18 F (00010000000000000000000000000000)6 E(vec\($_, 1, 4\) = 8)152 540 Q 42 (== 128)18 F(00000001000000000000000000000000)6 E(vec\($_, 2, 4\) = 8) 152 552 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_, 3, 4\) = 8)152 564 Q 30(== 32768)18 F (00000000000000010000000000000000)6 E(vec\($_, 4, 4\) = 8)152 576 Q 24 (== 524288)18 F(00000000000000000001000000000000)6 E (vec\($_, 5, 4\) = 8)152 588 Q 18(== 8388608)18 F (00000000000000000000000100000000)6 E(vec\($_, 6, 4\) = 8)152 600 Q 6 (== 134217728)18 F(00000000000000000000000000010000)6 E (vec\($_, 7, 4\) = 8)152 612 Q (== 2147483648 00000000000000000000000000000001)18 E (vec\($_, 0, 8\) = 1)152 624 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 8\) = 1)152 636 Q 42 (== 256)18 F(00000000100000000000000000000000)6 E(vec\($_, 2, 8\) = 1) 152 648 Q 30(== 65536)18 F(00000000000000001000000000000000)6 E (vec\($_, 3, 8\) = 1)152 660 Q 12(== 16777216)18 F (00000000000000000000000010000000)6 E(vec\($_, 0, 8\) = 2)152 672 Q 54 (== 2)18 F(01000000000000000000000000000000)6 E(vec\($_, 1, 8\) = 2)152 684 Q 42(== 512)18 F(00000000010000000000000000000000)6 E (vec\($_, 2, 8\) = 2)152 696 Q 24(== 131072)18 F (00000000000000000100000000000000)6 E(vec\($_, 3, 8\) = 2)152 708 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_, 0, 8\) = 4)152 720 Q 54(== 4)18 F (00100000000000000000000000000000)6 E F0(perl v5.14.2)72 768 Q 193.17 (2011-10-01 101)162.62 F 0 Cg EP %%Page: 102 102 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (vec\($_, 1, 8\) = 4)152 84 Q 36(== 1024)18 F (00000000001000000000000000000000)6 E(vec\($_, 2, 8\) = 4)152 96 Q 24 (== 262144)18 F(00000000000000000010000000000000)6 E (vec\($_, 3, 8\) = 4)152 108 Q 12(== 67108864)18 F (00000000000000000000000000100000)6 E(vec\($_, 0, 8\) = 8)152 120 Q 54 (== 8)18 F(00010000000000000000000000000000)6 E(vec\($_, 1, 8\) = 8)152 132 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_, 2, 8\) = 8)152 144 Q 24(== 524288)18 F (00000000000000000001000000000000)6 E(vec\($_, 3, 8\) = 8)152 156 Q 6 (== 134217728)18 F(00000000000000000000000000010000)6 E (vec\($_, 0, 8\) = 16)152 168 Q 48(== 16)12 F (00001000000000000000000000000000)6 E(vec\($_, 1, 8\) = 16)152 180 Q 36 (== 4096)12 F(00000000000010000000000000000000)6 E(vec\($_, 2, 8\) = 16) 152 192 Q 18(== 1048576)12 F(00000000000000000000100000000000)6 E (vec\($_, 3, 8\) = 16)152 204 Q 6(== 268435456)12 F (00000000000000000000000000001000)6 E(vec\($_, 0, 8\) = 32)152 216 Q 48 (== 32)12 F(00000100000000000000000000000000)6 E(vec\($_, 1, 8\) = 32) 152 228 Q 36(== 8192)12 F(00000000000001000000000000000000)6 E (vec\($_, 2, 8\) = 32)152 240 Q 18(== 2097152)12 F (00000000000000000000010000000000)6 E(vec\($_, 3, 8\) = 32)152 252 Q 6 (== 536870912)12 F(00000000000000000000000000000100)6 E (vec\($_, 0, 8\) = 64)152 264 Q 48(== 64)12 F (00000010000000000000000000000000)6 E(vec\($_, 1, 8\) = 64)152 276 Q 30 (== 16384)12 F(00000000000000100000000000000000)6 E (vec\($_, 2, 8\) = 64)152 288 Q 18(== 4194304)12 F (00000000000000000000001000000000)6 E(vec\($_, 3, 8\) = 64)152 300 Q (== 1073741824 00000000000000000000000000000010)12 E (vec\($_, 0, 8\) = 128 ==)152 312 Q (128 00000001000000000000000000000000)48 E(vec\($_, 1, 8\) = 128 ==)152 324 Q(32768 00000000000000010000000000000000)36 E (vec\($_, 2, 8\) = 128 ==)152 336 Q (8388608 00000000000000000000000100000000)24 E (vec\($_, 3, 8\) = 128 == 2147483648 00000000000000000000000000000001) 152 348 Q F0 -.1(wa)108 364.8 S(it).1 E(Beha)128 376.8 Q -.15(ve)-.2 G 2.534(sl).15 G(ik)-2.534 E(e)-.1 E/F2 10/Times-Italic@0 SF(wait)2.534 E F0 .034(\(2\) on your system: it w)1.666 F .035 (aits for a child process to terminate and returns the pid of the)-.1 F 3.527(deceased process, or)128 388.8 R F16.027 E F0 3.526 (if there are no child processes.)6.027 F 3.526 (The status is returned in)8.526 F F1($?)6.026 E F0(and)8.526 E F1 (${^CHILD_ERROR_NATIVE})128 400.8 Q F0 5.66(.N)C .66 (ote that a return v)-5.66 F .661(alue of)-.25 F F13.161 E F0 .661 (could mean that child processes are)3.161 F (being automatically reaped, as described in perlipc.)128 412.8 Q .598 (If you use w)128 430.8 R .598(ait in your handler for)-.1 F F1($SIG) 3.097 E F0({)A/F3 9/Times-Roman@0 SF(CHLD)A F0 3.097(}i)C 3.097(tm) -3.097 G .597(ay accidentally for the child created by)-3.097 F F2 (qx\(\))3.097 E F0(or)3.097 E F2(system\(\))128 442.8 Q F0 2.5(.S)C (ee perlipc for details.)-2.5 E -.1(wa)108 459.6 S(itpid).1 E F3(PID)2.5 E F0(,FLA)A(GS)-.4 E -.8(Wa)128 471.6 S .652(its for a particular child\ process to terminate and returns the pid of the deceased process, or).8 F F13.152 E F0(if)3.152 E .793(there is no such child process.)128 483.6 R .792(On some systems, a v)5.792 F .792 (alue of 0 indicates that there are processes still)-.25 F 2.5 (running. The)128 495.6 R(status is returned in)2.5 E F1($?)2.5 E F0 (and)2.5 E F1(${^CHILD_ERROR_NATIVE})2.5 E F0 5(.I)C 2.5(fy)-5 G(ou say) -2.5 E F1(use POSIX ":sys_wait_h";)152 513.6 Q(#...)152 525.6 Q(do {)152 537.6 Q($kid = waitpid\(\2551, WNOHANG\);)176 549.6 Q 6(}w)152 561.6 S (hile $kid > 0;)-6 E F0 .125(then you can do a non-blocking w)128 579.6 R .125(ait for all pending zombie processes.)-.1 F .126(Non-blocking w) 5.126 F .126(ait is a)-.1 F -.25(va)-.2 G(ilable).25 E .632 (on machines supporting either the)128 591.6 R F2(waitpid)3.132 E F0 .631(\(2\) or)1.666 F F2(wait4)3.131 E F0 .631(\(2\) syscalls.)1.666 F (Ho)5.631 E(we)-.25 E -.15(ve)-.25 G 1.431 -.4(r, w).15 H .631 (aiting for a particular).3 F .424(pid with)128 603.6 R F3(FLA)2.924 E (GS)-.36 E F0(of)2.924 E F1(0)2.924 E F0 .424(is implemented e)2.924 F -.15(ve)-.25 G 2.924(rywhere. \(Perl).15 F .425 (emulates the system call by remembering the)2.925 F(status v)128 615.6 Q(alues of processes that ha)-.25 E .3 -.15(ve ex)-.2 H(ited b).15 E (ut ha)-.2 E .3 -.15(ve n)-.2 H(ot been harv).15 E (ested by the Perl script yet.\))-.15 E 3.162 (Note that on some systems, a return v)128 633.6 R 3.162(alue of)-.25 F F15.662 E F0 3.162(could mean that child processes are being)5.662 F(automatically reaped.)128 645.6 Q (See perlipc for details, and for other e)5 E(xamples.)-.15 E -.1(wa)108 662.4 S(ntarray).1 E .939(Returns true if the conte)128 674.4 R .939 (xt of the currently e)-.15 F -.15(xe)-.15 G .939(cuting subroutine or) .15 F F1(eval)3.44 E F0 .94(is looking for a list v)3.44 F(alue.)-.25 E 1.908(Returns f)128 686.4 R 1.907(alse if the conte)-.1 F 1.907 (xt is looking for a scalar)-.15 F 6.907(.R)-.55 G 1.907 (eturns the unde\214ned v)-6.907 F 1.907(alue if the conte)-.25 F 1.907 (xt is)-.15 F(looking for no v)128 698.4 Q(alue \(v)-.25 E(oid conte)-.2 E(xt\).)-.15 E(perl v5.14.2)72 768 Q 193.17(2011-10-01 102)162.62 F 0 Cg EP %%Page: 103 103 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (return unless defined wantarray; # don\010t bother doing more)152 84 Q (my @a = complex_calculation\(\);)152 96 Q (return wantarray ? @a : "@a";)152 108 Q(wantarray\(\))128 126 Q F0 2.02 -.55('s r)D .92(esult is unspeci\214ed in the top le).55 F -.15(ve)-.25 G 3.42(lo).15 G 3.42(fa\214)-3.42 G .92(le, in a)-3.42 F F1(BEGIN)3.42 E F0(,)A F1(UNITCHECK)3.42 E F0(,)A F1(CHECK)3.42 E F0(,)A F1(INIT)128 138 Q F0(or)2.5 E F1(END)2.5 E F0(block, or in a)2.5 E F1(DESTROY)2.5 E F0 (method.)2.5 E(This function should ha)128 156 Q .3 -.15(ve b)-.2 H (een named).15 E/F2 10/Times-Italic@0 SF(wantlist\(\))2.5 E F0(instead.) 2.5 E -.1(wa)108 172.8 S(rn).1 E/F3 9/Times-Roman@0 SF(LIST)2.5 E F0 .433(Prints the v)128 184.8 R .433(alue of)-.25 F F3(LIST)2.933 E F0(to) 2.933 E F3(STDERR)2.933 E F0 5.432(.I)C 2.932(ft)-5.432 G .432 (he last element of)-2.932 F F3(LIST)2.932 E F0 .432 (does not end in a ne)2.932 F .432(wline, it appends)-.25 F (the same \214le/line number te)128 196.8 Q(xt as)-.15 E F1(die)2.5 E F0 (does.)2.5 E .937(If the output is empty and)128 214.8 R F1($@)3.437 E F0 .937(already contains a v)3.437 F .937(alue \(typically from a pre) -.25 F .938(vious e)-.25 F -.25(va)-.25 G .938(l\) that v).25 F .938 (alue is)-.25 F 1.528(used after appending)128 226.8 R F1 ("\\t...caught")4.028 E F0(to)4.028 E F1($@)4.028 E F0 6.528(.T)C 1.528 (his is useful for staying almost, b)-6.528 F 1.527(ut not entirely)-.2 F(similar to)128 238.8 Q F1(die)2.5 E F0(.)A(If)128 256.8 Q F1($@)2.5 E F0(is empty then the string)2.5 E F1("Warning: Something\010s wrong")2.5 E F0(is used.)2.5 E 2.915(No message is printed if there is a)128 274.8 R F1 -4.334($SIG{_ _WARN_ _})5.416 F F0 2.916(handler installed.)5.416 F 2.916(It is the handler')7.916 F(s)-.55 E .167 (responsibility to deal with the message as it sees \214t \(lik)128 286.8 R .167(e, for instance, con)-.1 F -.15(ve)-.4 G .167 (rting it into a).15 F F1(die)2.667 E F0 2.667(\). Most)B 1.434 (handlers must therefore arrange to actually display the w)128 298.8 R 1.434(arnings that the)-.1 F 3.934(ya)-.15 G 1.434 (re not prepared to deal)-3.934 F .075(with, by calling)128 310.8 R F1 (warn)2.575 E F0(ag)2.575 E .075(ain in the handler)-.05 F 5.075(.N)-.55 G .075(ote that this is quite safe and will not produce an endless) -5.075 F(loop, since)128 322.8 Q F1 1.666(__)2.5 G -4.334(WARN_ _)-1.666 F F0(hooks are not called from inside one.)2.5 E -1.1(Yo)128 340.8 S 2.712(uw)1.1 G .212(ill \214nd this beha)-2.712 F .213 (vior is slightly dif)-.2 F .213(ferent from that of)-.25 F F1 -4.334 ($SIG{_ _DIE_ _})2.713 F F0 .213(handlers \(which don')2.713 F(t)-.18 E (suppress the error te)128 352.8 Q(xt, b)-.15 E(ut can instead call)-.2 E F1(die)2.5 E F0(ag)2.5 E(ain to change it\).)-.05 E 1.712(Using a)128 370.8 R F1 1.666(__)4.212 G -4.334(WARN_ _)-1.666 F F0 1.712 (handler pro)4.212 F 1.712(vides a po)-.15 F 1.712(werful w)-.25 F 1.712 (ay to silence all w)-.1 F 1.712(arnings \(e)-.1 F -.15(ve)-.25 G 4.212 (nt).15 G 1.712(he so-called)-4.212 F(mandatory ones\).)128 382.8 Q (An e)5 E(xample:)-.15 E F1 6(#w)152 400.8 S (ipe out *all* compile\255time warnings)-6 E(BEGIN { $SIG{\010_)152 412.8 Q -4.334(_WARN_ _\010})1.666 F 6(=s)6 G (ub { warn $_[0] if $DOWARN } })-6 E(my $foo = 10;)152 424.8 Q (my $foo = 20;)152 436.8 Q 6(#n)60 G 6(ow)-6 G (arning about duplicate my $foo,)-6 E 6(#b)290 448.8 S (ut hey, you asked for it!)-6 E 6(#n)152 460.8 S 6(oc)-6 G (ompile\255time or run\255time warnings before here)-6 E($DOWARN = 1;) 152 472.8 Q 6(#r)152 496.8 S(un\255time warnings enabled after here)-6 E (warn "\\$foo is alive and $foo!";)152 508.8 Q 6(#d)30 G(oes show up)-6 E F0 .253(See perlv)128 526.8 R .253(ar for details on setting)-.25 F F1 (%SIG)2.753 E F0 .254(entries and for more e)2.753 F 2.754(xamples. See) -.15 F .254(the Carp module for other)2.754 F(kinds of w)128 538.8 Q (arnings using its)-.1 E F2(carp\(\))2.5 E F0(and)2.5 E F2(cluc)2.5 E (k\(\))-.2 E F0(functions.)2.5 E(when)108 555.6 Q F3 .25(EXPR BLOCK)2.5 F F0(when)108 567.6 Q F3(BLOCK)2.5 E F1(when)128 579.6 Q F0 1.764 (is analogous to the)4.264 F F1(case)4.264 E F0 -.1(ke)4.264 G(yw)-.05 E 1.764(ord in other languages. Used with a)-.1 F F1(foreach)4.263 E F0 1.763(loop or the)4.263 F -.15(ex)128 591.6 S(perimental).15 E F1(given) 3.286 E F0(block,)3.286 E F1(when)3.286 E F0 .786 (can be used in Perl to implement)3.286 F F1(switch)3.286 E F0(/)A F1 (case)A F0(lik)3.287 E 3.287(es)-.1 G(tatements.)-3.287 E -1.27 -.74 (Av a)128 603.6 T 2.45(ilable as a statement after Perl 5.10 and as a s\ tatement modi\214er after 5.14.).74 F 2.45(Here are three)7.45 F -.15 (ex)128 615.6 S(amples:).15 E(perl v5.14.2)72 768 Q 193.17 (2011-10-01 103)162.62 F 0 Cg EP %%Page: 104 104 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use v5.10;)152 84 Q(foreach \(@fruits\) {)152 96 Q (when \(/apples?/\) {)176 108 Q(say "I like apples.")200 120 Q(})176 132 Q(when \(/oranges?/\) {)176 144 Q(say "I don\010t like oranges.")200 156 Q(})176 168 Q(default {)176 180 Q(say "I don\010t like anything")200 192 Q(})176 204 Q(})152 216 Q 6(#r)152 240 S (equire 5.14 for when as statement modifier)-6 E(use v5.14;)152 252 Q (foreach \(@fruits\) {)152 264 Q(say "I like apples.")176 276 Q (when /apples?/;)48 E(say "I don\010t like oranges." when /oranges?;)176 288 Q(default { say "I don\010t like anything" })176 300 Q(})152 312 Q (use v5.10;)152 336 Q(given \($fruit\) {)152 348 Q(when \(/apples?/\) {) 176 360 Q(say "I like apples.")200 372 Q(})176 384 Q (when \(/oranges?/\) {)176 396 Q(say "I don\010t like oranges.")200 408 Q(})176 420 Q(default {)176 432 Q(say "I don\010t like anything")200 444 Q(})176 456 Q(})152 468 Q F0(See `)128 486 Q(`Switch statements')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlsyn for detailed information.)-2.5 E (write)108 502.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(write)108 514.8 Q F2(EXPR)2.5 E F0(write)108 526.8 Q 2.703 (Writes a formatted record \(possibly multi-line\) to the speci\214ed) 128 538.8 R F2(FILEHANDLE)5.204 E F0 5.204(,u)C 2.704(sing the format) -5.204 F 1.601(associated with that \214le.)128 550.8 R 1.601(By def) 6.601 F 1.601(ault the format for a \214le is the one ha)-.1 F 1.6 (ving the same name as the)-.2 F 2.232(\214lehandle, b)128 562.8 R 2.233 (ut the format for the current output channel \(see the)-.2 F F1(select) 4.733 E F0 2.233(function\) may be set)4.733 F -.15(ex)128 574.8 S (plicitly by assigning the name of the format to the).15 E F1($~)2.5 E F0 -.25(va)2.5 G(riable.).25 E -.8(To)128 592.8 S 3.025(po).8 G 3.025 (ff)-3.025 G .525(orm processing is handled automatically:)-3.025 F .524 (if there is insuf)5.524 F .524(\214cient room on the current page for) -.25 F .122(the formatted record, the page is adv)128 604.8 R .123 (anced by writing a form feed, a special top-of-page format is used)-.25 F .667(to format the ne)128 616.8 R 3.167(wp)-.25 G .667 (age header before the record is written.)-3.167 F .667(By def)5.667 F .667(ault, the top-of-page format is the)-.1 F .023 (name of the \214lehandle with `)128 628.8 R(`_T)-.74 E(OP')-.18 E 2.523 ('a)-.74 G .023(ppended. This w)-2.523 F .023 (ould be a problem with auto)-.1 F(vi)-.15 E .023 (vi\214ed \214lehandles,)-.25 F -.2(bu)128 640.8 S 3.243(ti).2 G 3.243 (tm)-3.243 G .743(ay be dynamically set to the format of your choice by\ assigning the name to the)-3.243 F F1($^)3.242 E F0 -.25(va)3.242 G (riable).25 E .28(while that \214lehandle is selected.)128 652.8 R .28 (The number of lines remaining on the current page is in v)5.28 F (ariable)-.25 E F1<24ad>2.78 E F0(,)A(which can be set to)128 664.8 Q F1 (0)2.5 E F0(to force a ne)2.5 E 2.5(wp)-.25 G(age.)-2.5 E(If)128 682.8 Q F2(FILEHANDLE)3.263 E F0 .762 (is unspeci\214ed, output goes to the current def)3.262 F .762 (ault output channel, which starts out as)-.1 F F2(STDOUT)128 694.8 Q F0 -.2(bu)3.876 G 3.877(tm).2 G 1.377(ay be changed by the)-3.877 F F1 (select)3.877 E F0(operator)3.877 E 6.377(.I)-.55 G 3.877(ft)-6.377 G (he)-3.877 E F2(FILEHANDLE)3.877 E F0 1.377(is an)3.877 F F2(EXPR)3.877 E F0 3.877(,t)C 1.377(hen the)-3.877 F -.15(ex)128 706.8 S .218 (pression is e).15 F -.25(va)-.25 G .218 (luated and the resulting string is used to look up the name of the).25 F F2(FILEHANDLE)2.717 E F0 .217(at run)2.717 F 2.5(time. F)128 718.8 R (or more on formats, see perlform.)-.15 E(perl v5.14.2)72 768 Q 193.17 (2011-10-01 104)162.62 F 0 Cg EP %%Page: 105 105 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (Note that write is)128 84 Q/F1 10/Times-Italic@0 SF(not)2.5 E F0 (the opposite of)2.5 E/F2 10/Courier@0 SF(read)2.5 E F0 5(.U)C (nfortunately)-5 E(.)-.65 E(y///)108 100.8 Q (The transliteration operator)128 100.8 Q 5(.S)-.55 G(ame as)-5 E F2 (tr///)2.5 E F0 5(.S)C(ee `)-5 E(`Quote and Quote-lik)-.74 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E (perl v5.14.2)72 768 Q 193.17(2011-10-01 105)162.62 F 0 Cg EP %%Trailer end %%EOF ---- DEBUG filter_nroff is not set, so not filtering Finished writing to /tmp/2K10koeKJ9. 'page: Sending unpaged output to STDOUT. %!PS-Adobe-3.0 %%Creator: groff version 1.20.1 %%CreationDate: Wed Dec 14 12:40:06 2011 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic %%+ font Courier %%+ font Courier-Oblique %%+ font Courier-Bold %%DocumentSuppliedResources: procset grops 1.20 1 %%Pages: 105 %%PageOrder: Ascend %%DocumentMedia: Default 612 792 0 () () %%Orientation: Portrait %%EndComments %%BeginDefaults %%PageMedia: Default %%EndDefaults %%BeginProlog %%BeginResource: procset grops 1.20 1 %!PS-Adobe-3.0 Resource-ProcSet /setpacking where{ pop currentpacking true setpacking }if /grops 120 dict dup begin /SC 32 def /A/show load def /B{0 SC 3 -1 roll widthshow}bind def /C{0 exch ashow}bind def /D{0 exch 0 SC 5 2 roll awidthshow}bind def /E{0 rmoveto show}bind def /F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def /G{0 rmoveto 0 exch ashow}bind def /H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /I{0 exch rmoveto show}bind def /J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def /K{0 exch rmoveto 0 exch ashow}bind def /L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /M{rmoveto show}bind def /N{rmoveto 0 SC 3 -1 roll widthshow}bind def /O{rmoveto 0 exch ashow}bind def /P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /Q{moveto show}bind def /R{moveto 0 SC 3 -1 roll widthshow}bind def /S{moveto 0 exch ashow}bind def /T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def /SF{ findfont exch [exch dup 0 exch 0 exch neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /MF{ findfont [5 2 roll 0 3 1 roll neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /level0 0 def /RES 0 def /PL 0 def /LS 0 def /MANUAL{ statusdict begin/manualfeed true store end }bind def /PLG{ gsave newpath clippath pathbbox grestore exch pop add exch pop }bind def /BP{ /level0 save def 1 setlinecap 1 setlinejoin DEFS/BPhook known{DEFS begin BPhook end}if 72 RES div dup scale LS{ 90 rotate }{ 0 PL translate }ifelse 1 -1 scale }bind def /EP{ level0 restore showpage }def /DA{ newpath arcn stroke }bind def /SN{ transform .25 sub exch .25 sub exch round .25 add exch round .25 add exch itransform }bind def /DL{ SN moveto SN lineto stroke }bind def /DC{ newpath 0 360 arc closepath }bind def /TM matrix def /DE{ TM currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath TM setmatrix }bind def /RC/rcurveto load def /RL/rlineto load def /ST/stroke load def /MT/moveto load def /CL/closepath load def /Fr{ setrgbcolor fill }bind def /setcmykcolor where{ pop /Fk{ setcmykcolor fill }bind def }if /Fg{ setgray fill }bind def /FL/fill load def /LW/setlinewidth load def /Cr/setrgbcolor load def /setcmykcolor where{ pop /Ck/setcmykcolor load def }if /Cg/setgray load def /RE{ findfont dup maxlength 1 index/FontName known not{1 add}if dict begin { 1 index/FID ne 2 index/UniqueID ne and {def}{pop pop}ifelse }forall /Encoding exch def dup/FontName exch def currentdict end definefont pop }bind def /DEFS 0 def /EBEGIN{ moveto DEFS begin }bind def /EEND/end load def /CNT 0 def /level1 0 def /PBEGIN{ /level1 save def translate div 3 1 roll div exch scale neg exch neg exch translate 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit []0 setdash /setstrokeadjust where{ pop false setstrokeadjust }if /setoverprint where{ pop false setoverprint }if newpath /CNT countdictstack def userdict begin /showpage{}def /setpagedevice{}def mark }bind def /PEND{ cleartomark countdictstack CNT sub{end}repeat level1 restore }bind def end def /setpacking where{ pop setpacking }if %%EndResource %%EndProlog %%BeginSetup %%BeginFeature: *PageSize Default << /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice %%EndFeature %%IncludeResource: font Times-Roman %%IncludeResource: font Times-Bold %%IncludeResource: font Times-Italic %%IncludeResource: font Courier %%IncludeResource: font Courier-Oblique %%IncludeResource: font Courier-Bold grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron /scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent /ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen /period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O /P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex /underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y /z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft /guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl /endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen /brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft /logicalnot/minus/registered/macron/degree/plusminus/twosuperior /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior /ordmasculine/guilsinglright/onequarter/onehalf/threequarters /questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn /germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash /ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def /Courier-Bold@0 ENC0/Courier-Bold RE/Courier-Oblique@0 ENC0 /Courier-Oblique RE/Courier@0 ENC0/Courier RE/Times-Italic@0 ENC0 /Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE/Times-Roman@0 ENC0 /Times-Roman RE %%EndSetup %%Page: 1 1 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10.95 /Times-Bold@0 SF -.219(NA)72 84 S(ME).219 E F0(perlfunc \255 Perl b)108 96 Q(uiltin functions)-.2 E F1(DESCRIPTION)72 112.8 Q F0 .591 (The functions in this section can serv)108 124.8 R 3.091(ea)-.15 G 3.091(st)-3.091 G .591(erms in an e)-3.091 F 3.09(xpression. The)-.15 F 3.09(yf)-.15 G .59(all into tw)-3.19 F 3.09(om)-.1 G .59(ajor cate)-3.09 F .59(gories: list)-.15 F 2.4(operators and named unary operators.)108 136.8 R 2.401(These dif)7.401 F 2.401 (fer in their precedence relationship with a follo)-.25 F(wing)-.25 E 3.659(comma. \(See)108 148.8 R 1.159(the precedence table in perlop.\)) 3.659 F 1.159(List operators tak)6.159 F 3.659(em)-.1 G 1.158 (ore than one ar)-3.659 F 1.158(gument, while unary)-.18 F 1.521 (operators can ne)108 160.8 R -.15(ve)-.25 G 4.022(rt).15 G(ak)-4.022 E 4.022(em)-.1 G 1.522(ore than one ar)-4.022 F 4.022(gument. Thus,)-.18 F 4.022(ac)4.022 G 1.522(omma terminates the ar)-4.022 F 1.522 (gument of a unary)-.18 F(operator)108 172.8 Q 2.999(,b)-.4 G .499 (ut merely separates the ar)-3.199 F .499(guments of a list operator) -.18 F 5.499(.A)-.55 G .498(unary operator generally pro)-2.501 F .498 (vides scalar)-.15 F(conte)108 184.8 Q .36(xt to its ar)-.15 F .36 (gument, while a list operator may pro)-.18 F .36 (vide either scalar or list conte)-.15 F .36(xts for its ar)-.15 F 2.86 (guments. If)-.18 F .474(it does both, scalar ar)108 196.8 R .474 (guments come \214rst and list ar)-.18 F .474(gument follo)-.18 F 1.774 -.65(w, a)-.25 H .474(nd there can only e).65 F -.15(ve)-.25 G 2.973(rb) .15 G 2.973(eo)-2.973 G .473(ne such list)-2.973 F(ar)108 208.8 Q 2.512 (gument. F)-.18 F .012(or instance,)-.15 F/F2 10/Times-Italic@0 SF (splice\(\))2.513 E F0 .013(has three scalar ar)2.513 F .013 (guments follo)-.18 F .013(wed by a list, whereas)-.25 F F2 -.1(ge)2.513 G(thostbyname\(\)).1 E F0(has)2.513 E(four scalar ar)108 220.8 Q (guments.)-.18 E .462(In the syntax descriptions that follo)108 237.6 R 1.761 -.65(w, l)-.25 H .461(ist operators that e).65 F .461 (xpect a list \(and pro)-.15 F .461(vide list conte)-.15 F .461 (xt for elements)-.15 F 1.433(of the list\) are sho)108 249.6 R 1.433 (wn with)-.25 F/F3 9/Times-Roman@0 SF(LIST)3.934 E F0 1.434(as an ar) 3.934 F 3.934(gument. Such)-.18 F 3.934(al)3.934 G 1.434 (ist may consist of an)-3.934 F 3.934(yc)-.15 G 1.434 (ombination of scalar)-3.934 F(ar)108 261.6 Q 1.739(guments or list v) -.18 F 1.739(alues; the list v)-.25 F 1.739 (alues will be included in the list as if each indi)-.25 F 1.738 (vidual element were)-.25 F 2.323(interpolated at that point in the lis\ t, forming a longer single-dimensional list v)108 273.6 R 4.824 (alue. Commas)-.25 F(should)4.824 E(separate literal elements of the)108 285.6 Q F3(LIST)2.5 E F0(.)A(An)108 302.4 Q 3.031(yf)-.15 G .531 (unction in the list belo)-3.031 F 3.031(wm)-.25 G .53 (ay be used either with or without parentheses around its ar)-3.031 F 3.03(guments. \(The)-.18 F 1.07 (syntax descriptions omit the parentheses.\))108 314.4 R 1.071 (If you use parentheses, the simple b)6.071 F 1.071 (ut occasionally surprising)-.2 F .254(rule is this: It)108 326.4 R F2 (looks)2.754 E F0(lik)2.754 E 2.754(eaf)-.1 G .254 (unction, therefore it)-2.754 F F2(is)2.754 E F0 2.754(af)2.754 G .254 (unction, and precedence doesn')-2.754 F 2.754(tm)-.18 G(atter)-2.754 E 5.253(.O)-.55 G .253(therwise it')-5.253 F(s)-.55 E 3.63(al)108 338.4 S 1.13(ist operator or unary operator)-3.63 F 3.631(,a)-.4 G 1.131 (nd precedence does matter)-3.631 F 6.131(.W)-.55 G 1.131 (hitespace between the function and left)-6.131 F(parenthesis doesn')108 350.4 Q 2.5(tc)-.18 G(ount, so sometimes you need to be careful:)-2.5 E /F4 10/Courier@0 SF(print 1+2+4;)132 367.2 Q 6(#P)36 G(rints 7.)-6 E (print\(1+2\) + 4;)132 379.2 Q 6(#P)18 G(rints 3.)-6 E(print \(1+2\)+4;) 132 391.2 Q 6(#A)24 G(lso prints 3!)-6 E(print +\(1+2\)+4;)132 403.2 Q 6 (#P)18 G(rints 7.)-6 E(print \(\(1+2\)+4\);)132 415.2 Q 6(#P)12 G (rints 7.)-6 E F0(If you run Perl with the)108 432 Q/F5 10/Times-Bold@0 SF2.5 E F0(switch it can w)2.5 E(arn you about this.)-.1 E -.15 (Fo)5 G 2.5(re).15 G(xample, the third line abo)-2.65 E .3 -.15(ve p) -.15 H(roduces:).15 E F4 (print \(...\) interpreted as function at \255 line 1.)132 448.8 Q (Useless use of integer addition in void context at \255 line 1.)132 460.8 Q F0 3.739(Af)108 477.6 S 1.739 -.25(ew f)-3.739 H 1.239 (unctions tak).25 F 3.739(en)-.1 G 3.739(oa)-3.739 G -.18(rg)-3.739 G 1.239(uments at all, and therefore w).18 F 1.239 (ork as neither unary nor list operators.)-.1 F(These)6.238 E .011 (include such functions as)108 489.6 R F4(time)2.511 E F0(and)2.511 E F4 (endpwent)2.511 E F0 5.012(.F)C .012(or e)-5.162 F(xample,)-.15 E F4 (time+86_400)2.512 E F0(al)2.512 E -.1(wa)-.1 G .012(ys means).1 F F4 .012(time\(\) +)2.512 F(86_400)108 501.6 Q F0(.)A -.15(Fo)108 518.4 S 2.892(rf).15 G .391 (unctions that can be used in either a scalar or list conte)-2.892 F .391(xt, nonaborti)-.15 F .691 -.15(ve f)-.25 H .391 (ailure is generally indicated in).05 F(scalar conte)108 530.4 Q (xt by returning the unde\214ned v)-.15 E(alue, and in list conte)-.25 E (xt by returning the empty list.)-.15 E .662(Remember the follo)108 547.2 R .662(wing important rule: There is)-.25 F F5 .662(no rule)3.162 F F0 .662(that relates the beha)3.162 F .663(vior of an e)-.2 F .663 (xpression in list)-.15 F(conte)108 559.2 Q 1.814(xt to its beha)-.15 F 1.814(vior in scalar conte)-.2 F 1.814(xt, or vice v)-.15 F 4.313 (ersa. It)-.15 F 1.813(might do tw)4.313 F 4.313(ot)-.1 G 1.813 (otally dif)-4.313 F 1.813(ferent things.)-.25 F(Each)6.813 E 1.116 (operator and function decides which sort of v)108 571.2 R 1.116(alue w) -.25 F 1.116(ould be most appropriate to return in scalar conte)-.1 F (xt.)-.15 E .63(Some operators return the length of the list that w)108 583.2 R .63(ould ha)-.1 F .93 -.15(ve b)-.2 H .63 (een returned in list conte).15 F 3.13(xt. Some)-.15 F(operators)3.13 E .909(return the \214rst v)108 595.2 R .909(alue in the list.)-.25 F .909 (Some operators return the last v)5.909 F .909(alue in the list.)-.25 F .909(Some operators return a)5.909 F(count of successful operations.)108 607.2 Q(In general, the)5 E 2.5(yd)-.15 G 2.5(ow)-2.5 G(hat you w)-2.5 E (ant, unless you w)-.1 E(ant consistenc)-.1 E -.65(y.)-.15 G 3.768(An) 108 624 S 1.268(amed array in scalar conte)-3.768 F 1.268 (xt is quite dif)-.15 F 1.268(ferent from what w)-.25 F 1.268 (ould at \214rst glance appear to be a list in)-.1 F .248(scalar conte) 108 636 R 2.748(xt. Y)-.15 F .248(ou can')-1.1 F 2.748(tg)-.18 G .248 (et a list lik)-2.748 F(e)-.1 E F4(\(1,2,3\))2.748 E F0 .248 (into being in scalar conte)2.748 F .249(xt, because the compiler kno) -.15 F(ws)-.25 E .996(the conte)108 648 R .996(xt at compile time.)-.15 F .996(It w)5.996 F .995(ould generate the scalar comma operator there,\ not the list construction)-.1 F -.15(ve)108 660 S(rsion of the comma.) .15 E(That means it w)5 E(as ne)-.1 E -.15(ve)-.25 G 2.5(ral).15 G (ist to start with.)-2.5 E 1.107 (In general, functions in Perl that serv)108 676.8 R 3.608(ea)-.15 G 3.608(sw)-3.608 G 1.108(rappers for system calls \(`)-3.608 F (`syscalls')-.74 E 1.108('\) of the same name \(lik)-.74 F(e)-.1 E F2 -.15(ch)108 688.8 S(own).15 E F0(\(2\),)1.666 E F2(fork)3.802 E F0 (\(2\),)1.666 E F2(closedir)3.802 E F0 1.302 (\(2\), etc.\) return true when the)1.666 F 3.802(ys)-.15 G 1.301 (ucceed and)-3.802 F F4(undef)3.801 E F0 1.301(otherwise, as is usually) 3.801 F .991(mentioned in the descriptions belo)108 700.8 R 4.791 -.65 (w. T)-.25 H .991(his is dif).65 F .991(ferent from the C interf)-.25 F .991(aces, which return)-.1 F F43.492 E F0 .992(on f)3.492 F (ailure.)-.1 E 1.561(Exceptions to this rule include)108 712.8 R F4 (wait)4.061 E F0(,)A F4(waitpid)4.061 E F0 4.061(,a)C(nd)-4.061 E F4 (syscall)4.061 E F0 6.561(.S)C 1.56(ystem calls also set the special) -6.561 F F4($!)4.06 E F0 -.25(va)108 724.8 S(riable on f).25 E 2.5 (ailure. Other)-.1 F(functions do not, e)2.5 E(xcept accidentally)-.15 E (.)-.65 E(perl v5.14.2)72 768 Q 203.17(2011-10-01 1)162.62 F 0 Cg EP %%Page: 2 2 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .817 (Extension modules can also hook into the Perl parser to de\214ne ne)108 84 R 3.318(wk)-.25 G .818(inds of k)-3.318 F -.15(ey)-.1 G -.1(wo).15 G .818(rd-headed e).1 F(xpression.)-.15 E .436(These may look lik)108 96 R 2.936(ef)-.1 G .436(unctions, b)-2.936 F .435 (ut may also look completely dif)-.2 F 2.935(ferent. The)-.25 F .435 (syntax follo)2.935 F .435(wing the k)-.25 F -.15(ey)-.1 G -.1(wo).15 G (rd).1 E .815(is de\214ned entirely by the e)108 108 R 3.315 (xtension. If)-.15 F .815(you are an implementor)3.315 F 3.316(,s)-.4 G .816(ee `)-3.316 F(`PL_k)-.74 E -.15(ey)-.1 G -.1(wo).15 G(rd_plugin').1 E 3.316('i)-.74 G 3.316(np)-3.316 G .816(erlapi for)-3.316 F .612 (the mechanism.)108 120 R .611 (If you are using such a module, see the module')5.612 F 3.111(sd)-.55 G .611(ocumentation for details of the syntax)-3.111 F(that it de\214nes.) 108 132 Q/F1 10/Times-Bold@0 SF -.2(Pe)87 148.8 S (rl Functions by Category).2 E F0 2.625(Here are Perl')108 160.8 R 5.125 (sf)-.55 G 2.626(unctions \(including things that look lik)-5.125 F 5.126(ef)-.1 G 2.626(unctions, lik)-5.126 F 5.126(es)-.1 G 2.626(ome k) -5.126 F -.15(ey)-.1 G -.1(wo).15 G 2.626(rds and named).1 F (operators\) arranged by cate)108 172.8 Q(gory)-.15 E 5(.S)-.65 G (ome functions appear in more than one place.)-5 E (Functions for SCALARs or strings)108 189.6 Q/F2 10/Courier@0 SF(chomp) 128 201.6 Q F0(,)A F2(chop)2.693 E F0(,)A F2(chr)2.693 E F0(,)A F2 (crypt)2.693 E F0(,)A F2(hex)2.693 E F0(,)A F2(index)2.692 E F0(,)A F2 (lc)2.692 E F0(,)A F2(lcfirst)2.692 E F0(,)A F2(length)2.692 E F0(,)A F2 (oct)2.692 E F0(,)A F2(ord)2.692 E F0(,)A F2(pack)2.692 E F0(,)A F2(q//) 2.692 E F0(,)A F2(qq//)2.692 E F0(,)A F2(reverse)128 213.6 Q F0(,)A F2 (rindex)2.5 E F0(,)A F2(sprintf)2.5 E F0(,)A F2(substr)2.5 E F0(,)A F2 (tr///)2.5 E F0(,)A F2(uc)2.5 E F0(,)A F2(ucfirst)2.5 E F0(,)A F2(y///) 2.5 E F0(Re)108 230.4 Q(gular e)-.15 E(xpressions and pattern matching) -.15 E F2(m//)128 242.4 Q F0(,)A F2(pos)2.5 E F0(,)A F2(quotemeta)2.5 E F0(,)A F2(s///)2.5 E F0(,)A F2(split)2.5 E F0(,)A F2(study)2.5 E F0(,)A F2(qr//)2.5 E F0(Numeric functions)108 259.2 Q F2(abs)128 271.2 Q F0(,)A F2(atan2)2.5 E F0(,)A F2(cos)2.5 E F0(,)A F2(exp)2.5 E F0(,)A F2(hex)2.5 E F0(,)A F2(int)2.5 E F0(,)A F2(log)2.5 E F0(,)A F2(oct)2.5 E F0(,)A F2 (rand)2.5 E F0(,)A F2(sin)2.5 E F0(,)A F2(sqrt)2.5 E F0(,)A F2(srand)2.5 E F0(Functions for real)108 288 Q F2(@ARRAYs)2.5 E(each)128 300 Q F0(,)A F2(keys)2.5 E F0(,)A F2(pop)2.5 E F0(,)A F2(push)2.5 E F0(,)A F2(shift) 2.5 E F0(,)A F2(splice)2.5 E F0(,)A F2(unshift)2.5 E F0(,)A F2(values) 2.5 E F0(Functions for list data)108 316.8 Q F2(grep)128 328.8 Q F0(,)A F2(join)2.5 E F0(,)A F2(map)2.5 E F0(,)A F2(qw//)2.5 E F0(,)A F2 (reverse)2.5 E F0(,)A F2(sort)2.5 E F0(,)A F2(unpack)2.5 E F0 (Functions for real)108 345.6 Q F2(%HASHes)2.5 E(delete)128 357.6 Q F0 (,)A F2(each)2.5 E F0(,)A F2(exists)2.5 E F0(,)A F2(keys)2.5 E F0(,)A F2 (values)2.5 E F0(Input and output functions)108 374.4 Q F2(binmode)128 386.4 Q F0(,)A F2(close)4.333 E F0(,)A F2(closedir)4.333 E F0(,)A F2 (dbmclose)4.333 E F0(,)A F2(dbmopen)4.333 E F0(,)A F2(die)4.333 E F0(,)A F2(eof)4.333 E F0(,)A F2(fileno)4.334 E F0(,)A F2(flock)4.334 E F0(,)A F2(format)4.334 E F0(,)A F2(getc)128 398.4 Q F0(,)A F2(print)6.334 E F0 (,)A F2(printf)6.334 E F0(,)A F2(read)6.334 E F0(,)A F2(readdir)6.333 E F0(,)A F2(rewinddir)6.333 E F0(,)A F2(say)6.333 E F0(,)A F2(seek)6.333 E F0(,)A F2(seekdir)6.333 E F0(,)A F2(select)6.333 E F0(,)A F2(syscall)128 410.4 Q F0(,)A F2(sysread)2.5 E F0(,)A F2(sysseek)2.5 E F0(,)A F2 (syswrite)2.5 E F0(,)A F2(tell)2.5 E F0(,)A F2(telldir)2.5 E F0(,)A F2 (truncate)2.5 E F0(,)A F2(warn)2.5 E F0(,)A F2(write)2.5 E F0 (Functions for \214x)108 427.2 Q(ed-length data or records)-.15 E F2 (pack)128 439.2 Q F0(,)A F2(read)2.5 E F0(,)A F2(syscall)2.5 E F0(,)A F2 (sysread)2.5 E F0(,)A F2(syswrite)2.5 E F0(,)A F2(unpack)2.5 E F0(,)A F2 (vec)2.5 E F0(Functions for \214lehandles, \214les, or directories)108 456 Q F2128 468 Q/F3 10/Courier-Oblique@0 SF(X)A F0(,)A F2(chdir) 4.727 E F0(,)A F2(chmod)4.727 E F0(,)A F2(chown)4.727 E F0(,)A F2 (chroot)4.727 E F0(,)A F2(fcntl)4.727 E F0(,)A F2(glob)4.727 E F0(,)A F2 (ioctl)4.727 E F0(,)A F2(link)4.727 E F0(,)A F2(lstat)4.728 E F0(,)A F2 (mkdir)4.728 E F0(,)A F2(open)4.728 E F0(,)A F2(opendir)128 480 Q F0(,)A F2(readlink)2.5 E F0(,)A F2(rename)2.5 E F0(,)A F2(rmdir)2.5 E F0(,)A F2 (stat)2.5 E F0(,)A F2(symlink)2.5 E F0(,)A F2(sysopen)2.5 E F0(,)A F2 (umask)2.5 E F0(,)A F2(unlink)2.5 E F0(,)A F2(utime)2.5 E F0 -2.15 -.25 (Ke y)108 496.8 T -.1(wo).25 G(rds related to the control \215o).1 E 2.5 (wo)-.25 G 2.5(fy)-2.5 G(our Perl program)-2.5 E F2(caller)128 508.8 Q F0(,)A F2(continue)3.625 E F0(,)A F2(die)3.625 E F0(,)A F2(do)3.625 E F0 (,)A F2(dump)3.625 E F0(,)A F2(eval)3.625 E F0(,)A F2(exit)3.625 E F0(,) A F2(goto)3.625 E F0(,)A F2(last)3.625 E F0(,)A F2(next)3.625 E F0(,)A F2(redo)3.625 E F0(,)A F2(return)3.625 E F0(,)A F2(sub)3.625 E F0(,)A F2 (wantarray)128 520.8 Q F0 -2.15 -.25(Ke y)108 537.6 T -.1(wo).25 G (rds related to the switch feature).1 E F2(break)128 549.6 Q F0(,)A F2 (continue)2.5 E F0(,)A F2(default, given)2.5 E F0(,)A F2(when)2.5 E F0 .629(These are a)128 567.6 R -.25(va)-.2 G .629 (ilable only if you enable the).25 F F2("switch")3.129 E F0 3.129 (feature. See)3.129 F .63(feature and `)3.13 F .63(`Switch statements') -.74 F(')-.74 E(in perlsyn.)128 579.6 Q(Alternately)5 E 2.5(,i)-.65 G (nclude a)-2.5 E F2(use v5.10)2.5 E F0(or later to the current scope.) 2.5 E -2.15 -.25(Ke y)108 596.4 T -.1(wo).25 G(rds related to scoping).1 E F2(caller)128 608.4 Q F0(,)A F2(import)2.5 E F0(,)A F2(local)2.5 E F0 (,)A F2(my)2.5 E F0(,)A F2(our)2.5 E F0(,)A F2(package)2.5 E F0(,)A F2 (state)2.5 E F0(,)A F2(use)2.5 E(state)128 626.4 Q F0 .675(is a)3.175 F -.25(va)-.2 G .675(ilable only if the).25 F F2("state")3.175 E F0 .675 (feature is enabled. See feature.)3.175 F(Alternately)5.674 E 3.174(,i) -.65 G .674(nclude a)-3.174 F F2(use)3.174 E(v5.10)128 638.4 Q F0 (or later to the current scope.)2.5 E(Miscellaneous functions)108 655.2 Q F2(defined)128 667.2 Q F0(,)A F2(dump)6.05 E F0(,)A F2(eval)6.05 E F0 (,)A F2(formline)6.05 E F0(,)A F2(local)6.05 E F0(,)A F2(my)6.05 E F0(,) A F2(our)6.05 E F0(,)A F2(reset)6.05 E F0(,)A F2(scalar)6.05 E F0(,)A F2 (state)6.05 E F0(,)A F2(undef)6.05 E F0(,)A F2(wantarray)128 679.2 Q F0 (Functions for processes and process groups)108 696 Q F2(alarm)128 708 Q F0(,)A F2(exec)5 E F0(,)A F2(fork)5 E F0(,)A F2(getpgrp)5 E F0(,)A F2 (getppid)5 E F0(,)A F2(getpriority)5 E F0(,)A F2(kill)5 E F0(,)A F2 (pipe)5 E F0(,)A F2(qx//)5 E F0(,)A F2(setpgrp)5 E F0(,)A F2 (setpriority)128 720 Q F0(,)A F2(sleep)2.5 E F0(,)A F2(system)2.5 E F0 (,)A F2(times)2.5 E F0(,)A F2(wait)2.5 E F0(,)A F2(waitpid)2.5 E F0 (perl v5.14.2)72 768 Q 203.17(2011-10-01 2)162.62 F 0 Cg EP %%Page: 3 3 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E -2.15 -.25(Ke y) 108 84 T -.1(wo).25 G(rds related to Perl modules).1 E/F1 10/Courier@0 SF(do)128 96 Q F0(,)A F1(import)2.5 E F0(,)A F1(no)2.5 E F0(,)A F1 (package)2.5 E F0(,)A F1(require)2.5 E F0(,)A F1(use)2.5 E F0 -2.15 -.25 (Ke y)108 112.8 T -.1(wo).25 G (rds related to classes and object-orientation).1 E F1(bless)128 124.8 Q F0(,)A F1(dbmclose)2.5 E F0(,)A F1(dbmopen)2.5 E F0(,)A F1(package)2.5 E F0(,)A F1(ref)2.5 E F0(,)A F1(tie)2.5 E F0(,)A F1(tied)2.5 E F0(,)A F1 (untie)2.5 E F0(,)A F1(use)2.5 E F0(Lo)108 141.6 Q(w-le)-.25 E -.15(ve) -.25 G 2.5(ls).15 G(ock)-2.5 E(et functions)-.1 E F1(accept)128 153.6 Q F0(,)A F1(bind)5.428 E F0(,)A F1(connect)5.428 E F0(,)A F1(getpeername) 5.428 E F0(,)A F1(getsockname)5.429 E F0(,)A F1(getsockopt)5.429 E F0(,) A F1(listen)5.429 E F0(,)A F1(recv)5.429 E F0(,)A F1(send)128 165.6 Q F0 (,)A F1(setsockopt)2.5 E F0(,)A F1(shutdown)2.5 E F0(,)A F1(socket)2.5 E F0(,)A F1(socketpair)2.5 E F0 (System V interprocess communication functions)108 182.4 Q F1(msgctl)128 194.4 Q F0(,)A F1(msgget)3 E F0(,)A F1(msgrcv)3 E F0(,)A F1(msgsnd)3 E F0(,)A F1(semctl)3 E F0(,)A F1(semget)3 E F0(,)A F1(semop)3 E F0(,)A F1 (shmctl)3 E F0(,)A F1(shmget)3 E F0(,)A F1(shmread)3 E F0(,)A F1 (shmwrite)128 206.4 Q F0(Fetching user and group info)108 223.2 Q F1 (endgrent)128 235.2 Q F0(,)A F1(endhostent)6.75 E F0(,)A F1(endnetent) 6.75 E F0(,)A F1(endpwent)6.75 E F0(,)A F1(getgrent)6.75 E F0(,)A F1 (getgrgid)6.75 E F0(,)A F1(getgrnam)6.75 E F0(,)A F1(getlogin)128 247.2 Q F0(,)A F1(getpwent)2.5 E F0(,)A F1(getpwnam)2.5 E F0(,)A F1(getpwuid) 2.5 E F0(,)A F1(setgrent)2.5 E F0(,)A F1(setpwent)2.5 E F0 (Fetching netw)108 264 Q(ork info)-.1 E F1(endprotoent)128 276 Q F0(,)A F1(endservent)14.375 E F0(,)A F1(gethostbyaddr)14.375 E F0(,)A F1 (gethostbyname)14.375 E F0(,)A F1(gethostent)14.375 E F0(,)A F1 (getnetbyaddr)128 288 Q F0(,)A F1(getnetbyname)5.375 E F0(,)A F1 (getnetent)5.375 E F0(,)A F1(getprotobyname)5.375 E F0(,)A F1 (getprotobynumber)5.375 E F0(,)A F1(getprotoent)128 300 Q F0(,)A F1 (getservbyname)14.375 E F0(,)A F1(getservbyport)14.375 E F0(,)A F1 (getservent)14.375 E F0(,)A F1(sethostent)14.375 E F0(,)A F1(setnetent) 128 312 Q F0(,)A F1(setprotoent)2.5 E F0(,)A F1(setservent)2.5 E F0 -.35 (Ti)108 328.8 S(me-related functions).35 E F1(gmtime)128 340.8 Q F0(,)A F1(localtime)2.5 E F0(,)A F1(time)2.5 E F0(,)A F1(times)2.5 E F0 (Functions ne)108 357.6 Q 2.5(wi)-.25 G 2.5(np)-2.5 G(erl5)-2.5 E F1 (abs)128 369.6 Q F0(,)A F1(bless)3.05 E F0(,)A F1(break)3.05 E F0(,)A F1 (chomp)3.05 E F0(,)A F1(chr)3.05 E F0(,)A F1(continue)3.05 E F0(,)A F1 (default)3.05 E F0(,)A F1(exists)3.05 E F0(,)A F1(formline)3.05 E F0(,)A F1(given)3.05 E F0(,)A F1(glob)3.05 E F0(,)A F1(import)128 381.6 Q F0(,) A F1(lc)2.625 E F0(,)A F1(lcfirst)2.625 E F0(,)A F1(lock)2.625 E F0(,)A F1(map)2.625 E F0(,)A F1(my)2.625 E F0(,)A F1(no)2.625 E F0(,)A F1(our) 2.625 E F0(,)A F1(prototype)2.625 E F0(,)A F1(qr//)2.625 E F0(,)A F1 (qw//)2.625 E F0(,)A F1(qx//)2.625 E F0(,)A F1(readline)2.625 E F0(,)A F1(readpipe)128 393.6 Q F0(,)A F1(ref)2.5 E F0(,)A F1(sub)2.5 E F0(*,)A F1(sysopen)2.5 E F0(,)A F1(tie)2.5 E F0(,)A F1(tied)2.5 E F0(,)A F1(uc) 2.5 E F0(,)A F1(ucfirst)2.5 E F0(,)A F1(untie)2.5 E F0(,)A F1(use)2.5 E F0(,)A F1(when)2.5 E F0(*)128 411.6 Q F1(sub)2.5 E F0 -.1(wa)2.5 G 2.5 (sak).1 G -.15(ey)-2.6 G -.1(wo).15 G(rd in Perl 4, b).1 E (ut in Perl 5 it is an operator)-.2 E 2.5(,w)-.4 G (hich can be used in e)-2.5 E(xpressions.)-.15 E (Functions obsoleted in perl5)108 428.4 Q F1(dbmclose)128 440.4 Q F0(,)A F1(dbmopen)2.5 E/F2 10/Times-Bold@0 SF -.2(Po)87 457.2 S(rtability).2 E F0 .316(Perl w)108 469.2 R .317 (as born in Unix and can therefore access all common Unix system calls.) -.1 F .317(In non-Unix en)5.317 F(vironments,)-.4 E 1.018 (the functionality of some Unix system calls may not be a)108 481.2 R -.25(va)-.2 G 1.017(ilable or details of the a).25 F -.25(va)-.2 G 1.017 (ilable functionality).25 F(may dif)108 493.2 Q(fer slightly)-.25 E 5 (.T)-.65 G(he Perl functions af)-5 E(fected by this are:)-.25 E F1 108 510 Q F0(,)A F1(binmode)7.222 E F0(,)A F1(chmod)7.222 E F0(,)A F1 (chown)7.222 E F0(,)A F1(chroot)7.222 E F0(,)A F1(crypt)7.222 E F0(,)A F1(dbmclose)7.222 E F0(,)A F1(dbmopen)7.222 E F0(,)A F1(dump)7.223 E F0 (,)A F1(endgrent)7.223 E F0(,)A F1(endhostent)108 522 Q F0(,)A F1 (endnetent)5.715 E F0(,)A F1(endprotoent)5.715 E F0(,)A F1(endpwent) 5.714 E F0(,)A F1(endservent)5.714 E F0(,)A F1(exec)5.714 E F0(,)A F1 (fcntl)5.714 E F0(,)A F1(flock)5.714 E F0(,)A F1(fork)108 534 Q F0(,)A F1(getgrent)6.083 E F0(,)A F1(getgrgid)6.083 E F0(,)A F1(gethostbyname) 6.083 E F0(,)A F1(gethostent)6.083 E F0(,)A F1(getlogin)6.084 E F0(,)A F1(getnetbyaddr)6.084 E F0(,)A F1(getnetbyname)108 546 Q F0(,)A F1 (getnetent)9 E F0(,)A F1(getppid)9 E F0(,)A F1(getpgrp)9 E F0(,)A F1 (getpriority)9 E F0(,)A F1(getprotobynumber)9 E F0(,)A F1(getprotoent) 108 558 Q F0(,)A F1(getpwent)13.8 E F0(,)A F1(getpwnam)13.8 E F0(,)A F1 (getpwuid)13.8 E F0(,)A F1(getservbyport)13.8 E F0(,)A F1(getservent) 13.8 E F0(,)A F1(getsockopt)108 570 Q F0(,)A F1(glob)4.45 E F0(,)A F1 (ioctl)4.45 E F0(,)A F1(kill)4.45 E F0(,)A F1(link)4.45 E F0(,)A F1 (lstat)4.45 E F0(,)A F1(msgctl)4.45 E F0(,)A F1(msgget)4.45 E F0(,)A F1 (msgrcv)4.45 E F0(,)A F1(msgsnd)4.45 E F0(,)A F1(open)4.45 E F0(,)A F1 (pipe)108 582 Q F0(,)A F1(readlink)6.937 E F0(,)A F1(rename)6.937 E F0 (,)A F1(select)6.937 E F0(,)A F1(semctl)6.937 E F0(,)A F1(semget)6.938 E F0(,)A F1(semop)6.938 E F0(,)A F1(setgrent)6.938 E F0(,)A F1(sethostent) 6.938 E F0(,)A F1(setnetent)108 594 Q F0(,)A F1(setpgrp)3.084 E F0(,)A F1(setpriority)3.084 E F0(,)A F1(setprotoent)3.083 E F0(,)A F1(setpwent) 3.083 E F0(,)A F1(setservent)3.083 E F0(,)A F1(setsockopt)3.083 E F0(,)A F1(shmctl)108 606 Q F0(,)A F1(shmget)5.437 E F0(,)A F1(shmread)5.437 E F0(,)A F1(shmwrite)5.437 E F0(,)A F1(socket)5.437 E F0(,)A F1 (socketpair)5.438 E F0(,)A F1(stat)5.438 E F0(,)A F1(symlink)5.438 E F0 (,)A F1(syscall)5.438 E F0(,)A F1(sysopen)108 618 Q F0(,)A F1(system)2.5 E F0(,)A F1(times)2.5 E F0(,)A F1(truncate)2.5 E F0(,)A F1(umask)2.5 E F0(,)A F1(unlink)2.5 E F0(,)A F1(utime)2.5 E F0(,)A F1(wait)2.5 E F0(,)A F1(waitpid)2.5 E F0 -.15(Fo)108 634.8 S 3.782(rm).15 G 1.281(ore inform\ ation about the portability of these functions, see perlport and other \ a)-3.782 F -.25(va)-.2 G 1.281(ilable platform-).25 F (speci\214c documentation.)108 646.8 Q F2(Alphabetical Listing of P)87 663.6 Q(erl Functions)-.2 E F0108 675.6 Q/F3 9/Times-Roman@0 SF (FILEHANDLE)2.5 E F0108 687.6 Q F3(EXPR)2.5 E F0108 699.6 Q F3(DIRHANDLE)2.5 E F0108 711.6 Q 2.715<418c>128 711.6 S .215 (le test, where X is one of the letters listed belo)-2.715 F 4.015 -.65 (w. T)-.25 H .215(his unary operator tak).65 F .216(es one ar)-.1 F .216 (gument, either a)-.18 F .638(\214lename, a \214lehandle, or a dirhandl\ e, and tests the associated \214le to see if something is true about it\ .)128 723.6 R(perl v5.14.2)72 768 Q 203.17(2011-10-01 3)162.62 F 0 Cg EP %%Page: 4 4 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .18(If the ar)128 84 R .181(gument is omitted, tests)-.18 F/F1 10/Courier@0 SF($_)2.681 E F0 2.681(,e)C .181(xcept for)-2.831 F F12.681 E F0 2.681(,w)C .181 (hich tests)-2.681 F/F2 9/Times-Roman@0 SF(STDIN)2.681 E F0 5.181(.U)C .181(nless otherwise documented,)-5.181 F .231(it returns)128 96 R F1(1) 2.731 E F0 .231(for true and)2.731 F F1<0808>2.731 E F0 .231(for f)2.731 F .231(alse, or the unde\214ned v)-.1 F .231(alue if the \214le doesn') -.25 F 2.731(te)-.18 G 2.731(xist. Despite)-2.881 F .231(the funn)2.731 F(y)-.15 E(names, precedence is the same as an)128 108 Q 2.5(yo)-.15 G (ther named unary operator)-2.5 E 5(.T)-.55 G(he operator may be an)-5 E 2.5(yo)-.15 G(f:)-2.5 E F1 6(\255r File)152 126 R (is readable by effective uid/gid.)6 E 6(\255w File)152 138 R (is writable by effective uid/gid.)6 E 6(\255x File)152 150 R (is executable by effective uid/gid.)6 E 6(\255o File)152 162 R (is owned by effective uid.)6 E 6(\255R File)152 186 R (is readable by real uid/gid.)6 E 6(\255W File)152 198 R (is writable by real uid/gid.)6 E 6(\255X File)152 210 R (is executable by real uid/gid.)6 E 6(\255O File)152 222 R (is owned by real uid.)6 E 6(\255e File)152 246 R(exists.)6 E 6 (\255z File)152 258 R(has zero size \(is empty\).)6 E 6(\255s File)152 270 R(has nonzero size \(returns size in bytes\).)6 E 6(\255f File)152 294 R(is a plain file.)6 E 6(\255d File)152 306 R(is a directory.)6 E 6 (\255l File)152 318 R(is a symbolic link.)6 E 6(\255p File)152 330 R (is a named pipe \(FIFO\), or Filehandle is a pipe.)6 E 6(\255S File)152 342 R(is a socket.)6 E 6(\255b File)152 354 R(is a block special file.)6 E 6(\255c File)152 366 R(is a character special file.)6 E 6 (\255t Filehandle)152 378 R(is opened to a tty.)6 E 6(\255u File)152 402 R(has setuid bit set.)6 E 6(\255g File)152 414 R(has setgid bit set.)6 E 6(\255k File)152 426 R(has sticky bit set.)6 E 6(\255T File)152 450 R (is an ASCII text file \(heuristic guess\).)6 E 6(\255B File)152 462 R (is a "binary" file \(opposite of \255T\).)6 E 6(\255M Script)152 486 R (start time minus file modification time, in days.)6 E 6(\255A Same)152 498 R(for access time.)6 E 6(\255C Same)152 510 R (for inode change time \(Unix, may differ for other platforms\))6 E F0 (Example:)128 528 Q F1(while \(<>\) {)152 546 Q(chomp;)176 558 Q (next unless \255f $_;)176 570 Q 6(#i)12 G(gnore specials)-6 E(#...)176 582 Q(})152 594 Q F0 3.036(Note that)128 612 R F1(\255s/a/b/)5.536 E F0 3.036(does not do a ne)5.536 F -.05(ga)-.15 G 3.036(ted substitution.) .05 F(Saying)8.036 E F1(\255exp\($foo\))5.536 E F0 3.037(still w)5.536 F 3.037(orks as)-.1 F -.15(ex)128 624 S(pected, ho).15 E(we)-.25 E -.15 (ve)-.25 G(r: only single letters follo).15 E (wing a minus are interpreted as \214le tests.)-.25 E .164 (These operators are e)128 642 R -.15(xe)-.15 G .163(mpt from the `).15 F .163(`looks lik)-.74 F 2.663(eaf)-.1 G .163(unction rule')-2.663 F 2.663('d)-.74 G .163(escribed abo)-2.663 F -.15(ve)-.15 G 2.663(.T).15 G .163(hat is, an opening)-2.663 F 3.019 (parenthesis after the operator does not af)128 654 R 3.019(fect ho)-.25 F 5.519(wm)-.25 G 3.019(uch of the follo)-5.519 F 3.02 (wing code constitutes the)-.25 F(ar)128 666 Q .797(gument. Put the ope\ ning parentheses before the operator to separate it from code that foll\ o)-.18 F .796(ws \(this)-.25 F(applies only to operators with higher pr\ ecedence than unary operators, of course\):)128 678 Q F1 (\255s\($file\) + 1024)152 696 Q 6(#p)18 G (robably wrong; same as \255s\($file + 1024\))-6 E (\(\255s $file\) + 1024)152 708 Q 6(#c)12 G(orrect)-6 E F0 1.152 (The interpretation of the \214le permission operators)128 726 R F1 3.652 E F0(,)A F13.652 E F0(,)A F13.652 E F0(,)A F1 3.652 E F0(,)A F13.652 E F0 3.653(,a)C(nd)-3.653 E F1 3.653 E F0 1.153(is by def)3.653 F 1.153(ault based)-.1 F(perl v5.14.2) 72 768 Q 203.17(2011-10-01 4)162.62 F 0 Cg EP %%Page: 5 5 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .305 (solely on the mode of the \214le and the uids and gids of the user)128 84 R 5.305(.T)-.55 G .305(here may be other reasons you can')-5.305 F(t) -.18 E .356(actually read, write, or e)128 96 R -.15(xe)-.15 G .356 (cute the \214le: for e).15 F .357(xample netw)-.15 F .357 (ork \214lesystem access controls, A)-.1 F .357(CLs \(access)-.4 F .674 (control lists\), read-only \214lesystems, and unrecognized e)128 108 R -.15(xe)-.15 G .674(cutable formats.).15 F .674 (Note that the use of these)5.674 F .984(six speci\214c operators to v) 128 120 R .985(erify if some operation is possible is usually a mistak) -.15 F .985(e, because it may be)-.1 F(open to race conditions.)128 132 Q .063 (Also note that, for the superuser on the local \214lesystems, the)128 150 R/F1 10/Courier@0 SF2.563 E F0(,)A F12.563 E F0(,)A F1 2.562 E F0 2.562(,a)C(nd)-2.562 E F12.562 E F0 .062 (tests al)2.562 F -.1(wa)-.1 G .062(ys return 1,).1 F(and)128 162 Q F1 3.261 E F0(and)3.261 E F13.262 E F0 .762(return 1 if an) 3.262 F 3.262(ye)-.15 G -.15(xe)-3.412 G .762 (cute bit is set in the mode.).15 F .762 (Scripts run by the superuser may thus)5.762 F 1.108(need to do a)128 174 R/F2 10/Times-Italic@0 SF(stat\(\))3.608 E F0 1.108(to determine th\ e actual mode of the \214le, or temporarily set their ef)3.608 F(fecti) -.25 E 1.407 -.15(ve u)-.25 H 1.107(id to).15 F(something else.)128 186 Q .818(If you are using A)128 204 R .819(CLs, there is a pragma called) -.4 F F1(filetest)3.319 E F0 .819 (that may produce more accurate results)3.319 F 1.965(than the bare)128 216 R F2(stat\(\))4.464 E F0 1.964(mode bits.)4.464 F 1.964(When under) 6.964 F F1 1.964(use filetest \010access\010)4.464 F F0 1.964(the abo) 4.464 F -.15(ve)-.15 G(-mentioned).15 E 1.087(\214letests test whether \ the permission can\(not\) be granted using the)128 228 R F2(access)3.587 E F0 1.087(\(2\) f)1.666 F 1.087(amily of system calls.)-.1 F 2.464 (Also note that the)128 240 R F14.964 E F0(and)4.964 E F1 4.964 E F0 2.463(may under this pragma return true e)4.963 F -.15(ve) -.25 G 4.963(ni).15 G 4.963(ft)-4.963 G 2.463(here are no e)-4.963 F -.15(xe)-.15 G(cute).15 E 3.272(permission bits set \(nor an)128 252 R 5.773(ye)-.15 G 3.273(xtra e)-5.923 F -.15(xe)-.15 G 3.273 (cute permission A).15 F 5.773(CLs\). This)-.4 F 3.273 (strangeness is due to the)5.773 F 1.069(underlying system calls' de\ \214nitions. Note also that, due to the implementation of)128 264 R F1 1.069(use filetest)3.569 F(\010access\010)128 276 Q F0 3.545(,t)C(he) -3.545 E F1(_)3.545 E F0 1.045(special \214lehandle w)3.545 F(on')-.1 E 3.545(tc)-.18 G 1.045 (ache the results of the \214le tests when this pragma is in)-3.545 F (ef)128 288 Q 2.5(fect. Read)-.25 F(the documentation for the)2.5 E F1 (filetest)2.5 E F0(pragma for more information.)2.5 E(The)128 306 Q F1 4.427 E F0(and)4.427 E F14.427 E F0 1.927(switches w)4.427 F 1.927(ork as follo)-.1 F 4.426(ws. The)-.25 F 1.926 (\214rst block or so of the \214le is e)4.426 F 1.926(xamined for odd) -.15 F 1.945(characters such as strange control codes or characters wit\ h the high bit set.)128 318 R 1.946(If too man)6.946 F 4.446(ys)-.15 G (trange)-4.446 E .884(characters \(>30%\) are found, it')128 330 R 3.384 (sa)-.55 G F1A F0 .884(\214le; otherwise it')3.384 F 3.384(sa)-.55 G F1A F0 3.384(\214le. Also,)3.384 F(an)3.384 E 3.384<798c>-.15 G .883(le containing a zero)-3.384 F .778 (byte in the \214rst block is considered a binary \214le.)128 342 R(If) 5.778 E F13.278 E F0(or)3.278 E F13.278 E F0 .778 (is used on a \214lehandle, the current)3.278 F/F3 9/Times-Roman@0 SF (IO)3.278 E F0 -.2(bu)128 354 S -.25(ff).2 G .228(er is e).25 F .227 (xamined rather than the \214rst block.)-.15 F(Both)5.227 E F1 2.727 E F0(and)2.727 E F12.727 E F0 .227 (return true on an empty \214le, or a \214le at)2.727 F F3(EOF)128 366 Q F0 .763(when testing a \214lehandle.)3.263 F .763(Because you ha)5.763 F 1.064 -.15(ve t)-.2 H 3.264(or).15 G .764(ead a \214le to do the)-3.264 F F13.264 E F0 .764(test, on most occasions)3.264 F(you w)128 378 Q(ant to use a)-.1 E F12.5 E F0(ag)2.5 E (ainst the \214le \214rst, as in)-.05 E F1 (next unless \255f $file && \255T $file)2.5 E F0(.)A .047(If an)128 396 R 2.547(yo)-.15 G 2.546(ft)-2.547 G .046 (he \214le tests \(or either the)-2.546 F F1(stat)2.546 E F0(or)2.546 E F1(lstat)2.546 E F0 .046(operator\) is gi)2.546 F -.15(ve)-.25 G 2.546 (nt).15 G .046(he special \214lehandle consisting)-2.546 F .088 (of a solitary underline, then the stat structure of the pre)128 408 R .089(vious \214le test \(or stat operator\) is used, sa)-.25 F .089 (ving a)-.2 F .049(system call.)128 420 R .049(\(This doesn')5.049 F 2.549(tw)-.18 G .049(ork with)-2.649 F F12.549 E F0 2.549(,a)C .049(nd you need to remember that)-2.549 F F2(lstat\(\))2.549 E F0(and) 2.549 E F12.549 E F0(lea)2.549 E .348 -.15(ve v)-.2 H .048 (alues in)-.1 F 1.438 (the stat structure for the symbolic link, not the real \214le.\))128 432 R 1.438(\(Also, if the stat b)6.438 F(uf)-.2 E 1.438(fer w)-.25 F 1.438(as \214lled by an)-.1 F F1(lstat)128 444 Q F0(call,)2.5 E F1 2.5 E F0(and)2.5 E F12.5 E F0(will reset it with the results of) 2.5 E F1(stat _)2.5 E F0 2.5(\). Example:)B F1 (print "Can do.\\n" if \255r $a || \255w _ || \255x _;)152 462 Q (stat\($filename\);)152 486 Q(print "Readable\\n" if \255r _;)152 498 Q (print "Writable\\n" if \255w _;)152 510 Q (print "Executable\\n" if \255x _;)152 522 Q (print "Setuid\\n" if \255u _;)152 534 Q(print "Setgid\\n" if \255g _;) 152 546 Q(print "Sticky\\n" if \255k _;)152 558 Q (print "Text\\n" if \255T _;)152 570 Q(print "Binary\\n" if \255B _;)152 582 Q F0 .215(As of Perl 5.9.1, as a form of purely syntactic sug)128 600 R(ar)-.05 E 2.715(,y)-.4 G .215 (ou can stack \214le test operators, in a w)-2.715 F .214(ay that)-.1 F F12.714 E .151(\255w \255x $file)128 612 R F0 .151(is equi)2.651 F -.25(va)-.25 G .151(lent to).25 F F1 .151 (\255x $file && \255w _ && \255f _)2.651 F F0 2.651(.\()C .151 (This is only f)-2.651 F(anc)-.1 E 2.651(yf)-.15 G(anc)-2.751 E .151 (y: if you)-.15 F .697(use the return v)128 624 R .697(alue of)-.25 F F1 .697(\255f $file)3.197 F F0 .697(as an ar)3.197 F .696 (gument to another \214letest operator)-.18 F 3.196(,n)-.4 G 3.196(os) -3.196 G .696(pecial magic will)-3.196 F(happen.\))128 636 Q(abs)108 652.8 Q F3 -1.215(VA)2.5 G(LUE)1.215 E F0(abs)108 664.8 Q (Returns the absolute v)128 664.8 Q(alue of its ar)-.25 E 2.5 (gument. If)-.18 F F3 -1.215(VA)2.5 G(LUE)1.215 E F0(is omitted, uses) 2.5 E F1($_)2.5 E F0(.)A(accept)108 681.6 Q F3(NEWSOCKET)2.5 E F0 (,GENERICSOCKET)A 2.841(Accepts an incoming sock)128 693.6 R 2.841 (et connect, just as)-.1 F F2(accept)5.341 E F0 2.841(\(2\) does.)1.666 F 2.841(Returns the pack)7.841 F 2.841(ed address if it)-.1 F (succeeded, f)128 705.6 Q(alse otherwise.)-.1 E(See the e)5 E (xample in `)-.15 E(`Sock)-.74 E(ets: Client/Serv)-.1 E (er Communication')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E 1.179(On systems that support a close-on-e)128 723.6 R -.15(xe)-.15 G 3.679<638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.679 F 1.178(wly opened \214le)-.25 F(perl v5.14.2)72 768 Q 203.17 (2011-10-01 5)162.62 F 0 Cg EP %%Page: 6 6 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(descriptor)128 84 Q 2.5(,a)-.4 G 2.5(sd)-2.5 G(etermined by the v)-2.5 E(alue of $^F)-.25 E 5(.S)-.8 G(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv) -2.5 E(ar)-.25 E(.)-.55 E(alarm)108 100.8 Q/F1 9/Times-Roman@0 SF (SECONDS)2.5 E F0(alarm)108 112.8 Q .144(Arranges to ha)128 124.8 R .444 -.15(ve a)-.2 H F1(SIGALRM)2.794 E F0(deli)2.644 E -.15(ve)-.25 G .144 (red to this process after the speci\214ed number of w).15 F .144 (allclock seconds)-.1 F 2.265(has elapsed.)128 136.8 R(If)7.265 E F1 (SECONDS)4.765 E F0 2.265(is not speci\214ed, the v)4.765 F 2.265 (alue stored in)-.25 F/F2 10/Courier@0 SF($_)4.765 E F0 2.264 (is used. \(On some machines,)4.765 F(unfortunately)128 148.8 Q 3.411 (,t)-.65 G .912(he elapsed time may be up to one second less or more th\ an you speci\214ed because of)-3.411 F(ho)128 160.8 Q 2.5(ws)-.25 G (econds are counted, and process scheduling may delay the deli)-2.5 E -.15(ve)-.25 G(ry of the signal e).15 E -.15(ve)-.25 G 2.5(nf).15 G (urther)-2.5 E(.\))-.55 E .368(Only one timer may be counting at once.) 128 178.8 R .368(Each call disables the pre)5.368 F .368(vious timer) -.25 F 2.868(,a)-.4 G .367(nd an ar)-2.868 F .367(gument of)-.18 F F2(0) 2.867 E F0 1.064(may be supplied to cancel the pre)128 190.8 R 1.064 (vious timer without starting a ne)-.25 F 3.564(wo)-.25 G 3.564(ne. The) -3.564 F 1.064(returned v)3.564 F 1.065(alue is the)-.25 F (amount of time remaining on the pre)128 202.8 Q(vious timer)-.25 E(.) -.55 E -.15(Fo)128 220.8 S 3.844(rd).15 G 1.344 (elays of \214ner granularity than one second, the T)-3.844 F 1.344 (ime::HiRes module \(from)-.35 F F1(CP)3.844 E(AN)-.828 E F0 3.844(,a)C 1.343(nd starting)-3.844 F 1.802 (from Perl 5.8 part of the standard distrib)128 232.8 R 1.802 (ution\) pro)-.2 F(vides)-.15 E/F3 10/Times-Italic@0 SF(ualarm\(\))4.302 E F0 6.802(.Y)C 1.802(ou may also use Perl')-7.902 F 4.302(sf)-.55 G (our)-4.302 E(-)-.2 E(ar)128 244.8 Q .816(gument v)-.18 F .816 (ersion of)-.15 F F3(select\(\))3.316 E F0(lea)3.316 E .816 (ving the \214rst three ar)-.2 F .815 (guments unde\214ned, or you might be able to use)-.18 F(the)128 256.8 Q F2(syscall)2.5 E F0(interf)2.5 E(ace to access)-.1 E F3(setitimer)2.5 E F0(\(2\) if your system supports it. See perlf)1.666 E(aq8 for details.) -.1 E 2.253(It is usually a mistak)128 274.8 R 4.753(et)-.1 G 4.753(oi) -4.753 G(ntermix)-4.753 E F2(alarm)4.753 E F0(and)4.753 E F2(sleep)4.753 E F0 2.254(calls, because)4.753 F F2(sleep)4.754 E F0 2.254 (may be internally)4.754 F(implemented on your system with)128 286.8 Q F2(alarm)2.5 E F0(.)A .081(If you w)128 304.8 R .081(ant to use)-.1 F F2 (alarm)2.581 E F0 .081(to time out a system call you need to use an) 2.581 F F2(eval)2.581 E F0(/)A F2(die)A F0(pair)2.581 E 5.081(.Y)-.55 G .081(ou can')-6.181 F 2.58(tr)-.18 G(ely)-2.58 E .227 (on the alarm causing the system call to f)128 316.8 R .227(ail with)-.1 F F2($!)2.727 E F0 .227(set to)2.727 F F2(EINTR)2.727 E F0 .227 (because Perl sets up signal handlers)2.727 F .22 (to restart system calls on some systems.)128 328.8 R(Using)5.22 E F2 (eval)2.72 E F0(/)A F2(die)A F0(al)2.72 E -.1(wa)-.1 G .22(ys w).1 F .22 (orks, modulo the ca)-.1 F -.15(ve)-.2 G .22(ats gi).15 F -.15(ve)-.25 G 2.72(ni).15 G(n)-2.72 E -.74(``)128 340.8 S(Signals').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E F2(eval {)152 358.8 Q (local $SIG{ALRM} = sub { die "alarm\\n" }; # NB: \\n required)176 370.8 Q(alarm $timeout;)176 382.8 Q($nread = sysread SOCKET, $buffer, $size;) 176 394.8 Q(alarm 0;)176 406.8 Q(};)152 418.8 Q(if \($@\) {)152 430.8 Q (die unless $@ eq "alarm\\n";)176 442.8 Q 6(#p)18 G (ropagate unexpected errors)-6 E 6(#t)176 454.8 S(imed out)-6 E(})152 466.8 Q(else {)152 478.8 Q 6(#d)176 490.8 S(idn\010t)-6 E(})152 502.8 Q F0 -.15(Fo)128 520.8 S 2.5(rm).15 G(ore information see perlipc.)-2.5 E (atan2 Y)108 537.6 Q(,X)-1.29 E (Returns the arctangent of Y/X in the range \255PI to)128 549.6 Q F1(PI) 2.5 E F0(.)A -.15(Fo)128 567.6 S 5.176(rt).15 G 2.676 (he tangent operation, you may use the)-5.176 F F2(Math::Trig::tan)5.176 E F0 2.676(function, or use the f)5.176 F(amiliar)-.1 E(relation:)128 579.6 Q F2(sub tan { sin\($_[0]\) / cos\($_[0]\))152 597.6 Q(})12 E F0 1.447(The return v)128 615.6 R 1.447(alue for)-.25 F F2(atan2\(0,0\)) 3.947 E F0 1.447(is implementation-de\214ned; consult your)3.947 F F3 (atan2)3.946 E F0 1.446(\(3\) manpage for)1.666 F(more information.)128 627.6 Q(bind)108 644.4 Q F1(SOCKET)2.5 E F0(,N)A(AME)-.35 E 2.717 (Binds a netw)128 656.4 R 2.717(ork address to a sock)-.1 F 2.717 (et, just as)-.1 F F3(bind)5.217 E F0 2.717(\(2\) does.)1.666 F 2.717 (Returns true if it succeeded, f)7.717 F(alse)-.1 E(otherwise.)128 668.4 Q F1 -.315(NA)5.079 G(ME).315 E F0 .079(should be a pack)2.579 F .079 (ed address of the appropriate type for the sock)-.1 F 2.578(et. See)-.1 F .078(the e)2.578 F(xamples)-.15 E(in `)128 680.4 Q(`Sock)-.74 E (ets: Client/Serv)-.1 E(er Communication')-.15 E 2.5('i)-.74 G 2.5(np) -2.5 G(erlipc.)-2.5 E(binmode)108 697.2 Q F1(FILEHANDLE)2.5 E F0(,)A F1 (LA)2.5 E(YER)-.945 E F0(perl v5.14.2)72 768 Q 203.17(2011-10-01 6) 162.62 F 0 Cg EP %%Page: 7 7 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(binmode)108 84 Q /F1 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0 .992(Arranges for)128 96 R F1 (FILEHANDLE)3.492 E F0 .992(to be read or written in `)3.492 F(`binary') -.74 E 3.493('o)-.74 G 3.493(r`)-3.493 G(`te)-4.233 E(xt')-.15 E 3.493 ('m)-.74 G .993(ode on systems where the)-3.493 F 1.728 (run-time libraries distinguish between binary and te)128 108 R 1.728 (xt \214les.)-.15 F(If)6.728 E F1(FILEHANDLE)4.228 E F0 1.727(is an e) 4.228 F 1.727(xpression, the)-.15 F -.25(va)128 120 S .403(lue is tak) .25 F .403(en as the name of the \214lehandle.)-.1 F .404 (Returns true on success, otherwise it returns)5.404 F/F2 10/Courier@0 SF(undef)2.904 E F0(and)2.904 E(sets)128 132 Q F2($!)2.5 E F0 (\(errno\).)2.5 E .098(On some systems \(in general,)128 150 R F1 (DOS\255)2.597 E F0 .097(and W)2.597 F(indo)-.4 E .097 (ws-based systems\))-.25 F/F3 10/Times-Italic@0 SF(binmode\(\))2.597 E F0 .097(is necessary when you')2.597 F(re)-.5 E 1.914(not w)128 162 R 1.914(orking with a te)-.1 F 1.914(xt \214le.)-.15 F -.15(Fo)6.914 G 4.414(rt).15 G 1.914(he sak)-4.414 F 4.414(eo)-.1 G 4.414(fp)-4.414 G 1.914(ortability it is a good idea al)-4.414 F -.1(wa)-.1 G 1.914 (ys to use it when).1 F 1.598(appropriate, and ne)128 174 R -.15(ve)-.25 G 4.098(rt).15 G 4.098(ou)-4.098 G 1.598(se it when it isn')-4.098 F 4.098(ta)-.18 G 4.098(ppropriate. Also,)-4.098 F 1.597 (people can set their I/O to be by)4.098 F(def)128 186 Q (ault UTF8\255encoded Unicode, not bytes.)-.1 E(In other w)128 204 Q (ords: re)-.1 E -.05(ga)-.15 G(rdless of platform, use).05 E F3 (binmode\(\))2.5 E F0(on binary data, lik)2.5 E 2.5(ei)-.1 G (mages, for e)-2.5 E(xample.)-.15 E(If)128 222 Q F1(LA)3.371 E(YER)-.945 E F0 .871(is present it is a single string, b)3.371 F .872 (ut may contain multiple directi)-.2 F -.15(ve)-.25 G .872 (s. The directi).15 F -.15(ve)-.25 G 3.372(sa).15 G .872(lter the)-3.372 F(beha)128 234 Q(viour of the \214lehandle.)-.2 E(When)5 E F1(LA)2.5 E (YER)-.945 E F0(is present, using binmode on a te)2.5 E(xt \214le mak) -.15 E(es sense.)-.1 E(If)128 252 Q F1(LA)2.8 E(YER)-.945 E F0 .3 (is omitted or speci\214ed as)2.8 F F2(:raw)2.8 E F0 .3 (the \214lehandle is made suitable for passing binary data. This)2.8 F 2.602(includes turning of)128 264 R 5.103(fp)-.25 G(ossible)-5.103 E F1 (CRLF)5.103 E F0 2.603 (translation and marking it as bytes \(as opposed to Unicode)5.103 F 2.993(characters\). Note)128 276 R .493 (that, despite what may be implied in)2.993 F F3 -1.11(``)2.993 G(Pr) 1.11 E -.1(og)-.45 G -.15(ra).1 G .493(mming P).15 F(erl')-.8 E(')-1.11 E F0 .492(\(the Camel, 3rd edition\))2.993 F 1.253(or else)128 288 R (where,)-.25 E F2(:raw)3.753 E F0(is)3.753 E F3(not)3.753 E F0 1.253 (simply the in)3.753 F -.15(ve)-.4 G 1.253(rse of).15 F F2(:crlf)3.753 E F0 6.253(.O)C 1.253(ther layers that w)-6.253 F 1.253(ould af)-.1 F 1.254(fect the binary)-.25 F 1.89(nature of the stream are)128 300 R F3 (also)4.39 E F0 1.889 (disabled. See PerlIO, perlrun, and the discussion about the)4.389 F F1 (PERLIO)4.389 E F0(en)128 312 Q(vironment v)-.4 E(ariable.)-.25 E(The) 128 330 Q F2(:bytes)2.774 E F0(,)A F2(:crlf)2.774 E F0(,)A F2(:utf8) 2.774 E F0 2.774(,a)C .274(nd an)-2.774 F 2.774(yo)-.15 G .274 (ther directi)-2.774 F -.15(ve)-.25 G 2.774(so).15 G 2.774(ft)-2.774 G .274(he form)-2.774 F F2(:...)2.775 E F0 2.775(,a)C .275(re called I/O) -2.775 F F3(layer)2.775 E(s)-.1 E F0 5.275(.T)C(he)-5.275 E F2(open)128 342 Q F0(pragma can be used to establish def)2.5 E(ault I/O layers.)-.1 E(See open.)5 E F3(The)128 360 Q/F4 9/Times-Italic@0 SF(LA)2.647 E(YER) -.495 E F3(par)2.647 E .146 (ameter of the binmode\(\) function is described as `)-.15 F(`)-1.11 E F4(DISCIPLINE)A F3 2.366 -1.11('' i)D 2.646(n`)1.11 G(`Pr)-3.756 E -.1 (og)-.45 G -.15(ra).1 G .146(mming P).15 F(erl,)-.8 E(3r)128 372 Q 4.996 (dE)-.37 G(dition')-4.996 E 4.996('. Howe)-1.11 F(ver)-.15 E 4.996(,s) -1.11 G 2.497(ince the publishing of this book, by many known as `) -4.996 F(`Camel)-1.11 E F4(III)4.997 E F3 -1.11('')C 4.997(,t)1.11 G(he) -4.997 E 3.98(consensus of the naming of this functionality has mo)128 384 R 3.98(ved fr)-.1 F 3.98(om `)-.45 F(`discipline')-1.11 E 6.48('t) -1.11 G 6.48(o`)-6.48 G(`layer')-7.59 E 6.48('. All)-1.11 F .868 (documentation of this ver)128 396 R .868(sion of P)-.1 F .868(erl ther) -.8 F(efor)-.37 E 3.369(er)-.37 G(efer)-3.739 E 3.369(st)-.1 G 3.369(o`) -3.369 G(`layer)-4.479 E(s')-.1 E 3.369('r)-1.11 G .869(ather than to `) -3.519 F(`disciplines')-1.11 E 3.369('. Now)-1.11 F(bac)128 408 Q 2.5 (kt)-.2 G 2.5(ot)-2.5 G(he r)-2.5 E -.4(eg)-.37 G(ularly sc).4 E (heduled documentation...)-.15 E F0 1.971 -.8(To m)128 426 T(ark).8 E F1 (FILEHANDLE)2.871 E F0(as)2.871 E F1(UTF\2558)2.871 E F0 2.87(,u)C(se) -2.87 E F2(:utf8)2.87 E F0(or)2.87 E F2(:encoding\(UTF\2558\))2.87 E F0 (.)A F2(:utf8)5.37 E F0 .37(just marks the data)2.87 F(as)128 438 Q F1 (UTF\2558)3.406 E F0 .906(without further checking, while)3.406 F F2 (:encoding\(UTF\2558\))3.406 E F0 .906 (checks the data for actually being)3.406 F -.25(va)128 450 S(lid).25 E F1(UTF\2558)2.5 E F0 2.5(.M)C (ore details can be found in PerlIO::encoding.)-2.5 E 1.889(In general,) 128 468 R F3(binmode\(\))4.389 E F0 1.889(should be called after)4.389 F F3(open\(\))4.389 E F0 -.2(bu)4.389 G 4.389(tb).2 G 1.889(efore an) -4.389 F 4.389(yI)-.15 G 1.888(/O is done on the \214lehandle.)-4.389 F (Calling)128 480 Q F3(binmode\(\))2.597 E F0 .097(normally \215ushes an) 2.597 F 2.598(yp)-.15 G .098(ending b)-2.598 F(uf)-.2 E .098 (fered output data \(and perhaps pending input data\))-.25 F 2.055 (on the handle.)128 492 R 2.055(An e)7.055 F 2.055 (xception to this is the)-.15 F F2(:encoding)4.555 E F0 2.054 (layer that changes the def)4.555 F 2.054(ault character)-.1 F 1.062 (encoding of the handle; see `)128 504 R(`open')-.74 E 3.563('. The)-.74 F F2(:encoding)3.563 E F0 1.063 (layer sometimes needs to be called in mid-)3.563 F .947 (stream, and it doesn')128 516 R 3.447<748d>-.18 G .946(ush the stream.) -3.447 F(The)5.946 E F2(:encoding)3.446 E F0 .946 (also implicitly pushes on top of itself the)3.446 F F2(:utf8)128 528 Q F0(layer because internally Perl operates on UTF8\255encoded Unicode ch\ aracters.)2.5 E 1.772(The operating system, de)128 546 R 1.772(vice dri) -.25 F -.15(ve)-.25 G 1.773 (rs, C libraries, and Perl run-time system all conspire to let the).15 F .275(programmer treat a single character \()128 558 R F2(\\n)A F0 2.775 (\)a)C 2.775(st)-2.775 G .275(he line terminator)-2.775 F 2.774(,i)-.4 G (rrespecti)-2.774 E .574 -.15(ve o)-.25 H 2.774(fe).15 G .274 (xternal representation.)-2.924 F .42(On man)128 570 R 2.92(yo)-.15 G .42(perating systems, the nati)-2.92 F .72 -.15(ve t)-.25 H -.15(ex).15 G 2.92<748c>.15 G .42 (le representation matches the internal representation, b)-2.92 F(ut)-.2 E(on some platforms the e)128 582 Q(xternal representation of)-.15 E F2 (\\n)2.5 E F0(is made up of more than one character)2.5 E(.)-.55 E .068 (All v)128 600 R .068(ariants of Unix, Mac)-.25 F F1(OS)2.568 E F0 .068 (\(old and ne)2.568 F .068(w\), and Stream_LF \214les on)-.25 F F1(VMS) 2.567 E F0 .067(use a single character to end)2.567 F 2.454 (each line in the e)128 612 R 2.454(xternal representation of te)-.15 F 2.454(xt \(e)-.15 F -.15(ve)-.25 G 4.954(nt).15 G 2.455 (hough that single character is)-4.954 F F1(CARRIA)4.955 E(GE)-.36 E (RETURN)128 624 Q F0 .799(on old, pre-Darwin \215a)3.299 F -.2(vo)-.2 G .799(rs of Mac).2 F F1(OS)3.299 E F0 3.299(,a)C .799(nd is)-3.299 F F1 1.049(LINE FEED)3.299 F F0 .799(on Unix and most)3.299 F F1(VMS)3.299 E F0 .799(\214les\). In)3.299 F .813(other systems lik)128 636 R(e)-.1 E F1(OS/2)3.314 E F0(,)A F1(DOS)3.314 E F0 3.314(,a)C .814(nd the v)-3.314 F .814(arious \215a)-.25 F -.2(vo)-.2 G .814(rs of MS-W).2 F(indo)-.4 E .814(ws, your program sees a)-.25 F F2(\\n)3.314 E F0 .814(as a)3.314 F (simple)128 648 Q F2(\\cJ)3.621 E F0 3.621(,b)C 1.121(ut what')-3.821 F 3.621(ss)-.55 G 1.121(tored in te)-3.621 F 1.121(xt \214les are the tw) -.15 F 3.62(oc)-.1 G(haracters)-3.62 E F2(\\cM\\cJ)3.62 E F0 6.12(.T)C 1.12(hat means that if you)-6.12 F(don')128 660 Q 3.249(tu)-.18 G(se) -3.249 E F3(binmode\(\))3.249 E F0 .749(on these systems,)3.249 F F2 (\\cM\\cJ)3.249 E F0 .749(sequences on disk will be con)3.249 F -.15(ve) -.4 G .75(rted to).15 F F2(\\n)3.25 E F0 .75(on input,)3.25 F .358 (and an)128 672 R(y)-.15 E F2(\\n)2.858 E F0 .358 (in your program will be con)2.858 F -.15(ve)-.4 G .357(rted back to).15 F F2(\\cM\\cJ)2.857 E F0 .357(on output.)2.857 F .357 (This is what you w)5.357 F .357(ant for)-.1 F(te)128 684 Q (xt \214les, b)-.15 E(ut it can be disastrous for binary \214les.)-.2 E .274(Another consequence of using)128 702 R F3(binmode\(\))2.774 E F0 .274(\(on some systems\) is that special end-of-\214le mark)2.774 F .275 (ers will be)-.1 F .36(seen as part of the data stream.)128 714 R -.15 (Fo)5.36 G 2.86(rs).15 G .359(ystems from the Microsoft f)-2.86 F .359 (amily this means that, if your binary)-.1 F(data contain)128 726 Q F2 (\\cZ)2.5 E F0 2.5(,t)C(he I/O subsystem will re)-2.5 E -.05(ga)-.15 G (rd it as the end of the \214le, unless you use).05 E F3(binmode\(\))2.5 E F0(.)A(perl v5.14.2)72 768 Q 203.17(2011-10-01 7)162.62 F 0 Cg EP %%Page: 8 8 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10 /Times-Italic@0 SF(binmode\(\))128 84 Q F0 1.76 (is important not only for)4.26 F F1 -.37(re)4.261 G(adline\(\)).37 E F0 (and)4.261 E F1(print\(\))4.261 E F0 1.761(operations, b)4.261 F 1.761 (ut also when using)-.2 F F1 -.37(re)4.261 G(ad\(\)).37 E F0(,)A F1 (seek\(\))128 96 Q F0(,)A F1(sysr)3.115 E(ead\(\))-.37 E F0(,)A F1 (syswrite\(\))3.115 E F0(and)3.115 E F1(tell\(\))3.115 E F0 .614 (\(see perlport for more details\).)3.115 F .614(See the)5.614 F/F2 10 /Courier@0 SF($/)3.114 E F0(and)3.114 E F2($\\)3.114 E F0 -.25(va)3.114 G .614(riables in).25 F(perlv)128 108 Q(ar for ho)-.25 E 2.5(wt)-.25 G 2.5(om)-2.5 G (anually set your input and output line-termination sequences.)-2.5 E (bless)108 124.8 Q/F3 9/Times-Roman@0 SF(REF)2.5 E F0(,CLASSN)A(AME)-.35 E(bless)108 136.8 Q F3(REF)2.5 E F0 .453 (This function tells the thingy referenced by)128 148.8 R F3(REF)2.954 E F0 .454(that it is no)2.954 F 2.954(wa)-.25 G 2.954(no)-2.954 G .454 (bject in the)-2.954 F F3(CLASSN)2.954 E(AME)-.315 E F0(package.)2.954 E (If)128 160.8 Q F3(CLASSN)3.014 E(AME)-.315 E F0 .514 (is omitted, the current package is used.)3.014 F .514(Because a)5.514 F F2(bless)3.014 E F0 .514(is often the last thing in a)3.014 F (constructor)128 172.8 Q 4.963(,i)-.4 G 4.963(tr)-4.963 G 2.463 (eturns the reference for con)-4.963 F -.15(ve)-.4 G 4.963(nience. Al) .15 F -.1(wa)-.1 G 2.463(ys use the tw).1 F(o-ar)-.1 E 2.463(gument v) -.18 F 2.463(ersion if a)-.15 F(deri)128 184.8 Q -.15(ve)-.25 G 2.514 (dc).15 G .014(lass might inherit the function doing the blessing.) -2.514 F .013(See perltoot and perlobj for more about the)5.014 F (blessing \(and blessings\) of objects.)128 196.8 Q 2.775(Consider al) 128 214.8 R -.1(wa)-.1 G 2.775(ys blessing objects in CLASSN).1 F 2.775 (AMEs that are mix)-.35 F 2.775(ed case.)-.15 F 2.775 (Namespaces with all)7.775 F(lo)128 226.8 Q .733 (wercase names are considered reserv)-.25 F .733(ed for Perl pragmata.) -.15 F .733(Builtin types ha)5.733 F 1.033 -.15(ve a)-.2 H .733 (ll uppercase names.).15 F 4.962 -.8(To p)128 238.8 T(re).8 E -.15(ve) -.25 G 3.362(nt confusion, you may wish to a).15 F -.2(vo)-.2 G 3.362 (id such package names as well.).2 F(Mak)8.362 E 5.862(es)-.1 G 3.362 (ure that)-5.862 F F3(CLASSN)128 250.8 Q(AME)-.315 E F0(is a true v)2.5 E(alue.)-.25 E(See `)128 268.8 Q(`Perl Modules')-.74 E 2.5('i)-.74 G 2.5 (np)-2.5 G(erlmod.)-2.5 E(break)108 285.6 Q(Break out of a)128 297.6 Q F2(given\(\))2.5 E F0(block.)2.5 E 1.289(This k)128 315.6 R -.15(ey)-.1 G -.1(wo).15 G 1.289(rd is enabled by the).1 F F2("switch")3.789 E F0 1.288(feature: see feature for more information.)3.788 F(Alternately) 6.288 E(,)-.65 E(include a)128 327.6 Q F2(use v5.10)2.5 E F0 (or later to the current scope.)2.5 E(caller)108 344.4 Q F3(EXPR)2.5 E F0(caller)108 356.4 Q .308(Returns the conte)128 368.4 R .308 (xt of the current subroutine call.)-.15 F .308(In scalar conte)5.308 F .308(xt, returns the caller')-.15 F 2.808(sp)-.55 G .308(ackage name) -2.808 F 1.12(if there)128 380.4 R F1(is)3.62 E F0 3.62(ac)3.62 G 1.12 (aller \(that is, if we')-3.62 F 1.119(re in a subroutine or)-.5 F F2 (eval)3.619 E F0(or)3.619 E F2(require)3.619 E F0 3.619(\)a)C 1.119 (nd the unde\214ned v)-3.619 F(alue)-.25 E 2.5(otherwise. In)128 392.4 R (list conte)2.5 E(xt, returns)-.15 E F2 36 6(#0 1)152 410.4 T(2)54 E (\($package, $filename, $line\) = caller;)152 422.4 Q F0 -.4(Wi)128 440.4 S(th).4 E F3(EXPR)2.993 E F0 2.993(,i)C 2.994(tr)-2.993 G .494 (eturns some e)-2.994 F .494(xtra information that the deb)-.15 F .494 (ugger uses to print a stack trace.)-.2 F .494(The v)5.494 F(alue)-.25 E (of)128 452.4 Q F3(EXPR)2.5 E F0(indicates ho)2.5 E 2.5(wm)-.25 G(an) -2.5 E 2.5(yc)-.15 G(all frames to go back before the current one.)-2.5 E F2 24 12(#0 1)152 470.4 T -6 36(23 4)48 H (\($package, $filename, $line, $subroutine, $hasargs,)152 482.4 Q 30 12 (#5 6 7)152 506.4 T -36 42(89 1)60 H(0)-42 E ($wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash\))152 518.4 Q 6(=c)158 530.4 S(aller\($i\);)-6 E F0(Here)128 548.4 Q F2 ($subroutine)3.172 E F0 .672(may be)3.172 F F2(\(eval\))3.172 E F0 .672 (if the frame is not a subroutine call, b)3.172 F .671(ut an)-.2 F F2 (eval)3.171 E F0 5.671(.I)C 3.171(ns)-5.671 G .671(uch a)-3.171 F 1.845 (case additional elements)128 560.4 R F2($evaltext)4.346 E F0(and)4.346 E F2($is_require)4.346 E F0 1.846(are set:)4.346 F F2($is_require)4.346 E F0 1.846(is true if the)4.346 F .194(frame is created by a)128 572.4 R F2(require)2.693 E F0(or)2.693 E F2(use)2.693 E F0(statement,)2.693 E F2 ($evaltext)2.693 E F0 .193(contains the te)2.693 F .193(xt of the)-.15 F F2 .193(eval EXPR)2.693 F F0 6.976(statement. In)128 584.4 R(particular) 6.976 E 6.976(,f)-.4 G 4.476(or an)-6.976 F F2 4.476(eval BLOCK)6.976 F F0(statement,)6.976 E F2($subroutine)6.977 E F0(is)6.977 E F2(\(eval\)) 6.977 E F0 6.977(,b)C(ut)-7.177 E F2($evaltext)128 596.4 Q F0 .894 (is unde\214ned.)3.394 F .894(\(Note also that each)5.894 F F2(use)3.394 E F0 .893(statement creates a)3.394 F F2(require)3.393 E F0 .893 (frame inside an)3.393 F F2 .184(eval EXPR)128 608.4 R F0(frame.\))2.684 E F2($subroutine)5.184 E F0 .184(may also be)2.684 F F2(\(unknown\)) 2.684 E F0 .184(if this particular subroutine happens)2.684 F .194 (to ha)128 620.4 R .494 -.15(ve b)-.2 H .194 (een deleted from the symbol table.).15 F F2($hasargs)5.194 E F0 .194 (is true if a ne)2.694 F 2.694(wi)-.25 G .194(nstance of)-2.694 F F2(@_) 2.694 E F0 -.1(wa)2.694 G 2.694(ss).1 G .194(et up for)-2.694 F .622 (the frame.)128 632.4 R F2($hints)5.622 E F0(and)3.122 E F2($bitmask) 3.122 E F0 .622(contain pragmatic hints that the caller w)3.122 F .622 (as compiled with.)-.1 F(The)5.623 E F2($hints)128 644.4 Q F0(and)2.666 E F2($bitmask)2.666 E F0 -.25(va)2.666 G .166 (lues are subject to change between v).25 F .165 (ersions of Perl, and are not meant for)-.15 F -.15(ex)128 656.4 S (ternal use.).15 E F2($hinthash)128 674.4 Q F0 .875 (is a reference to a hash containing the v)3.375 F .875(alue of)-.25 F F2(%^H)3.375 E F0 .876(when the caller w)3.375 F .876(as compiled, or) -.1 F F2(undef)128 686.4 Q F0(if)3.007 E F2(%^H)3.007 E F0 -.1(wa)3.007 G 3.007(se).1 G(mpty)-3.007 E 3.007(.D)-.65 G 3.007(on)-3.007 G .506 (ot modify the v)-3.007 F .506(alues of this hash, as the)-.25 F 3.006 (ya)-.15 G .506(re the actual v)-3.006 F .506(alues stored)-.25 F (in the optree.)128 698.4 Q .088 (Furthermore, when called from within the)128 716.4 R F3(DB)2.588 E F0 .089(package, caller returns more detailed information: it sets)2.588 F (the list v)128 728.4 Q(ariable)-.25 E F2(@DB::args)2.5 E F0 (to be the ar)2.5 E(guments with which the subroutine w)-.18 E(as in)-.1 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E(perl v5.14.2)72 768 Q 203.17 (2011-10-01 8)162.62 F 0 Cg EP %%Page: 9 9 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .712(Be a)128 84 R -.1(wa)-.15 G .712(re that the optimizer might ha).1 F 1.012 -.15(ve o) -.2 H .712(ptimized call frames a).15 F -.1(wa)-.15 G 3.212(yb).1 G (efore)-3.212 E/F1 10/Courier@0 SF(caller)3.212 E F0 .711 (had a chance to)3.212 F .574(get the information.)128 96 R .574 (That means that)5.574 F F1(caller\(N\))3.074 E F0 .575 (might not return information about the call frame)3.074 F .992(you e) 128 108 R .992(xpect it to, for)-.15 F F1 6.991(N>1)3.491 G F0 5.991(.I) -6.991 G 3.491(np)-5.991 G(articular)-3.491 E(,)-.4 E F1(@DB::args)3.491 E F0 .991(might ha)3.491 F 1.291 -.15(ve i)-.2 H .991 (nformation from the pre).15 F(vious)-.25 E(time)128 120 Q F1(caller)2.5 E F0 -.1(wa)2.5 G 2.5(sc).1 G(alled.)-2.5 E .145(Be a)128 138 R -.1(wa) -.15 G .145(re that setting).1 F F1(@DB::args)2.645 E F0(is)2.645 E/F2 10/Times-Italic@0 SF .145(best ef)2.645 F(fort)-.18 E F0 2.645(,i)C .145 (ntended for deb)-2.645 F .145(ugging or generating backtraces, and)-.2 F .364(should not be relied upon. In particular)128 150 R 2.864(,a)-.4 G (s)-2.864 E F1(@_)2.864 E F0 .364(contains aliases to the caller')2.864 F 2.864(sa)-.55 G -.18(rg)-2.864 G .364(uments, Perl does not).18 F(tak) 128 162 Q 4.315(eac)-.1 G(op)-4.315 E 4.315(yo)-.1 G(f)-4.315 E F1(@_) 4.315 E F0 4.315(,s)C(o)-4.315 E F1(@DB::args)4.315 E F0 1.815 (will contain modi\214cations the subroutine mak)4.315 F 1.815(es to)-.1 F F1(@_)4.315 E F0 1.815(or its)4.315 F .64 (contents, not the original v)128 174 R .64(alues at call time.)-.25 F F1(@DB::args)3.14 E F0 3.14(,l)C(ik)-3.14 E(e)-.1 E F1(@_)3.14 E F0 3.14 (,d)C .64(oes not hold e)-3.14 F .64(xplicit references)-.15 F .865 (to its elements, so under certain cases its elements may ha)128 186 R 1.165 -.15(ve b)-.2 H .865(ecome freed and reallocated for other).15 F -.25(va)128 198 S .338(riables or temporary v).25 F .338(alues. Finally) -.25 F 2.838(,as)-.65 G .338(ide ef)-2.838 F .337 (fect of the current implementation is that the ef)-.25 F .337(fects of) -.25 F F1 .504(shift @_)128 210 R F0(can)3.004 E F2(normally)3.004 E F0 .504(be undone \(b)3.004 F .505(ut not)-.2 F F1 .505(pop @_)3.005 F F0 .505(or other splicing,)3.005 F F2(and)3.005 E F0 .505 (not if a reference to)3.005 F F1(@_)3.005 E F0 1.106(has been tak)128 222 R(en,)-.1 E F2(and)3.606 E F0 1.105(subject to the ca)3.606 F -.15 (ve)-.2 G 1.105(at about reallocated elements\), so).15 F F1(@DB::args) 3.605 E F0 1.105(is actually a)3.605 F -.05(hy)128 234 S (brid of the current state and initial state of).05 E F1(@_)2.5 E F0 2.5 (.B)C(uyer be)-2.5 E -.1(wa)-.25 G(re.).1 E(chdir)108 250.8 Q/F3 9 /Times-Roman@0 SF(EXPR)2.5 E F0(chdir)108 262.8 Q F3(FILEHANDLE)2.5 E F0 (chdir)108 274.8 Q F3(DIRHANDLE)2.5 E F0(chdir)108 286.8 Q 1.742 (Changes the w)128 298.8 R 1.742(orking directory to)-.1 F F3(EXPR)4.242 E F0 4.242(,i)C 4.242(fp)-4.242 G 1.742(ossible. If)-4.242 F F3(EXPR) 4.242 E F0 1.742(is omitted, changes to the directory)4.242 F 1.67 (speci\214ed by)128 310.8 R F1($ENV{HOME})4.17 E F0 4.17(,i)C 4.169(fs) -4.17 G 1.669(et; if not, changes to the directory speci\214ed by)-4.169 F F1($ENV{LOGDIR})4.169 E F0(.)A(\(Under)128 322.8 Q F3(VMS)2.752 E F0 2.752(,t)C .252(he v)-2.752 F(ariable)-.25 E F1($ENV{SYS$LOGIN})2.752 E F0 .253(is also check)2.753 F .253 (ed, and used if it is set.\) If neither is set,)-.1 F F1(chdir)128 334.8 Q F0(does nothing. It returns true on success, f)2.5 E (alse otherwise. See the e)-.1 E(xample under)-.15 E F1(die)2.5 E F0(.)A .236(On systems that support)128 352.8 R F2(fc)2.736 E(hdir)-.15 E F0 .236(\(2\), you may pass a \214lehandle or directory handle as the ar) 1.666 F 2.735(gument. On)-.18 F(systems that don')128 364.8 Q 2.5(ts) -.18 G(upport)-2.5 E F2(fc)2.5 E(hdir)-.15 E F0 (\(2\), passing handles raises an e)1.666 E(xception.)-.15 E(chmod)108 381.6 Q F3(LIST)2.5 E F0 1.3 (Changes the permissions of a list of \214les.)128 393.6 R 1.301 (The \214rst element of the list must be the numeric mode,)6.3 F .372 (which should probably be an octal number)128 405.6 R 2.872(,a)-.4 G .372(nd which de\214nitely should)-2.872 F F2(not)2.872 E F0 .371 (be a string of octal digits:)2.872 F F1(0644)128 417.6 Q F0 .395 (is okay)2.895 F 2.895(,b)-.65 G(ut)-3.095 E F1("0644")2.895 E F0 .395 (is not.)2.895 F .395 (Returns the number of \214les successfully changed.)5.395 F .395 (See also `)5.395 F(`oct')-.74 E(')-.74 E(if all you ha)128 429.6 Q .3 -.15(ve i)-.2 H 2.5(sas).15 G(tring.)-2.5 E F1 ($cnt = chmod 0755, "foo", "bar";)152 447.6 Q(chmod 0755, @executables;) 152 459.6 Q($mode = "0644"; chmod $mode, "foo";)152 471.6 Q 6(#!)36 G (!! sets mode to)-6 E 6<23ad>398 483.6 S-6 E ($mode = "0644"; chmod oct\($mode\), "foo"; # this is better)152 495.6 Q ($mode = 0644;)152 507.6 Q(chmod $mode, "foo";)18 E 6(#t)36 G (his is best)-6 E F0 .453(On systems that support)128 525.6 R F2(fc) 2.953 E(hmod)-.15 E F0 .453 (\(2\), you may pass \214lehandles among the \214les.)1.666 F .453 (On systems that don')5.453 F(t)-.18 E(support)128 537.6 Q F2(fc)3.663 E (hmod)-.15 E F0 1.163(\(2\), passing \214lehandles raises an e)1.666 F 3.663(xception. Filehandles)-.15 F 1.164(must be passed as globs or) 3.663 F(glob references to be recognized; bare)128 549.6 Q -.1(wo)-.25 G (rds are considered \214lenames.).1 E F1(open\(my $fh, "<", "foo"\);)152 567.6 Q(my $perm = \(stat $fh\)[2] & 07777;)152 579.6 Q (chmod\($perm | 0600, $fh\);)152 591.6 Q F0 -1.1(Yo)128 609.6 S 2.5(uc) 1.1 G(an also import the symbolic)-2.5 E F1(S_I*)2.5 E F0 (constants from the)2.5 E F1(Fcntl)2.5 E F0(module:)2.5 E F1 (use Fcntl qw\( :mode \);)152 627.6 Q (chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;)152 639.6 Q 6(#I)152 651.6 S(dentical to the chmod 0755 of the example above.)-6 E F0(chomp)108 668.4 Q F3 -1.215(VA)2.5 G(RIABLE)1.215 E F0(chomp\()108 680.4 Q F3(LIST)2.5 E F0(\))2.5 E(chomp)108 692.4 Q .811(This safer v) 128 704.4 R .811(ersion of `)-.15 F(`chop')-.74 E 3.311('r)-.74 G(emo) -3.311 E -.15(ve)-.15 G 3.311(sa).15 G 1.111 -.15(ny t)-3.311 H .81 (railing string that corresponds to the current v).15 F .81(alue of)-.25 F F1($/)3.31 E F0 2.504(\(also kno)128 716.4 R 2.504(wn as)-.25 F F1 ($INPUT_RECORD_SEPARATOR)5.004 E F0 2.504(in the)5.004 F F1(English) 5.005 E F0 5.005(module\). It)5.005 F 2.505(returns the total)5.005 F .507(number of characters remo)128 728.4 R -.15(ve)-.15 G 3.007(df).15 G .507(rom all its ar)-3.007 F 3.007(guments. It')-.18 F 3.007(so)-.55 G .507(ften used to remo)-3.007 F .807 -.15(ve t)-.15 H .507(he ne).15 F .506(wline from the)-.25 F(perl v5.14.2)72 768 Q 203.17(2011-10-01 9) 162.62 F 0 Cg EP %%Page: 10 10 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .255 (end of an input record when you')128 84 R .255(re w)-.5 F .255 (orried that the \214nal record may be missing its ne)-.1 F 2.755 (wline. When)-.25 F(in)2.755 E 1.062(paragraph mode \()128 96 R/F1 10 /Courier@0 SF 1.062($/ = "")B F0 1.062(\), it remo)B -.15(ve)-.15 G 3.562(sa).15 G 1.062(ll trailing ne)-3.562 F 1.062 (wlines from the string.)-.25 F 1.061(When in slurp mode)6.062 F(\()128 108 Q F1 .566($/ = undef)B F0 3.066(\)o)C 3.066<728c>-3.066 G -.15(xe) -3.066 G .566(d-length record mode \().15 F F1($/)A F0 .567 (is a reference to an inte)3.067 F .567(ger or the lik)-.15 F .567 (e; see perlv)-.1 F(ar\))-.25 E/F2 10/Times-Italic@0 SF -.15(ch)128 120 S(omp\(\)).15 E F0 -.1(wo)2.5 G(n').1 E 2.5(tr)-.18 G(emo)-2.5 E .3 -.15 (ve a)-.15 H -.15(ny).15 G 2.5(thing. If).15 F/F3 9/Times-Roman@0 SF -1.215(VA)2.5 G(RIABLE)1.215 E F0(is omitted, it chomps)2.5 E F1($_)2.5 E F0 5(.E)C(xample:)-5 E F1(while \(<>\) {)152 138 Q 6(chomp; #)176 150 R(avoid \\n on last field)6 E(@array = split\(/:/\);)176 162 Q 6(#.)176 174 S(..)-6 E(})152 186 Q F0(If)128 204 Q F3 -1.215(VA)2.5 G(RIABLE) 1.215 E F0(is a hash, it chomps the hash')2.5 E 2.5(sv)-.55 G(alues, b) -2.75 E(ut not its k)-.2 E -.15(ey)-.1 G(s.).15 E -1.1(Yo)128 222 S 2.5 (uc)1.1 G(an actually chomp an)-2.5 E(ything that')-.15 E 2.5(sa)-.55 G 2.5(nl)-2.5 G -.25(va)-2.5 G(lue, including an assignment:).25 E F1 (chomp\($cwd = \222pwd\222\);)152 240 Q(chomp\($answer = \);)152 252 Q F0(If you chomp a list, each element is chomped, and the total nu\ mber of characters remo)128 270 Q -.15(ve)-.15 G 2.5(di).15 G 2.5(sr) -2.5 G(eturned.)-2.5 E 1.622 (Note that parentheses are necessary when you')128 288 R 1.621 (re chomping an)-.5 F 1.621(ything that is not a simple v)-.15 F (ariable.)-.25 E .84(This is because)128 300 R F1 .84 (chomp $cwd = \222pwd\222;)3.34 F F0 .84(is interpreted as)3.34 F F1 .84 (\(chomp $cwd\) = \222pwd\222;)3.34 F F0 3.34(,r)C(ather)-3.34 E 1.765 (than as)128 312 R F1 1.765(chomp\( $cwd = \222pwd\222 \))4.265 F F0 1.765(which you might e)4.265 F 4.264(xpect. Similarly)-.15 F(,)-.65 E F1 1.764(chomp $a, $b)4.264 F F0(is)4.264 E(interpreted as)128 324 Q F1 (chomp\($a\), $b)2.5 E F0(rather than as)2.5 E F1(chomp\($a, $b\))2.5 E F0(.)A(chop)108 340.8 Q F3 -1.215(VA)2.5 G(RIABLE)1.215 E F0(chop\()108 352.8 Q F3(LIST)2.5 E F0(\))2.5 E(chop)108 364.8 Q .953(Chops of)128 376.8 R 3.453(ft)-.25 G .953 (he last character of a string and returns the character chopped.)-3.453 F .954(It is much more ef)5.954 F(\214cient)-.25 E(than)128 388.8 Q F1 (s/.$//s)3.1 E F0 .6(because it neither scans nor copies the string.)3.1 F(If)5.6 E F3 -1.215(VA)3.1 G(RIABLE)1.215 E F0 .6(is omitted, chops)3.1 F F1($_)3.1 E F0 5.6(.I)C(f)-5.6 E F3 -1.215(VA)128 400.8 S(RIABLE)1.215 E F0(is a hash, it chops the hash')2.5 E 2.5(sv)-.55 G(alues, b)-2.75 E (ut not its k)-.2 E -.15(ey)-.1 G(s.).15 E -1.1(Yo)128 418.8 S 2.5(uc) 1.1 G(an actually chop an)-2.5 E(ything that')-.15 E 2.5(sa)-.55 G 2.5 (nl)-2.5 G -.25(va)-2.5 G(lue, including an assignment.).25 E (If you chop a list, each element is chopped.)128 436.8 Q(Only the v)5 E (alue of the last)-.25 E F1(chop)2.5 E F0(is returned.)2.5 E 6.331 (Note that)128 454.8 R F1(chop)8.831 E F0 6.331 (returns the last character)8.831 F 11.331(.T)-.55 G 8.831(or)-12.131 G 6.332(eturn all b)-8.831 F 6.332(ut the last character)-.2 F 8.832(,u) -.4 G(se)-8.832 E F1(substr\($string, 0, \2551\))128 466.8 Q F0(.)A (See also `)128 484.8 Q(`chomp')-.74 E('.)-.74 E(cho)108 501.6 Q(wn)-.25 E F3(LIST)2.5 E F0 .148(Changes the o)128 513.6 R .148 (wner \(and group\) of a list of \214les.)-.25 F .147(The \214rst tw) 5.148 F 2.647(oe)-.1 G .147(lements of the list must be the)-2.647 F F2 (numeric)2.647 E F0 .307(uid and gid, in that order)128 525.6 R 5.307 (.A)-.55 G -.25(va)-2.5 G .308 (lue of \2551 in either position is interpreted by most systems to lea) .25 F .608 -.15(ve t)-.2 H(hat).15 E -.25(va)128 537.6 S(lue unchanged.) .25 E(Returns the number of \214les successfully changed.)5 E F1 ($cnt = chown $uid, $gid, \010foo\010, \010bar\010;)152 555.6 Q (chown $uid, $gid, @filenames;)152 567.6 Q F0 .49 (On systems that support)128 585.6 R F2(fc)2.99 E(hown)-.15 E F0 .49 (\(2\), you may pass \214lehandles among the \214les.)1.666 F .489 (On systems that don')5.489 F(t)-.18 E(support)128 597.6 Q F2(fc)3.705 E (hown)-.15 E F0 1.205(\(2\), passing \214lehandles raises an e)1.666 F 3.706(xception. Filehandles)-.15 F 1.206(must be passed as globs or) 3.706 F(glob references to be recognized; bare)128 609.6 Q -.1(wo)-.25 G (rds are considered \214lenames.).1 E(Here')128 627.6 Q 2.5(sa)-.55 G 2.5(ne)-2.5 G (xample that looks up nonnumeric uids in the passwd \214le:)-2.65 E F1 (print "User: ";)152 645.6 Q(chomp\($user = \);)152 657.6 Q (print "Files: ";)152 669.6 Q(chomp\($pattern = \);)152 681.6 Q (\($login,$pass,$uid,$gid\) = getpwnam\($user\))152 705.6 Q (or die "$user not in passwd file";)176 717.6 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 10)162.62 F 0 Cg EP %%Page: 11 11 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (@ary = glob\($pattern\);)152 84 Q 6(#e)12 G(xpand filenames)-6 E (chown $uid, $gid, @ary;)152 96 Q F0 .351 (On most systems, you are not allo)128 114 R .351(wed to change the o) -.25 F .35(wnership of the \214le unless you')-.25 F .35 (re the superuser)-.5 F(,)-.4 E 1.909 (although you should be able to change the group to an)128 126 R 4.41 (yo)-.15 G 4.41(fy)-4.41 G 1.91(our secondary groups.)-4.41 F 1.91 (On insecure)6.91 F .684(systems, these restrictions may be relax)128 138 R .684(ed, b)-.15 F .684(ut this is not a portable assumption.)-.2 F (On)5.684 E/F2 9/Times-Roman@0 SF(POSIX)3.184 E F0(systems,)3.183 E (you can detect this condition this w)128 150 Q(ay:)-.1 E F1 (use POSIX qw\(sysconf _PC_CHOWN_RESTRICTED\);)152 168 Q ($can_chown_giveaway = not sysconf\(_PC_CHOWN_RESTRICTED\);)152 180 Q F0 (chr)108 196.8 Q F2(NUMBER)2.5 E F0(chr)108 208.8 Q 1.146 (Returns the character represented by that)128 208.8 R F2(NUMBER)3.646 E F0 1.146(in the character set.)3.646 F -.15(Fo)6.147 G 3.647(re).15 G (xample,)-3.797 E F1(chr\(65\))3.647 E F0(is)3.647 E F1("A")128 220.8 Q F0(in either)2.5 E F2(ASCII)2.5 E F0 (or Unicode, and chr\(0x263a\) is a Unicode smile)2.5 E 2.5(yf)-.15 G (ace.)-2.6 E(Ne)128 238.8 Q -.05(ga)-.15 G(ti).05 E .557 -.15(ve v)-.25 H .257(alues gi)-.1 F .556 -.15(ve t)-.25 H .256 (he Unicode replacement character \().15 F/F3 10/Times-Italic@0 SF -.15 (ch)C(r).15 E F0(\(0xf)1.666 E -.25(ff)-.25 G .256(d\)\), e).25 F .256 (xcept under the bytes pragma,)-.15 F(where the lo)128 250.8 Q 2.5(we) -.25 G(ight bits of the v)-2.5 E(alue \(truncated to an inte)-.25 E (ger\) are used.)-.15 E(If)128 268.8 Q F2(NUMBER)2.5 E F0 (is omitted, uses)2.5 E F1($_)2.5 E F0(.)A -.15(Fo)128 286.8 S 2.5(rt) .15 G(he re)-2.5 E -.15(ve)-.25 G(rse, use `).15 E(`ord')-.74 E('.)-.74 E 1.035(Note that characters from 128 to 255 \(inclusi)128 304.8 R -.15 (ve)-.25 G 3.535(\)a).15 G 1.035(re by def)-3.535 F 1.035 (ault internally not encoded as)-.1 F F2(UTF\2558)3.536 E F0(for)3.536 E (backw)128 316.8 Q(ard compatibility reasons.)-.1 E (See perlunicode for more about Unicode.)128 334.8 Q(chroot)108 351.6 Q F2(FILEN)2.5 E(AME)-.315 E F0(chroot)108 363.6 Q .238(This function w) 128 375.6 R .238(orks lik)-.1 F 2.738(et)-.1 G .237 (he system call by the same name: it mak)-2.738 F .237 (es the named directory the ne)-.1 F 2.737(wr)-.25 G(oot)-2.737 E .294 (directory for all further pathnames that be)128 387.6 R .294 (gin with a)-.15 F F1(/)2.794 E F0 .294 (by your process and all its children.)2.794 F .294(\(It doesn')5.294 F (t)-.18 E 2.963(change your current w)128 399.6 R 2.963 (orking directory)-.1 F 5.462(,w)-.65 G 2.962(hich is unaf)-5.462 F 5.462(fected.\) F)-.25 F 2.962(or security reasons, this call is)-.15 F (restricted to the superuser)128 411.6 Q 5(.I)-.55 G(f)-5 E F2(FILEN)2.5 E(AME)-.315 E F0(is omitted, does a)2.5 E F1(chroot)2.5 E F0(to)2.5 E F1 ($_)2.5 E F0(.)A(close)108 428.4 Q F2(FILEHANDLE)2.5 E F0(close)108 440.4 Q .454(Closes the \214le or pipe associated with the \214lehandle\ , \215ushes the)128 452.4 R F2(IO)2.954 E F0 -.2(bu)2.954 G -.25(ff).2 G .454(ers, and closes the system \214le).25 F(descriptor)128 464.4 Q 5.546(.R)-.55 G .546 (eturns true if those operations succeed and if no error w)-5.546 F .545 (as reported by an)-.1 F 3.045(yP)-.15 G .545(erlIO layer)-3.045 F(.) -.55 E(Closes the currently selected \214lehandle if the ar)128 476.4 Q (gument is omitted.)-.18 E -1.1(Yo)128 494.4 S 2.618(ud)1.1 G(on')-2.618 E 2.618(th)-.18 G -2.25 -.2(av e)-2.618 H .119(to close)2.819 F F2 (FILEHANDLE)2.619 E F0 .119(if you are immediately going to do another) 2.619 F F1(open)2.619 E F0 .119(on it, because)2.619 F F1(open)128 506.4 Q F0 1.387(closes it for you.)3.888 F(\(See)6.387 E F1(open)3.887 E F0 3.887(.\) Ho)B(we)-.25 E -.15(ve)-.25 G 2.187 -.4(r, a).15 H 3.887(ne).4 G(xplicit)-4.037 E F1(close)3.887 E F0 1.387 (on an input \214le resets the line)3.887 F(counter \()128 518.4 Q F1 ($.)A F0(\), while the implicit close done by)A F1(open)2.5 E F0 (does not.)2.5 E 1.087(If the \214lehandle came from a piped open,)128 536.4 R F1(close)3.587 E F0 1.087(returns f)3.587 F 1.087 (alse if one of the other syscalls in)-.1 F -.2(vo)-.4 G(lv).2 E(ed)-.15 E -.1(fa)128 548.4 S .173(ils or if its program e).1 F .173 (xits with non-zero status.)-.15 F .173(If the only problem w)5.173 F .172(as that the program e)-.1 F .172(xited non-)-.15 F(zero,)128 560.4 Q F1($!)2.868 E F0 .368(will be set to)5.368 F F1(0)2.868 E F0 5.368(.C) C .368(losing a pipe also w)-5.368 F .369(aits for the process e)-.1 F -.15(xe)-.15 G .369(cuting on the pipe to e).15 F -.834(xit \212 in)-.15 F .141(case you wish to look at the output of the pipe afterw)128 572.4 R -.834(ards \212 and)-.1 F .141(implicitly puts the e)2.641 F .141 (xit status v)-.15 F .141(alue of)-.25 F(that command into)128 584.4 Q F1($?)2.5 E F0(and)2.5 E F1(${^CHILD_ERROR_NATIVE})2.5 E F0(.)A .875 (If there are multiple threads running,)128 602.4 R F1(close)3.375 E F0 .876(on a \214lehandle from a piped open returns true without)3.376 F -.1(wa)128 614.4 S(iting for the child process to terminate, if the \ \214lehandle is still open in another thread.).1 E .058(Closing the rea\ d end of a pipe before the process writing to it at the other end is do\ ne writing results in)128 632.4 R .823(the writer recei)128 644.4 R .823 (ving a)-.25 F F2(SIGPIPE)3.323 E F0 5.823(.I)C 3.323(ft)-5.823 G .823 (he other end can')-3.323 F 3.324(th)-.18 G .824 (andle that, be sure to read all the data before)-3.324 F (closing the pipe.)128 656.4 Q(Example:)128 674.4 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 11)162.62 F 0 Cg EP %%Page: 12 12 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (open\(OUTPUT, \010|sort >foo\010\))152 84 Q 6(#p)12 G(ipe to sort)-6 E (or die "Can\010t start sort: $!";)176 96 Q 138(#... #)152 108 R (print stuff to output)6 E(close OUTPUT)152 120 Q 6(#w)96 G (ait for sort to finish)-6 E(or warn $! ? "Error closing sort pipe: $!") 176 132 Q 6(:")242 144 S(Exit status $? from sort";)-6 E (open\(INPUT, \010foo\010\))152 156 Q 6(#g)60 G(et sort\010s results)-6 E(or die "Can\010t open \010foo\010 for input: $!";)176 168 Q/F2 9 /Times-Roman@0 SF(FILEHANDLE)128 186 Q F0 .145(may be an e)2.646 F .145 (xpression whose v)-.15 F .145 (alue can be used as an indirect \214lehandle, usually the real)-.25 F (\214lehandle name or an auto)128 198 Q(vi)-.15 E(vi\214ed handle.)-.25 E(closedir)108 214.8 Q F2(DIRHANDLE)2.5 E F0 (Closes a directory opened by)128 226.8 Q F1(opendir)2.5 E F0 (and returns the success of that system call.)2.5 E(connect)108 243.6 Q F2(SOCKET)2.5 E F0(,N)A(AME)-.35 E 2.102 (Attempts to connect to a remote sock)128 255.6 R 2.102(et, just lik)-.1 F(e)-.1 E/F3 10/Times-Italic@0 SF(connect)4.602 E F0 4.602 (\(2\). Returns)1.666 F 2.103(true if it succeeded, f)4.602 F(alse)-.1 E (otherwise.)128 267.6 Q F2 -.315(NA)5.079 G(ME).315 E F0 .079 (should be a pack)2.579 F .079 (ed address of the appropriate type for the sock)-.1 F 2.578(et. See)-.1 F .078(the e)2.578 F(xamples)-.15 E(in `)128 279.6 Q(`Sock)-.74 E (ets: Client/Serv)-.1 E(er Communication')-.15 E 2.5('i)-.74 G 2.5(np) -2.5 G(erlipc.)-2.5 E(continue)108 296.4 Q F2(BLOCK)2.5 E F0(continue) 108 308.4 Q F1(continue)128 320.4 Q F0 2.031(is actually a \215o)4.531 F 4.531(wc)-.25 G 2.031(ontrol statement rather than a function.)-4.531 F 2.032(If there is a)7.032 F F1(continue)4.532 E F2(BLOCK)128 332.4 Q F0 .858(attached to a)3.358 F F2(BLOCK)3.358 E F0 .858(\(typically in a) 3.358 F F1(while)3.357 E F0(or)3.357 E F1(foreach)3.357 E F0 .857 (\), it is al)B -.1(wa)-.1 G .857(ys e).1 F -.15(xe)-.15 G .857 (cuted just before).15 F .513(the conditional is about to be e)128 344.4 R -.25(va)-.25 G .514(luated ag).25 F .514(ain, just lik)-.05 F 3.014 (et)-.1 G .514(he third part of a)-3.014 F F1(for)3.014 E F0 .514 (loop in C.)3.014 F .514(Thus it can)5.514 F .513 (be used to increment a loop v)128 356.4 R .513(ariable, e)-.25 F -.15 (ve)-.25 G 3.013(nw).15 G .513(hen the loop has been continued via the) -3.013 F F1(next)3.013 E F0(statement)3.012 E (\(which is similar to the C)128 368.4 Q F1(continue)2.5 E F0 (statement\).)2.5 E F1(last)128 386.4 Q F0(,)A F1(next)2.555 E F0 2.555 (,o)C(r)-2.555 E F1(redo)2.555 E F0 .055(may appear within a)2.555 F F1 (continue)2.555 E F0(block;)2.555 E F1(last)2.555 E F0(and)2.555 E F1 (redo)2.555 E F0(beha)2.556 E .356 -.15(ve a)-.2 H 2.556(si).15 G 2.556 (ft)-2.556 G(he)-2.556 E 2.556(yh)-.15 G(ad)-2.556 E .621(been e)128 398.4 R -.15(xe)-.15 G .621(cuted within the main block.).15 F .621 (So will)5.621 F F1(next)3.121 E F0 3.121(,b)C .62(ut since it will e) -3.321 F -.15(xe)-.15 G .62(cute a).15 F F1(continue)3.12 E F0 .62 (block, it)3.12 F(may be more entertaining.)128 410.4 Q F1 (while \(EXPR\) {)152 428.4 Q(### redo always comes here)176 440.4 Q (do_something;)176 452.4 Q 6(}c)152 464.4 S(ontinue {)-6 E (### next always comes here)176 476.4 Q(do_something_else;)176 488.4 Q 6 (#t)176 500.4 S(hen back the top to re\255check EXPR)-6 E(})152 512.4 Q (### last always comes here)152 524.4 Q F0 .2(Omitting the)128 542.4 R F1(continue)2.7 E F0 .2(section is equi)2.7 F -.25(va)-.25 G .201 (lent to using an empty one, logically enough, so).25 F F1(next)2.701 E F0(goes)2.701 E (directly back to check the condition at the top of the loop.)128 554.4 Q .049(If the)128 572.4 R F1("switch")2.549 E F0 .048 (feature is enabled,)2.548 F F1(continue)2.548 E F0 .048 (is also a function that f)2.548 F .048(alls through the current)-.1 F F1(when)2.548 E F0(or)128 584.4 Q F1(default)4.658 E F0 2.158 (block instead of iterating a dynamically enclosing)4.658 F F1(foreach) 4.659 E F0 2.159(or e)4.659 F 2.159(xiting a le)-.15 F(xically)-.15 E (enclosing)128 596.4 Q F1(given)2.5 E F0 5(.S)C(ee feature and `)-5 E (`Switch statements')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlsyn for more information.)-2.5 E(cos)108 613.2 Q F2(EXPR)2.5 E F0 (cos)108 625.2 Q(Returns the cosine of)128 625.2 Q F2(EXPR)2.5 E F0(\(e) 2.5 E(xpressed in radians\).)-.15 E(If)5 E F2(EXPR)2.5 E F0 (is omitted, tak)2.5 E(es the cosine of)-.1 E F1($_)2.5 E F0(.)A -.15 (Fo)128 643.2 S 4.168(rt).15 G 1.668(he in)-4.168 F -.15(ve)-.4 G 1.668 (rse cosine operation, you may use the).15 F F1(Math::Trig::acos\(\)) 4.168 E F0 1.667(function, or use this)4.167 F(relation:)128 655.2 Q F1 (sub acos { atan2\( sqrt\(1 \255 $_[0] * $_[0]\), $_[0] \) })152 673.2 Q F0(crypt)108 690 Q F2(PLAINTEXT)2.5 E F0(,SAL)A(T)-.92 E .734 (Creates a digest string e)128 702 R .734(xactly lik)-.15 F 3.234(et)-.1 G(he)-3.234 E F3(crypt)3.234 E F0 .734 (\(3\) function in the C library \(assuming that you actually)1.666 F (ha)128 714 Q .3 -.15(ve a ve)-.2 H(rsion there that has not been e).15 E(xtirpated as a potential munition\).)-.15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 12)162.62 F 0 Cg EP %%Page: 13 13 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10 /Times-Italic@0 SF(crypt\(\))128 84 Q F0 .452(is a one-w)2.952 F .452 (ay hash function.)-.1 F(The)5.452 E/F2 9/Times-Roman@0 SF(PLAINTEXT) 2.952 E F0(and)2.952 E F2(SAL)2.952 E(T)-.828 E F0 .451 (are turned into a short string, called a)2.952 F 1.289 (digest, which is returned.)128 96 R 1.289(The same)6.289 F F2 (PLAINTEXT)3.789 E F0(and)3.789 E F2(SAL)3.789 E(T)-.828 E F0 1.289 (will al)3.789 F -.1(wa)-.1 G 1.289(ys return the same string, b).1 F (ut)-.2 E 2.612(there is no \(kno)128 108 R 2.612(wn\) w)-.25 F 2.612 (ay to get the original)-.1 F F2(PLAINTEXT)5.112 E F0 2.612 (from the hash.)5.112 F 2.611(Small changes in the)7.612 F F2(PLAINTEXT) 128 120 Q F0(or)2.5 E F2(SAL)2.5 E(T)-.828 E F0(will result in lar)2.5 E (ge changes in the digest.)-.18 E 1.167(There is no decrypt function.) 128 138 R 1.167(This function isn')6.167 F 3.667(ta)-.18 G 1.168 (ll that useful for cryptograph)-3.667 F 3.668(y\()-.05 G 1.168 (for that, look for)-3.668 F F1(Crypt)128 150 Q F0 .483 (modules on your nearby)2.984 F F2(CP)2.983 E(AN)-.828 E F0 .483 (mirror\) and the name `)2.983 F(`crypt')-.74 E 2.983('i)-.74 G 2.983 (sab)-2.983 G .483(it of a misnomer)-2.983 F 5.483(.I)-.55 G .483 (nstead it)-5.483 F .077(is primarily used to check if tw)128 162 R 2.577(op)-.1 G .077(ieces of te)-2.577 F .077 (xt are the same without ha)-.15 F .077 (ving to transmit or store the te)-.2 F(xt)-.15 E 3.385(itself. An)128 174 R -.15(ex)3.385 G .885(ample is checking if a correct passw).15 F .885(ord is gi)-.1 F -.15(ve)-.25 G 3.385(n. The).15 F .884 (digest of the passw)3.385 F .884(ord is stored,)-.1 F .393 (not the passw)128 186 R .393(ord itself.)-.1 F .394 (The user types in a passw)5.393 F .394(ord that is)-.1 F F1(crypt\(\)) 2.894 E F0 1.394 -.5('d w)D .394(ith the same salt as the stored).5 F 2.5(digest. If)128 198 R(the tw)2.5 E 2.5(od)-.1 G (igests match, the passw)-2.5 E(ord is correct.)-.1 E .314(When v)128 216 R .314(erifying an e)-.15 F .313 (xisting digest string you should use the digest as the salt \(lik)-.15 F(e)-.1 E/F3 10/Courier@0 SF(crypt\($plain,)2.813 E .259 ($digest\) eq $digest)128 228 R F0 2.76(\). The)B F2(SAL)2.76 E(T)-.828 E F0 .26(used to create the digest is visible as part of the digest.) 2.76 F(This)5.26 E(ensures)128 240 Q F1(crypt\(\))3.722 E F0 1.222 (will hash the ne)3.722 F 3.722(ws)-.25 G 1.222 (tring with the same salt as the digest.)-3.722 F 1.221(This allo)6.221 F 1.221(ws your code to)-.25 F -.1(wo)128 252 S .548 (rk with the standard crypt and with more e).1 F .548 (xotic implementations.)-.15 F .548(In other w)5.548 F .548 (ords, assume nothing)-.1 F (about the returned string itself nor about ho)128 264 Q 2.5(wm)-.25 G (an)-2.5 E 2.5(yb)-.15 G(ytes of)-2.5 E F2(SAL)2.5 E(T)-.828 E F0 (may matter)2.5 E(.)-.55 E -.35(Tr)128 282 S .15 (aditionally the result is a string of 13 bytes: tw).35 F 2.65<6f8c>-.1 G .15(rst bytes of the salt, follo)-2.65 F .15(wed by 11 bytes from the) -.25 F(set)128 294 Q F3([./0\2559A\255Za\255z])2.815 E F0 2.815(,a)C .315(nd only the \214rst eight bytes of)-2.815 F F2(PLAINTEXT)2.815 E F0 .316(mattered. But alternati)2.816 F .616 -.15(ve h)-.25 H(ashing).15 E 2.481(schemes \(lik)128 306 R(e)-.1 E F2(MD5)4.98 E F0 2.48 (\), higher le)B -.15(ve)-.25 G 4.98(ls).15 G 2.48 (ecurity schemes \(lik)-4.98 F 4.98(eC)-.1 G 2.48 (2\), and implementations on non-Unix)-4.98 F(platforms may produce dif) 128 318 Q(ferent strings.)-.25 E .848(When choosing a ne)128 336 R 3.348 (ws)-.25 G .849(alt create a random tw)-3.348 F 3.349(oc)-.1 G .849 (haracter string whose characters come from the set)-3.349 F F3 ([./0\2559A\255Za\255z])128 348 Q F0(\(lik)3.847 E(e)-.1 E F3 1.346(joi\ n \010\010, \(\010.\010, \010/\010, 0..9, \010A\010..\010Z\010, \010a\ \010..\010z\010\)[rand)3.847 F .332(64, rand 64])128 360 R F0 2.832 (\). This)B .333 (set of characters is just a recommendation; the characters allo)2.832 F .333(wed in the salt)-.25 F(depend solely on your system')128 372 Q 2.5 (sc)-.55 G(rypt library)-2.5 E 2.5(,a)-.65 G(nd Perl can')-2.5 E 2.5(tr) -.18 G(estrict what salts)-2.5 E F3(crypt\(\))2.5 E F0(accepts.)2.5 E (Here')128 390 Q 2.5(sa)-.55 G 2.5(ne)-2.5 G(xample that mak)-2.65 E (es sure that whoe)-.1 E -.15(ve)-.25 G 2.5(rr).15 G (uns this program kno)-2.5 E(ws their passw)-.25 E(ord:)-.1 E F3 ($pwd = \(getpwuid\($<\)\)[1];)152 408 Q(system "stty \255echo";)152 432 Q(print "Password: ";)152 444 Q(chomp\($word = \);)152 456 Q (print "\\n";)152 468 Q(system "stty echo";)152 480 Q (if \(crypt\($word, $pwd\) ne $pwd\) {)152 504 Q(die "Sorry...\\n";)176 516 Q 6(}e)152 528 S(lse {)-6 E(print "ok\\n";)176 540 Q(})152 552 Q F0 (Of course, typing in your o)128 570 Q(wn passw)-.25 E(ord to whoe)-.1 E -.15(ve)-.25 G 2.5(ra).15 G(sks you for it is unwise.)-2.5 E .437 (The crypt function is unsuitable for hashing lar)128 588 R .437 (ge quantities of data, not least of all because you can')-.18 F(t)-.18 E(get the information back.)128 600 Q (Look at the Digest module for more rob)5 E(ust algorithms.)-.2 E .121 (If using)128 618 R F1(crypt\(\))2.621 E F0 .121 (on a Unicode string \(which)2.621 F F1(potentially)2.621 E F0 .122 (has characters with codepoints abo)2.621 F .422 -.15(ve 2)-.15 H .122 (55\), Perl).15 F .615(tries to mak)128 630 R 3.115(es)-.1 G .614 (ense of the situation by trying to do)-3.115 F .614(wngrade \(a cop) -.25 F 3.114(yo)-.1 G .614(f\) the string back to an eight-bit)-3.114 F .764(byte string before calling)128 642 R F1(crypt\(\))3.264 E F0 .764 (\(on that cop)3.264 F 3.264(y\). If)-.1 F .764(that w)3.264 F .764 (orks, good.)-.1 F .764(If not,)5.764 F F1(crypt\(\))3.264 E F0 .765 (dies with)3.264 F F3(Wide)3.265 E(character in crypt)128 654 Q F0(.)A (dbmclose)108 670.8 Q F2(HASH)2.5 E F0([This function has been lar)128 682.8 Q(gely superseded by the)-.18 E F3(untie)2.5 E F0(function.])2.5 E (Breaks the binding between a)128 700.8 Q F2(DBM)2.5 E F0 (\214le and a hash.)2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 13) 162.62 F 0 Cg EP %%Page: 14 14 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(dbmopen)108 84 Q /F1 9/Times-Roman@0 SF(HASH)2.5 E F0(,DBN)A(AME,MASK)-.35 E ([This function has been lar)128 96 Q(gely superseded by the)-.18 E/F2 10/Courier@0 SF(tie)2.5 E F0(function.])2.5 E .558(This binds a)128 114 R/F3 10/Times-Italic@0 SF(dbm)3.058 E F0(\(3\),)1.666 E F3(ndbm)3.058 E F0(\(3\),)1.666 E F3(sdbm)3.058 E F0(\(3\),)1.666 E F3(gdbm)3.058 E F0 .558(\(3\), or Berk)1.666 F(ele)-.1 E(y)-.15 E F1(DB)3.057 E F0 .557 (\214le to a hash.)3.057 F F1(HASH)5.557 E F0 .557(is the name)3.057 F 1.22(of the hash.)128 126 R(\(Unlik)6.22 E 3.72(en)-.1 G(ormal)-3.72 E F2(open)3.72 E F0 3.72(,t)C 1.22(he \214rst ar)-3.72 F 1.221(gument is) -.18 F F3(not)3.721 E F0 3.721<618c>3.721 G 1.221(lehandle, e)-3.721 F -.15(ve)-.25 G 3.721(nt).15 G 1.221(hough it looks lik)-3.721 F(e)-.1 E (one\).)128 138 Q F1(DBN)5.211 E(AME)-.315 E F0 .211 (is the name of the database \(without the)2.711 F F3(.dir)2.71 E F0(or) 2.71 E F3(.pa)2.71 E(g)-.1 E F0 -.15(ex)2.71 G .21(tension if an).15 F 2.71(y\). If)-.15 F .21(the database)2.71 F .788(does not e)128 150 R .789(xist, it is created with protection speci\214ed by)-.15 F F1(MASK) 3.289 E F0 .789(\(as modi\214ed by the)3.289 F F2(umask)3.289 E F0 3.289 (\). If)B(your)3.289 E 2.234(system supports only the older)128 162 R F1 (DBM)4.734 E F0 2.234(functions, you may mak)4.734 F 4.734(eo)-.1 G 2.234(nly one)-4.734 F F2(dbmopen)4.734 E F0 2.233(call in your)4.734 F 4.09(program. In)128 174 R 1.59(older v)4.09 F 1.59 (ersions of Perl, if your system had neither)-.15 F F1(DBM)4.091 E F0 1.591(nor ndbm, calling)4.091 F F2(dbmopen)4.091 E F0(produced a f)128 186 Q(atal error; it no)-.1 E 2.5(wf)-.25 G(alls back to)-2.6 E F3(sdbm) 2.5 E F0(\(3\).)1.666 E .396(If you don')128 204 R 2.896(th)-.18 G -2.25 -.2(av e)-2.896 H .396(write access to the)3.096 F F1(DBM)2.896 E F0 .395(\214le, you can only read hash v)2.895 F .395 (ariables, not set them.)-.25 F .395(If you)5.395 F -.1(wa)128 216 S 1.019(nt to test whether you can write, either use \214le tests or try \ setting a dummy hash entry inside an).1 F F2(eval)128 228 Q F0 (to trap the error)2.5 E(.)-.55 E .624(Note that functions such as)128 246 R F2(keys)3.124 E F0(and)3.124 E F2(values)3.124 E F0 .624 (may return huge lists when used on lar)3.124 F(ge)-.18 E F1(DBM)3.124 E F0(\214les.)3.124 E -1.1(Yo)128 258 S 2.5(um)1.1 G(ay prefer to use the) -2.5 E F2(each)2.5 E F0(function to iterate o)2.5 E -.15(ve)-.15 G 2.5 (rl).15 G(ar)-2.5 E(ge)-.18 E F1(DBM)2.5 E F0 2.5(\214les. Example:)2.5 F F2 6(#p)152 276 S(rint out history file offsets)-6 E (dbmopen\(%HIST,\010/usr/lib/news/history\010,0666\);)152 288 Q (while \(\($key,$val\) = each %HIST\) {)152 300 Q (print $key, \010 = \010, unpack\(\010L\010,$val\), "\\n";)176 312 Q(}) 152 324 Q(dbmclose\(%HIST\);)152 336 Q F0 2.028(See also An)128 354 R 2.029 (yDBM_File for a more general description of the pros and cons of the v) -.15 F 2.029(arious dbm)-.25 F (approaches, as well as DB_File for a particularly rich implementation.) 128 366 Q -1.1(Yo)128 384 S 2.5(uc)1.1 G(an control which)-2.5 E F1(DBM) 2.5 E F0(library you use by loading that library before you call)2.5 E F3(dbmopen\(\))2.5 E F0(:)A F2(use DB_File;)152 402 Q (dbmopen\(%NS_Hist, "$ENV{HOME}/.netscape/history.db"\))152 414 Q (or die "Can\010t open netscape history file: $!";)176 426 Q F0(def)108 442.8 Q(ault)-.1 E F1(BLOCK)2.5 E F0 -.4(Wi)128 454.8 S 1.706(thin a).4 F F2(foreach)4.206 E F0 1.706(or a)4.206 F F2(given)4.206 E F0 4.206(,a) C F2(default)A F1(BLOCK)4.206 E F0 1.705(acts lik)4.206 F 4.205(ea)-.1 G F2(when)A F0(that')4.205 E 4.205(sa)-.55 G -.1(lwa)-4.205 G 1.705 (ys true.).1 F(Only)6.705 E -.2(av)128 466.8 S (ailable after Perl 5.10, and only if the)-.05 E F2(switch)2.5 E F0 (feature has been requested.)2.5 E(See `)5 E(`when')-.74 E('.)-.74 E (de\214ned)108 483.6 Q F1(EXPR)2.5 E F0(de\214ned)108 495.6 Q .578 (Returns a Boolean v)128 507.6 R .578(alue telling whether)-.25 F F1 (EXPR)3.078 E F0 .578(has a v)3.078 F .579 (alue other than the unde\214ned v)-.25 F(alue)-.25 E F2(undef)3.079 E F0 5.579(.I)C(f)-5.579 E F1(EXPR)128 519.6 Q F0(is not present,)2.5 E F2 ($_)2.5 E F0(is check)2.5 E(ed.)-.1 E(Man)128 537.6 Q 2.792(yo)-.15 G .292(perations return)-2.792 F F2(undef)2.792 E F0 .292(to indicate f) 2.792 F .291(ailure, end of \214le, system error)-.1 F 2.791(,u)-.4 G .291(ninitialized v)-2.791 F .291(ariable, and)-.25 F .91(other e)128 549.6 R .91(xceptional conditions.)-.15 F .911(This function allo)5.91 F .911(ws you to distinguish)-.25 F F2(undef)3.411 E F0 .911(from other v) 3.411 F 3.411(alues. \(A)-.25 F .147 (simple Boolean test will not distinguish among)128 561.6 R F2(undef) 2.647 E F0 2.647(,z)C .147(ero, the empty string, and)-2.647 F F2("0") 2.647 E F0 2.647(,w)C .146(hich are all)-2.647 F 1.126(equally f)128 573.6 R 3.626(alse.\) Note)-.1 F 1.126(that since)3.626 F F2(undef)3.626 E F0 1.127(is a v)3.627 F 1.127(alid scalar)-.25 F 3.627(,i)-.4 G 1.127 (ts presence doesn')-3.627 F(t)-.18 E F3(necessarily)3.627 E F0 1.127 (indicate an)3.627 F -.15(ex)128 585.6 S .373(ceptional condition:).15 F F2(pop)2.873 E F0(returns)2.873 E F2(undef)2.873 E F0 .373(when its ar) 2.873 F .373(gument is an empty array)-.18 F(,)-.65 E F3(or)2.872 E F0 .372(when the element)2.872 F(to return happens to be)128 597.6 Q F2 (undef)2.5 E F0(.)A -1.1(Yo)128 615.6 S 3.748(um)1.1 G 1.248 (ay also use)-3.748 F F2(defined\(&func\))3.748 E F0 1.248 (to check whether subroutine)3.748 F F2(&func)3.749 E F0 1.249(has e) 3.749 F -.15(ve)-.25 G 3.749(rb).15 G 1.249(een de\214ned.)-3.749 F .108 (The return v)128 627.6 R .108(alue is unaf)-.25 F .108(fected by an) -.25 F 2.608(yf)-.15 G(orw)-2.608 E .108(ard declarations of)-.1 F F2 (&func)2.607 E F0 5.107(.A)C .107(subroutine that is not de\214ned)-2.5 F .463(may still be callable: its package may ha)128 639.6 R .764 -.15 (ve a)-.2 H(n).15 E F2(AUTOLOAD)2.964 E F0 .464(method that mak)2.964 F .464(es it spring into e)-.1 F(xistence)-.15 E (the \214rst time that it is called; see perlsub)128 651.6 Q(.)-.4 E .484(Use of)128 669.6 R F2(defined)2.984 E F0 .484(on aggre)2.984 F -.05 (ga)-.15 G .483(tes \(hashes and arrays\) is deprecated.).05 F .483 (It used to report whether memory)5.483 F 1.203(for that aggre)128 681.6 R -.05(ga)-.15 G 1.203(te had e).05 F -.15(ve)-.25 G 3.703(rb).15 G 1.203(een allocated.)-3.703 F 1.203(This beha)6.203 F 1.204 (vior may disappear in future v)-.2 F 1.204(ersions of Perl.)-.15 F -1.1 (Yo)128 693.6 S 2.5(us)1.1 G(hould instead use a simple test for size:) -2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 14)162.62 F 0 Cg EP %%Page: 15 15 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (if \(@an_array\) { print "has array elements\\n" })152 84 Q (if \(%a_hash\))152 96 Q 6({p)18 G(rint "has hash members\\n")-6 E(})18 E F0 .625(When used on a hash element, it tells you whether the v)128 114 R .625(alue is de\214ned, not whether the k)-.25 F .924 -.15(ey ex) -.1 H .624(ists in).15 F(the hash.)128 126 Q(Use `)5 E(`e)-.74 E(xists') -.15 E 2.5('f)-.74 G(or the latter purpose.)-2.5 E(Examples:)128 144 Q F1(print if defined $switch{D};)152 162 Q (print "$val\\n" while defined\($val = pop\(@ary\)\);)152 174 Q (die "Can\010t readlink $sym: $!")152 186 Q (unless defined\($value = readlink $sym\);)176 198 Q (sub foo { defined &$bar ? &$bar\(@_\) : die "No bar"; })152 210 Q ($debugging = 0 unless defined $debugging;)152 222 Q F0 2.717(Note: Man) 128 240 R 2.717(yf)-.15 G .217(olks tend to o)-2.717 F -.15(ve)-.15 G (ruse).15 E F1(defined)2.717 E F0 .218(and are then surprised to disco) 2.718 F -.15(ve)-.15 G 2.718(rt).15 G .218(hat the number)-2.718 F F1(0) 2.718 E F0(and)2.718 E F1("")128 252 Q F0 (\(the zero-length string\) are, in f)2.5 E(act, de\214ned v)-.1 E 2.5 (alues. F)-.25 F(or e)-.15 E(xample, if you say)-.15 E F1 ("ab" =~ /a\(.*\)b/;)152 270 Q F0 .514(The pattern match succeeds and) 128 288 R F1($1)3.013 E F0 .513(is de\214ned, although it matched `) 3.013 F(`nothing')-.74 E 3.013('. It)-.74 F(didn')3.013 E 3.013(tr)-.18 G .513(eally f)-3.013 F .513(ail to)-.1 F .988(match an)128 300 R 3.488 (ything. Rather)-.15 F 3.488(,i)-.4 G 3.488(tm)-3.488 G .989 (atched something that happened to be zero characters long.)-3.488 F .989(This is all)5.989 F -.15(ve)128 312 S 1.11(ry abo).15 F -.15(ve) -.15 G 1.11(-board and honest.).15 F 1.11 (When a function returns an unde\214ned v)6.11 F 1.11(alue, it')-.25 F 3.61(sa)-.55 G 3.61(na)-3.61 G 1.11(dmission that it)-3.61 F(couldn')128 324 Q 2.605(tg)-.18 G -2.15 -.25(iv e)-2.605 H .105 (you an honest answer)2.855 F 5.105(.S)-.55 G 2.605(oy)-5.105 G .105 (ou should use)-2.605 F F1(defined)2.605 E F0 .106 (only when questioning the inte)2.606 F(grity)-.15 E(of what you')128 336 Q(re trying to do.)-.5 E(At other times, a simple comparison to)5 E F1(0)2.5 E F0(or)2.5 E F1("")2.5 E F0(is what you w)2.5 E(ant.)-.1 E (See also `)128 354 Q -1.95(`undef ')-.74 F(', `)-.74 E(`e)-.74 E (xists')-.15 E(', `)-.74 E -1.95(`ref ')-.74 F('.)-.74 E(delete)108 370.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0(Gi)128 382.8 Q -.15(ve)-.25 G 4.904(na).15 G 4.904(ne)-4.904 G 2.404 (xpression that speci\214es an element or slice of a hash,)-5.054 F F1 (delete)4.904 E F0 2.404(deletes the speci\214ed)4.904 F .312 (elements from that hash so that)128 394.8 R/F3 10/Times-Italic@0 SF -.2 (ex)2.812 G(ists\(\)).2 E F0 .312 (on that element no longer returns true.)2.812 F .313 (Setting a hash element)5.313 F(to the unde\214ned v)128 406.8 Q (alue does not remo)-.25 E .3 -.15(ve i)-.15 H(ts k).15 E -.15(ey)-.1 G 2.5(,b)-.5 G(ut deleting it does; see `)-2.7 E(`e)-.74 E(xists')-.15 E ('.)-.74 E 1.493(In list conte)128 424.8 R 1.493(xt, returns the v)-.15 F 1.493(alue or v)-.25 F 1.492 (alues deleted, or the last such element in scalar conte)-.25 F 3.992 (xt. The)-.15 F .262(return list')128 436.8 R 2.762(sl)-.55 G .263 (ength al)-2.762 F -.1(wa)-.1 G .263(ys matches that of the ar).1 F .263 (gument list: deleting non-e)-.18 F .263(xistent elements returns the) -.15 F(unde\214ned v)128 448.8 Q(alue in their corresponding positions.) -.25 E F3(delete\(\))128 466.8 Q F0 .213 (may also be used on arrays and array slices, b)2.714 F .213 (ut its beha)-.2 F .213(vior is less straightforw)-.2 F 2.713 (ard. Although)-.1 F F3 -.2(ex)128 478.8 S(ists\(\)).2 E F0 .706 (will return f)3.206 F .706 (alse for deleted entries, deleting array elements ne)-.1 F -.15(ve)-.25 G 3.207(rc).15 G .707(hanges indices of e)-3.207 F(xisting)-.15 E -.25 (va)128 490.8 S .584(lues; use).25 F F3(shift\(\))3.084 E F0(or)3.084 E F3(splice\(\))3.084 E F0 .584(for that.)3.084 F(Ho)5.584 E(we)-.25 E -.15(ve)-.25 G 1.384 -.4(r, i).15 H 3.084(fa).4 G .584 (ll deleted elements f)-3.084 F .583(all at the end of an array)-.1 F 3.083(,t)-.65 G(he)-3.083 E(array')128 502.8 Q 2.709(ss)-.55 G .209(ize\ shrinks to the position of the highest element that still tests true f\ or)-2.709 F F3 -.2(ex)2.709 G(ists\(\)).2 E F0 2.709(,o)C 2.709(rt) -2.709 G 2.709(o0i)-2.709 G 2.709(fn)-2.709 G(one)-2.709 E(do.)128 514.8 Q/F4 9/Times-Bold@0 SF -1.08(WA)128 532.8 S(RNING:)1.08 E F0 .011 (Calling delete on array v)2.512 F .011(alues is deprecated and lik)-.25 F .011(ely to be remo)-.1 F -.15(ve)-.15 G 2.511(di).15 G 2.511(naf) -2.511 G .011(uture v)-2.511 F .011(ersion of)-.15 F(Perl.)128 544.8 Q .947(Deleting from)128 562.8 R F1(%ENV)3.447 E F0 .947 (modi\214es the en)3.447 F 3.447(vironment. Deleting)-.4 F .947 (from a hash tied to a)3.447 F F2(DBM)3.448 E F0 .948 (\214le deletes the)3.448 F .47(entry from the)128 574.8 R F2(DBM)2.97 E F0 2.97(\214le. Deleting)2.97 F .47(from a)2.97 F F1(tied)2.97 E F0 .47 (hash or array may not necessarily return an)2.97 F .469(ything; it)-.15 F 1.092(depends on the implementation of the)128 586.8 R F1(tied)3.592 E F0(package')3.592 E(s)-.55 E F2(DELETE)3.592 E F0 1.092 (method, which may do whate)3.592 F -.15(ve)-.25 G 3.592(ri).15 G(t) -3.592 E(pleases.)128 598.8 Q(The)128 616.8 Q F1 .762(delete local EXPR) 3.262 F F0 .762 (construct localizes the deletion to the current block at run time.) 3.262 F(Until)5.762 E 1.99(the block e)128 628.8 R 1.991 (xits, elements locally deleted temporarily no longer e)-.15 F 4.491 (xist. See)-.15 F -.74(``)4.491 G 1.991(Localized deletion of).74 F (elements of composite types')128 640.8 Q 2.5('i)-.74 G 2.5(np)-2.5 G (erlsub)-2.5 E(.)-.4 E F1(%hash = \(foo => 11, bar => 22, baz => 33\);) 152 658.8 Q($scalar = delete $hash{foo};)152 670.8 Q 6(#$)78 G (scalar is 11)-6 E($scalar = delete @hash{qw\(foo bar\)};)152 682.8 Q 6 (#$)30 G(scalar is 22)-6 E 6(@array =)152 694.8 R (delete @hash{qw\(foo bar baz\)}; # @array)6 E(is \(undef,undef,33\))12 E F0(The follo)128 712.8 Q(wing \(inef)-.25 E (\214ciently\) deletes all the v)-.25 E(alues of)-.25 E F1(%HASH)2.5 E F0(and)2.5 E F1(@ARRAY:)2.5 E F0(perl v5.14.2)72 768 Q 198.17 (2011-10-01 15)162.62 F 0 Cg EP %%Page: 16 16 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (foreach $key \(keys %HASH\) {)152 84 Q(delete $HASH{$key};)176 96 Q(}) 152 108 Q(foreach $index \(0 .. $#ARRAY\) {)152 132 Q (delete $ARRAY[$index];)176 144 Q(})152 156 Q F0(And so do these:)128 174 Q F1(delete @HASH{keys %HASH};)152 192 Q (delete @ARRAY[0 .. $#ARRAY];)152 216 Q F0 1.59(But both are slo)128 234 R 1.589(wer than assigning the empty list or unde\214ning)-.25 F F1 (%HASH)4.089 E F0(or)4.089 E F1(@ARRAY)4.089 E F0 4.089(,w)C 1.589 (hich is the)-4.089 F(customary w)128 246 Q(ay to empty out an aggre)-.1 E -.05(ga)-.15 G(te:).05 E F1(%HASH = \(\);)152 264 Q 6(#c)30 G (ompletely empty %HASH)-6 E(undef %HASH;)152 276 Q 6(#f)24 G (orget %HASH ever existed)-6 E(@ARRAY = \(\);)152 300 Q 6(#c)24 G (ompletely empty @ARRAY)-6 E(undef @ARRAY;)152 312 Q 6(#f)18 G (orget @ARRAY ever existed)-6 E F0(The)128 330 Q/F2 9/Times-Roman@0 SF (EXPR)4.291 E F0 1.791(can be arbitrarily complicated pro)4.291 F 1.791 (vided its \214nal operation is an element or slice of an)-.15 F(aggre) 128 342 Q -.05(ga)-.15 G(te:).05 E F1(delete $ref\255>[$x][$y]{$key};) 152 360 Q(delete @{$ref\255>[$x][$y]}{$key1, $key2, @morekeys};)152 372 Q(delete $ref\255>[$x][$y][$index];)152 396 Q (delete @{$ref\255>[$x][$y]}[$index1, $index2, @moreindices];)152 408 Q F0(die)108 424.8 Q F2(LIST)2.5 E F1(die)128 436.8 Q F0 2.093 (raises an e)4.593 F 2.093(xception. Inside an)-.15 F F1(eval)4.593 E F0 2.092(the error message is stuf)4.592 F 2.092(fed into)-.25 F F1($@) 4.592 E F0 2.092(and the)4.592 F F1(eval)4.592 E F0(is)4.592 E 1.748 (terminated with the unde\214ned v)128 448.8 R 4.248(alue. If)-.25 F 1.748(the e)4.248 F 1.748(xception is outside of all enclosing)-.15 F F1 (eval)4.248 E F0 1.748(s, then the)B 1.078(uncaught e)128 460.8 R 1.078 (xception prints)-.15 F F2(LIST)3.577 E F0(to)3.577 E F1(STDERR)3.577 E F0 1.077(and e)3.577 F 1.077(xits with a non-zero v)-.15 F 1.077 (alue. If you need to e)-.25 F 1.077(xit the)-.15 F (process with a speci\214c e)128 472.8 Q(xit code, see `)-.15 E(`e)-.74 E(xit')-.15 E('.)-.74 E(Equi)128 490.8 Q -.25(va)-.25 G(lent e).25 E (xamples:)-.15 E F1(die "Can\010t cd to spool: $!\\n" unless chdir \010\ /usr/spool/news\010;)152 508.8 Q (chdir \010/usr/spool/news\010 or die "Can\010t cd to spool: $!\\n")152 520.8 Q F0 1.197(If the last element of)128 538.8 R F2(LIST)3.697 E F0 1.197(does not end in a ne)3.697 F 1.198 (wline, the current script line number and input line)-.25 F .756 (number \(if an)128 550.8 R .756(y\) are also printed, and a ne)-.15 F .755(wline is supplied.)-.25 F .755(Note that the `)5.755 F .755 (`input line number')-.74 F 3.255('\()-.74 G(also)-3.255 E(kno)128 562.8 Q .872(wn as `)-.25 F(`chunk')-.74 E .873('\) is subject to whate)-.74 F -.15(ve)-.25 G 3.373(rn).15 G .873(otion of `)-3.373 F(`line')-.74 E 3.373('h)-.74 G .873(appens to be currently in ef)-3.373 F .873 (fect, and is)-.25 F(also a)128 574.8 Q -.25(va)-.2 G (ilable as the special v).25 E(ariable)-.25 E F1($.)2.5 E F0 5(.S)C (ee `)-5 E(`$/')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar and `) -.25 E(`$.)-.74 E 1.48 -.74('' i)-.7 H 2.5(np).74 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E .484(Hint: sometimes appending)128 592.8 R F1 .484 (", stopped")2.984 F F0 .483(to your message will cause it to mak)2.984 F 2.983(eb)-.1 G .483(etter sense when)-2.983 F(the string)128 604.8 Q F1("at foo line 123")2.5 E F0(is appended.)2.5 E (Suppose you are running script `)5 E(`canasta')-.74 E('.)-.74 E F1 (die "/etc/games is no good";)152 622.8 Q (die "/etc/games is no good, stopped";)152 634.8 Q F0(produce, respecti) 128 652.8 Q -.15(ve)-.25 G(ly).15 E F1 (/etc/games is no good at canasta line 123.)152 670.8 Q (/etc/games is no good, stopped at canasta line 123.)152 682.8 Q F0 .937 (If the output is empty and)128 700.8 R F1($@)3.437 E F0 .937 (already contains a v)3.437 F .937(alue \(typically from a pre)-.25 F .938(vious e)-.25 F -.25(va)-.25 G .938(l\) that v).25 F .938(alue is) -.25 F(reused after appending)128 712.8 Q F1("\\t...propagated")2.5 E F0 5(.T)C(his is useful for propag)-5 E(ating e)-.05 E(xceptions:)-.15 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 16)162.62 F 0 Cg EP %%Page: 17 17 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (eval { ... };)152 84 Q(die unless $@ =~ /Expected exception/;)152 96 Q F0 1.924(If the output is empty and)128 114 R F1($@)4.424 E F0 1.924 (contains an object reference that has a)4.424 F F1(PROPAGATE)4.423 E F0 1.923(method, that)4.423 F .692(method will be called with additional \ \214le and line number parameters.)128 126 R .692(The return v)5.692 F .692(alue replaces the)-.25 F -.25(va)128 138 S .368(lue in).25 F F1($@) 2.868 E F0 5.368(;i)C .368(.e., as if)-5.368 F F1 .367 ($@ = eval { $@\255>PROPAGATE\(_)2.867 F -4.334(_FILE_ _,)1.666 F 1.666 (__)6.367 G -4.334(LINE_ _\))-1.666 F(};)6.367 E F0(were)2.867 E (called.)128 150 Q(If)128 168 Q F1($@)2.5 E F0(is empty then the string) 2.5 E F1("Died")2.5 E F0(is used.)2.5 E .601(If an uncaught e)128 186 R .601(xception results in interpreter e)-.15 F .601(xit, the e)-.15 F .601(xit code is determined from the v)-.15 F .602(alues of)-.25 F F1 ($!)3.102 E F0(and)128 198 Q F1($?)2.5 E F0(with this pseudocode:)2.5 E F1(exit $! if $!;)152 216 Q 6(#e)84 G(rrno)-6 E (exit $? >> 8 if $? >> 8;)152 228 Q 6(#c)24 G(hild exit status)-6 E (exit 255;)152 240 Q 6(#l)114 G(ast resort)-6 E F0 .502 (The intent is to squeeze as much possible information about the lik)128 258 R .501(ely cause into the limited space of)-.1 F .249(the system e) 128 270 R .249(xit code. Ho)-.15 F(we)-.25 E -.15(ve)-.25 G 1.049 -.4 (r, a).15 H(s).4 E F1($!)2.749 E F0 .249(is the v)2.749 F .249 (alue of C')-.25 F(s)-.55 E F1(errno)2.75 E F0 2.75(,w)C .25 (hich can be set by an)-2.75 F 2.75(ys)-.15 G .25(ystem call,)-2.75 F .323(this means that the v)128 282 R .323(alue of the e)-.25 F .323 (xit code used by)-.15 F F1(die)2.823 E F0 .322 (can be non-predictable, so should not be relied)2.823 F (upon, other than to be non-zero.)128 294 Q -1.1(Yo)128 312 S 3.081(uc) 1.1 G .581(an also call)-3.081 F F1(die)3.081 E F0 .581 (with a reference ar)3.081 F .581 (gument, and if this is trapped within an)-.18 F F1(eval)3.081 E F0(,)A F1($@)3.082 E F0(contains)3.082 E .973(that reference.)128 324 R .973 (This permits more elaborate e)5.973 F .972 (xception handling using objects that maintain arbitrary)-.15 F .335 (state about the e)128 336 R 2.835(xception. Such)-.15 F 2.835(as)2.835 G .335(cheme is sometimes preferable to matching particular string v) -2.835 F(alues)-.25 E(of)128 348 Q F1($@)2.788 E F0 .288(with re)2.788 F .288(gular e)-.15 F 2.788(xpressions. Because)-.15 F F1($@)2.788 E F0 .288(is a global v)2.788 F .288(ariable and)-.25 F F1(eval)2.787 E F0 .287(may be used within object)2.787 F .58 (implementations, be careful that analyzing the error object doesn')128 360 R 3.08(tr)-.18 G .58(eplace the reference in the global)-3.08 F -.25 (va)128 372 S 4.551(riable. It').25 F 4.551(se)-.55 G 2.051 (asiest to mak)-4.551 F 4.551(eal)-.1 G 2.051(ocal cop)-4.551 F 4.551 (yo)-.1 G 4.551(ft)-4.551 G 2.05(he reference before an)-4.551 F 4.55 (ym)-.15 G 4.55(anipulations. Here')-4.55 F 4.55(sa)-.55 G(n)-4.55 E -.15(ex)128 384 S(ample:).15 E F1(use Scalar::Util "blessed";)152 402 Q (eval { ... ; die Some::Module::Exception\255>new\( FOO => "bar" \) };) 152 426 Q(if \(my $ev_err = $@\) {)152 438 Q(if \(blessed\($ev_err\) &&\ $ev_err\255>isa\("Some::Module::Exception"\)\) {)176 450 Q 6(#h)200 462 S(andle Some::Module::Exception)-6 E(})176 474 Q(else {)176 486 Q 6(#h) 200 498 S(andle all other possible exceptions)-6 E(})176 510 Q(})152 522 Q F0 .21(Because Perl stringi\214es uncaught e)128 540 R .211 (xception messages before display)-.15 F 2.711(,y)-.65 G(ou')-2.711 E .211(ll probably w)-.1 F .211(ant to o)-.1 F -.15(ve)-.15 G(rload).15 E (stringi\214cation operations on e)128 552 Q(xception objects.)-.15 E (See o)5 E -.15(ve)-.15 G(rload for details about that.).15 E -1.1(Yo) 128 570 S 5.767(uc)1.1 G 3.266 (an arrange for a callback to be run just before the)-5.767 F F1(die) 5.766 E F0 3.266(does its deed, by setting the)5.766 F F1 -4.334 ($SIG{_ _DIE_ _})128 582 R F0 3.952(hook. The)3.952 F 1.453 (associated handler is called with the error te)3.952 F 1.453 (xt and can change the)-.15 F .288 (error message, if it sees \214t, by calling)128 594 R F1(die)2.788 E F0 (ag)2.788 E 2.788(ain. See)-.05 F -.74(``)2.788 G(%SIG').74 E 2.788('i) -.74 G 2.788(np)-2.788 G(erlv)-2.788 E .287(ar for details on setting) -.25 F F1(%SIG)2.787 E F0 .394(entries, and `)128 606 R(`e)-.74 E -.25 (va)-.25 G(l).25 E/F2 9/Times-Roman@0 SF(BLOCK)2.894 E F0 1.874 -.74 ('' f)D .394(or some e).74 F 2.894(xamples. Although)-.15 F .394 (this feature w)2.894 F .395(as to be run only right before)-.1 F 1.323 (your program w)128 618 R 1.323(as to e)-.1 F 1.323 (xit, this is not currently so: the)-.15 F F1 -4.334($SIG{_ _DIE_ _}) 3.822 F F0 1.322(hook is currently called)3.822 F -2.15 -.25(ev e)128 630 T 2.5(ni).25 G(nside)-2.5 E/F3 10/Times-Italic@0 SF -.15(ev)2.5 G (al\(\)).15 E F0(ed blocks/strings!)A(If one w)5 E (ants the hook to do nothing in such situations, put)-.1 E F1 (die @_ if $^S;)152 648 Q F0 1.874 (as the \214rst line of the handler \(see `)128 666 R(`$^S')-.74 E 4.375 ('i)-.74 G 4.375(np)-4.375 G(erlv)-4.375 E 4.375(ar\). Because)-.25 F 1.875(this promotes strange action at a)4.375 F (distance, this counterintuiti)128 678 Q .3 -.15(ve b)-.25 H(eha).15 E (vior may be \214x)-.2 E(ed in a future release.)-.15 E(See also)128 696 Q F3 -.2(ex)2.5 G(it\(\)).2 E F0(,)A F3(warn\(\))2.5 E F0 2.5(,a)C (nd the Carp module.)-2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 17) 162.62 F 0 Cg EP %%Page: 18 18 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(do)108 84 Q/F1 9 /Times-Roman@0 SF(BLOCK)2.5 E F0 .492(Not really a function.)128 96 R .492(Returns the v)5.492 F .492 (alue of the last command in the sequence of commands indicated)-.25 F (by)128 108 Q F1(BLOCK)2.764 E F0 5.264(.W)C .264(hen modi\214ed by the) -5.264 F/F2 10/Courier@0 SF(while)2.764 E F0(or)2.764 E F2(until)2.765 E F0 .265(loop modi\214er)2.765 F 2.765(,e)-.4 G -.15(xe)-2.915 G .265 (cutes the).15 F F1(BLOCK)2.765 E F0 .265(once before)2.765 F(testing t\ he loop condition. \(On other statements the loop modi\214ers test the \ conditional \214rst.\))128 120 Q F2 .237(do BLOCK)128 138 R F0(does) 2.737 E/F3 10/Times-Italic@0 SF(not)2.736 E F0 .236 (count as a loop, so the loop control statements)2.736 F F2(next)2.736 E F0(,)A F2(last)2.736 E F0 2.736(,o)C(r)-2.736 E F2(redo)2.736 E F0 .236 (cannot be)2.736 F(used to lea)128 150 Q .3 -.15(ve o)-.2 H 2.5(rr).15 G (estart the block.)-2.5 E(See perlsyn for alternati)5 E .3 -.15(ve s) -.25 H(trate).15 E(gies.)-.15 E(do)108 166.8 Q F1(SUBR)2.5 E(OUTINE)-.36 E F0(\()A F1(LIST)A F0(\))A 1.125 (This form of subroutine call is deprecated.)128 178.8 R F1(SUBR)6.126 E (OUTINE)-.36 E F0 1.126(can be a bare)3.626 F -.1(wo)-.25 G 1.126 (rd, a scalar v).1 F 1.126(ariable or a)-.25 F(subroutine be)128 190.8 Q (ginning with)-.15 E F2(&)2.5 E F0(.)A(do)108 207.6 Q F1(EXPR)2.5 E F0 (Uses the v)128 219.6 Q(alue of)-.25 E F1(EXPR)2.5 E F0 (as a \214lename and e)2.5 E -.15(xe)-.15 G (cutes the contents of the \214le as a Perl script.).15 E F2 (do \010stat.pl\010;)152 237.6 Q F0(is just lik)128 255.6 Q(e)-.1 E F2 (eval \222cat stat.pl\222;)152 273.6 Q F0 -.15(ex)128 291.6 S 1.6 (cept that it').15 F 4.1(sm)-.55 G 1.6(ore ef)-4.1 F 1.599 (\214cient and concise, k)-.25 F 1.599 (eeps track of the current \214lename for error messages,)-.1 F 1.193 (searches the)128 303.6 R F2(@INC)3.693 E F0 1.193 (directories, and updates)3.693 F F2(%INC)3.694 E F0 1.194 (if the \214le is found.)3.694 F 1.194(See `)6.194 F(`@INC')-.74 E 3.694 ('i)-.74 G 3.694(np)-3.694 G(erlv)-3.694 E 1.194(ar and)-.25 F -.74(``) 128 315.6 S(%INC').74 E 3.792('i)-.74 G 3.792(np)-3.792 G(erlv)-3.792 E 1.292(ar for these v)-.25 F 3.791(ariables. It)-.25 F 1.291(also dif) 3.791 F 1.291(fers in that code e)-.25 F -.25(va)-.25 G 1.291 (luated with).25 F F2 1.291(do FILENAME)3.791 F F0 1.199(cannot see le) 128 327.6 R 1.199(xicals in the enclosing scope;)-.15 F F2 1.199 (eval STRING)3.699 F F0 3.699(does. It')3.699 F 3.7(st)-.55 G 1.2 (he same, ho)-3.7 F(we)-.25 E -.15(ve)-.25 G 2 -.4(r, i).15 H 3.7(nt).4 G 1.2(hat it)-3.7 F(does reparse the \214le e)128 339.6 Q -.15(ve)-.25 G (ry time you call it, so you probably don').15 E 2.5(tw)-.18 G (ant to do this inside a loop.)-2.6 E(If)128 357.6 Q F2(do)2.799 E F0 .299(can read the \214le b)2.799 F .299 (ut cannot compile it, it returns)-.2 F F2(undef)2.799 E F0 .298 (and sets an error message in)2.798 F F2($@)2.798 E F0 5.298(.I)C(f) -5.298 E F2(do)2.798 E F0 .798 (cannot read the \214le, it returns undef and sets)128 369.6 R F2($!) 3.298 E F0 .798(to the error)3.298 F 5.799(.A)-.55 G -.1(lwa)-5.799 G .799(ys check).1 F F2($@)3.299 E F0 .799(\214rst, as compilation)3.299 F .689(could f)128 381.6 R .689(ail in a w)-.1 F .689(ay that also sets) -.1 F F2($!)3.189 E F0 5.689(.I)C 3.189(ft)-5.689 G .689 (he \214le is successfully compiled,)-3.189 F F2(do)3.189 E F0 .689 (returns the v)3.189 F .689(alue of the)-.25 F(last e)128 393.6 Q (xpression e)-.15 E -.25(va)-.25 G(luated.).25 E 1.654 (Inclusion of library modules is better done with the)128 411.6 R F2 (use)4.155 E F0(and)4.155 E F2(require)4.155 E F0 1.655 (operators, which also do)4.155 F (automatic error checking and raise an e)128 423.6 Q(xception if there') -.15 E 2.5(sap)-.55 G(roblem.)-2.5 E -1.1(Yo)128 441.6 S 2.972(um)1.1 G .472(ight lik)-2.972 F 2.972(et)-.1 G 2.972(ou)-2.972 G(se)-2.972 E F2 (do)2.972 E F0 .472(to read in a program con\214guration \214le.)2.972 F .471(Manual error checking can be done)5.471 F(this w)128 453.6 Q(ay:) -.1 E F2 6(#r)152 471.6 S(ead in config files: system first, then user) -6 E(for $file \("/share/prog/defaults.rc",)152 483.6 Q ("$ENV{HOME}/.someprogrc"\))218 495.6 Q({)152 507.6 Q (unless \($return = do $file\) {)176 519.6 Q (warn "couldn\010t parse $file: $@" if $@;)200 531.6 Q (warn "couldn\010t do $file: $!")200 543.6 Q(unless defined $return;)24 E(warn "couldn\010t run $file")200 555.6 Q(unless $return;)42 E(})176 567.6 Q(})152 579.6 Q F0(dump)108 596.4 Q F1(LABEL)2.5 E F0(dump)108 608.4 Q 1.862(This function causes an immediate core dump.)128 620.4 R 1.862(See also the)6.862 F/F4 10/Times-Bold@0 SF4.362 E F0 1.863 (command-line switch in perlrun,)4.362 F .462 (which does the same thing.)128 632.4 R .461 (Primarily this is so that you can use the)5.461 F F4(undump)2.961 E F0 .461(program \(not supplied\))2.961 F 1.738 (to turn your core dump into an e)128 644.4 R -.15(xe)-.15 G 1.739 (cutable binary after ha).15 F 1.739(ving initialized all your v)-.2 F 1.739(ariables at the)-.25 F(be)128 656.4 Q 2.034 (ginning of the program.)-.15 F 2.034(When the ne)7.034 F 4.534(wb)-.25 G 2.034(inary is e)-4.534 F -.15(xe)-.15 G 2.034(cuted it will be).15 F 2.033(gin by e)-.15 F -.15(xe)-.15 G 2.033(cuting a).15 F F2(goto)4.533 E(LABEL)128 668.4 Q F0 1.134(\(with all the restrictions that)3.634 F F2 (goto)3.634 E F0(suf)3.634 E 3.634(fers\). Think)-.25 F 1.134 (of it as a goto with an interv)3.634 F 1.135(ening core)-.15 F (dump and reincarnation.)128 680.4 Q(If)5 E F2(LABEL)2.5 E F0 (is omitted, restarts the program from the top.)2.5 E/F5 9/Times-Bold@0 SF -1.08(WA)128 698.4 S(RNING)1.08 E F0 2.903(:A)C .703 -.15(ny \214) -2.903 H .403(les opened at the time of the dump will).15 F F3(not)2.902 E F0 .402(be open an)2.902 F 2.902(ym)-.15 G .402 (ore when the program is)-2.902 F (reincarnated, with possible resulting confusion by Perl.)128 710.4 Q 1.657(This function is no)128 728.4 R 4.157(wl)-.25 G(ar)-4.157 E 1.657 (gely obsolete, mostly because it')-.18 F 4.158(sv)-.55 G 1.658 (ery hard to con)-4.308 F -.15(ve)-.4 G 1.658(rt a core \214le into an) .15 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 18)162.62 F 0 Cg EP %%Page: 19 19 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E -.15(exe)128 84 S .212(cutable. That').15 F 2.712(sw)-.55 G .312 -.05(hy y)-2.712 H .212 (ou should no).05 F 2.712(wi)-.25 G -1.9 -.4(nv o)-2.712 H .412 -.1 (ke i).4 H 2.712(ta).1 G(s)-2.712 E/F1 10/Courier@0 SF(CORE::dump\(\)) 2.712 E F0 2.712(,i)C 2.712(fy)-2.712 G .212(ou don')-2.712 F 2.712(tw) -.18 G .211(ant to be w)-2.812 F(arned)-.1 E(ag)128 96 Q (ainst a possible typo.)-.05 E(each)108 112.8 Q/F2 9/Times-Roman@0 SF (HASH)2.5 E F0(each)108 124.8 Q F2(ARRA)2.5 E(Y)-.945 E F0(each)108 136.8 Q F2(EXPR)2.5 E F0 1.829(When called in list conte)128 148.8 R 1.829(xt, returns a 2\255element list consisting of the k)-.15 F 2.13 -.15(ey a)-.1 H 1.83(nd v).15 F 1.83(alue for the ne)-.25 F(xt)-.15 E .37(element of a hash, or the inde)128 160.8 R 2.87(xa)-.15 G .37(nd v) -2.87 F .37(alue for the ne)-.25 F .37(xt element of an array)-.15 F 2.87(,s)-.65 G 2.87(ot)-2.87 G .37(hat you can iterate o)-2.87 F -.15 (ve)-.15 G(r).15 E 3.643(it. When)128 172.8 R 1.143 (called in scalar conte)3.643 F 1.143(xt, returns only the k)-.15 F 1.443 -.15(ey \()-.1 H 1.144(not the v).15 F 1.144 (alue\) in a hash, or the inde)-.25 F 3.644(xi)-.15 G 3.644(na)-3.644 G (n)-3.644 E(array)128 184.8 Q(.)-.65 E .097 (Hash entries are returned in an apparently random order)128 202.8 R 5.097(.T)-.55 G .097(he actual random order is subject to change)-5.097 F .551(in future v)128 214.8 R .551(ersions of Perl, b)-.15 F .551 (ut it is guaranteed to be in the same order as either the)-.2 F F1 (keys)3.051 E F0(or)3.051 E F1(values)3.051 E F0 .254(function w)128 226.8 R .254(ould produce on the same \(unmodi\214ed\) hash.)-.1 F .254 (Since Perl 5.8.2 the ordering can be dif)5.254 F(ferent)-.25 E -2.15 -.25(ev e)128 238.8 T 3.816(nb).25 G 1.316(etween dif)-3.816 F 1.316 (ferent runs of Perl for security reasons \(see `)-.25 F -.8(`A)-.74 G 1.316(lgorithmic Comple).8 F 1.317(xity Attacks')-.15 F 3.817('i)-.74 G (n)-3.817 E(perlsec\).)128 250.8 Q(After)128 268.8 Q F1(each)2.64 E F0 .14(has returned all entries from the hash or array)2.64 F 2.639(,t)-.65 G .139(he ne)-2.639 F .139(xt call to)-.15 F F1(each)2.639 E F0 .139 (returns the empty list)2.639 F .658(in list conte)128 280.8 R .658 (xt and)-.15 F F1(undef)3.158 E F0 .658(in scalar conte)3.158 F 3.158 (xt. The)-.15 F(ne)3.158 E .658(xt call follo)-.15 F .658 (wing that one restarts iteration.)-.25 F(Each)5.659 E 1.188 (hash or array has its o)128 292.8 R 1.188(wn internal iterator)-.25 F 3.688(,a)-.4 G 1.187(ccessed by)-3.688 F F1(each)3.687 E F0(,)A F1(keys) 3.687 E F0 3.687(,a)C(nd)-3.687 E F1(values)3.687 E F0 6.187(.T)C 1.187 (he iterator is)-6.187 F .499(implicitly reset when)128 304.8 R F1(each) 2.999 E F0 .499(has reached the end as just described; it can be e)2.999 F .5(xplicitly reset by calling)-.15 F F1(keys)128 316.8 Q F0(or)2.923 E F1(values)2.923 E F0 .422(on the hash or array)2.922 F 5.422(.I)-.65 G 2.922(fy)-5.422 G .422(ou add or delete a hash')-2.922 F 2.922(se)-.55 G .422(lements while iterating o)-2.922 F -.15(ve)-.15 G 2.922(ri).15 G (t,)-2.922 E .028(entries may be skipped or duplicated)128 328.8 R 1.666 <8a73>1.666 G 2.529(od)-1.666 G(on')-2.529 E 2.529(td)-.18 G 2.529(ot) -2.529 G 2.529(hat. Exception:)-2.529 F .029(It is al)2.529 F -.1(wa)-.1 G .029(ys safe to delete the item).1 F(most recently returned by)128 340.8 Q F1(each\(\))2.5 E F0 2.5(,s)C 2.5(ot)-2.5 G(he follo)-2.5 E (wing code w)-.25 E(orks properly:)-.1 E F1 (while \(\($key, $value\) = each %hash\) {)176 358.8 Q (print $key, "\\n";)188 370.8 Q(delete $hash{$key};)188 382.8 Q 6(#T)18 G(his is safe)-6 E(})176 394.8 Q F0(This prints out your en)128 412.8 Q (vironment lik)-.4 E 2.5(et)-.1 G(he)-2.5 E/F3 10/Times-Italic@0 SF (printen)2.5 E(v)-.4 E F0(\(1\) program, b)1.666 E(ut in a dif)-.2 E (ferent order:)-.25 E F1(while \(\($key,$value\) = each %ENV\) {)152 430.8 Q(print "$key=$value\\n";)176 442.8 Q(})152 454.8 Q F0 .141 (Starting with Perl 5.14,)128 472.8 R F1(each)2.641 E F0 .141(can tak) 2.641 F 2.64(eas)-.1 G(calar)-2.64 E F2(EXPR)2.64 E F0 2.64(,w)C .14 (hich must hold reference to an unblessed hash)-2.64 F .326(or array)128 484.8 R 5.326(.T)-.65 G .326(he ar)-5.326 F .326 (gument will be dereferenced automatically)-.18 F 5.326(.T)-.65 G .327 (his aspect of)-5.326 F F1(each)2.827 E F0 .327(is considered highly) 2.827 F -.15(ex)128 496.8 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E F1(while \(\($key,$value\) = each $hashref\) { ... })152 514.8 Q F0(See also)128 532.8 Q F1(keys)2.5 E F0(,)A F1(values)2.5 E F0 2.5(,a)C (nd)-2.5 E F1(sort)2.5 E F0(.)A(eof)108 549.6 Q F2(FILEHANDLE)2.5 E F0 (eof \(\))108 561.6 Q(eof)108 573.6 Q 1.385(Returns 1 if the ne)128 573.6 R 1.385(xt read on)-.15 F F2(FILEHANDLE)3.885 E F0 1.385 (will return end of \214le)3.885 F F3(or)3.884 E F0(if)3.884 E F2 (FILEHANDLE)3.884 E F0 1.384(is not open.)3.884 F F2(FILEHANDLE)128 585.6 Q F0 1.244(may be an e)3.744 F 1.244(xpression whose v)-.15 F 1.244(alue gi)-.25 F -.15(ve)-.25 G 3.744(st).15 G 1.244 (he real \214lehandle.)-3.744 F 1.245(\(Note that this function)6.245 F .369(actually reads a character and then)128 597.6 R F1(ungetc)2.868 E F0 2.868(si)C .368(t, so isn')-2.868 F 2.868(tu)-.18 G .368 (seful in an interacti)-2.868 F .668 -.15(ve c)-.25 H(onte).15 E 2.868 (xt.\) Do)-.15 F .368(not read)2.868 F .025 (from a terminal \214le \(or call)128 609.6 R F1(eof\(FILEHANDLE\))2.525 E F0 .025(on it\) after end-of-\214le is reached.)2.525 F .025 (File types such as)5.025 F (terminals may lose the end-of-\214le condition if you do.)128 621.6 Q (An)128 639.6 Q F1(eof)5.059 E F0 2.559(without an ar)5.059 F 2.559 (gument uses the last \214le read.)-.18 F(Using)7.559 E F1(eof\(\))5.058 E F0 2.558(with empty parentheses is)5.058 F(dif)128 651.6 Q 2.536 (ferent. It)-.25 F .037(refers to the pseudo \214le formed from the \ \214les listed on the command line and accessed via)2.536 F(the)128 663.6 Q F1(<>)2.892 E F0(operator)2.892 E 5.392(.S)-.55 G(ince)-5.392 E F1(<>)2.892 E F0(isn')2.892 E 2.892(te)-.18 G .392 (xplicitly opened, as a normal \214lehandle is, an)-3.042 F F1(eof\(\)) 2.891 E F0(before)2.891 E F1(<>)2.891 E F0(has)2.891 E .518 (been used will cause)128 675.6 R F1(@ARGV)3.018 E F0 .518(to be e)3.018 F .518(xamined to determine if input is a)-.15 F -.25(va)-.2 G 5.518 (ilable. Similarly).25 F 3.019(,a)-.65 G(n)-3.019 E F1(eof\(\))3.019 E F0(after)128 687.6 Q F1(<>)4.505 E F0 2.005 (has returned end-of-\214le will assume you are processing another)4.505 F F1(@ARGV)4.504 E F0 2.004(list, and if you)4.504 F(ha)128 699.6 Q -.15 (ve)-.2 G(n').15 E 2.5(ts)-.18 G(et)-2.5 E F1(@ARGV)2.5 E F0 2.5(,w)C (ill read input from)-2.5 E F1(STDIN)2.5 E F0 2.5(;s)C(ee `)-2.5 E (`I/O Operators')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E 1.192 (In a)128 717.6 R F1 1.192(while \(<>\))3.692 F F0(loop,)3.692 E F1(eof) 3.692 E F0(or)3.692 E F1(eof\(ARGV\))3.692 E F0 1.192 (can be used to detect the end of each \214le, whereas)3.692 F F1 (eof\(\))128 729.6 Q F0(will detect the end of the v)2.5 E (ery last \214le only)-.15 E 5(.E)-.65 G(xamples:)-5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 19)162.62 F 0 Cg EP %%Page: 20 20 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#r)152 84 S(eset line numbering on each input file)-6 E (while \(<>\) {)152 96 Q(next if /^\\s*#/;)176 108 Q 6(#s)12 G (kip comments)-6 E(print "$.\\t$_";)176 120 Q 6(}c)152 132 S(ontinue {) -6 E(close ARGV if eof;)176 144 Q 6(#N)12 G(ot eof\(\)!)-6 E(})152 156 Q 6(#i)152 180 S(nsert dashes just before last line of last file)-6 E (while \(<>\) {)152 192 Q(if \(eof\(\)\) {)176 204 Q 6(#c)12 G (heck for end of last file)-6 E <7072696e742022adadadadadadadadadadadadadad5c6e223b>200 216 Q(})176 228 Q(print;)176 240 Q(last if eof\(\);)176 252 Q 6(#n)60 G (eeded if we\010re reading from a terminal)-6 E(})152 264 Q F0 .644 (Practical hint: you almost ne)128 282 R -.15(ve)-.25 G 3.143(rn).15 G .643(eed to use)-3.143 F F1(eof)3.143 E F0 .643 (in Perl, because the input operators typically return)3.143 F F1(undef) 128 294 Q F0(when the)2.5 E 2.5(yr)-.15 G (un out of data or encounter an error)-2.5 E(.)-.55 E -.25(eva)108 310.8 S(l).25 E/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0 -.25(eva)108 322.8 S(l).25 E F2(BLOCK)2.5 E F0 -.25(eva)108 334.8 S(l).25 E .897 (In the \214rst form, the return v)128 346.8 R .898(alue of)-.25 F F2 (EXPR)3.398 E F0 .898(is parsed and e)3.398 F -.15(xe)-.15 G .898 (cuted as if it were a little Perl program.).15 F 1.223(The v)128 358.8 R 1.223(alue of the e)-.25 F 1.223 (xpression \(which is itself determined within scalar conte)-.15 F 1.222 (xt\) is \214rst parsed, and if)-.15 F .689(there were no errors, e)128 370.8 R -.15(xe)-.15 G .689(cuted in the le).15 F .689(xical conte)-.15 F .69(xt of the current Perl program, so that an)-.15 F 3.19(yv)-.15 G (ariable)-3.44 E 1.075 (settings or subroutine and format de\214nitions remain afterw)128 382.8 R 3.574(ards. Note)-.1 F 1.074(that the v)3.574 F 1.074 (alue is parsed e)-.25 F -.15(ve)-.25 G(ry).15 E 1.819(time the)128 394.8 R F1(eval)4.319 E F0 -.15(exe)4.319 G 4.319(cutes. If).15 F F2 (EXPR)4.319 E F0 1.819(is omitted, e)4.319 F -.25(va)-.25 G(luates).25 E F1($_)4.319 E F0 6.819(.T)C 1.819(his form is typically used to delay) -6.819 F(parsing and subsequent e)128 406.8 Q -.15(xe)-.15 G (cution of the te).15 E(xt of)-.15 E F2(EXPR)2.5 E F0(until run time.) 2.5 E 1.661(In the second form, the code within the)128 424.8 R F2 (BLOCK)4.16 E F0 1.66(is parsed only once)4.16 F 1.666<8a61>1.666 G 4.16 (tt)-1.666 G 1.66(he same time the code)-4.16 F 2.949(surrounding the) 128 436.8 R F1(eval)5.449 E F0 2.949(itself w)5.449 F 2.949(as parsed) -.1 F 1.666<8a61>1.666 G 2.949(nd e)-1.666 F -.15(xe)-.15 G 2.949 (cuted within the conte).15 F 2.949(xt of the current Perl)-.15 F 3.866 (program. This)128 448.8 R 1.366(form is typically used to trap e)3.866 F 1.365(xceptions more ef)-.15 F 1.365 (\214ciently than the \214rst \(see belo)-.25 F(w\),)-.25 E (while also pro)128 460.8 Q (viding the bene\214t of checking the code within)-.15 E F2(BLOCK)2.5 E F0(at compile time.)2.5 E(The \214nal semicolon, if an)128 478.8 Q 1.3 -.65(y, m)-.15 H(ay be omitted from the v).65 E(alue of)-.25 E F2(EXPR) 2.5 E F0(or within the)2.5 E F2(BLOCK)2.5 E F0(.)A .218 (In both forms, the v)128 496.8 R .218(alue returned is the v)-.25 F .218(alue of the last e)-.25 F .218(xpression e)-.15 F -.25(va)-.25 G .219(luated inside the mini-program;).25 F 3.805(ar)128 508.8 S 1.305 (eturn statement may be also used, just as with subroutines.)-3.805 F 1.304(The e)6.304 F 1.304(xpression pro)-.15 F 1.304(viding the return) -.15 F -.25(va)128 520.8 S 1.224(lue is e).25 F -.25(va)-.25 G 1.224 (luated in v).25 F 1.224(oid, scalar)-.2 F 3.724(,o)-.4 G 3.724(rl) -3.724 G 1.224(ist conte)-3.724 F 1.224(xt, depending on the conte)-.15 F 1.224(xt of the)-.15 F F1(eval)3.724 E F0 3.725(itself. See)3.725 F -.74(``)128 532.8 S -.1(wa).74 G(ntarray').1 E 2.5('f)-.74 G (or more on ho)-2.5 E 2.5(wt)-.25 G(he e)-2.5 E -.25(va)-.25 G (luation conte).25 E(xt can be determined.)-.15 E 1.093 (If there is a syntax error or runtime error)128 550.8 R 3.593(,o)-.4 G 3.593(ra)-3.593 G F1(die)A F0 1.093(statement is e)3.593 F -.15(xe)-.15 G(cuted,).15 E F1(eval)3.592 E F0(returns)3.592 E F1(undef)3.592 E F0 (in)3.592 E .69(scalar conte)128 562.8 R .69(xt or an empty list)-.15 F 1.666<8a6f>1.666 G 1.49 -.4(r, f)-1.666 H .691 (or syntax errors, a list containing a single unde\214ned v).4 F -.834 (alue \212 in)-.25 F .508(list conte)128 574.8 R .508(xt, and)-.15 F F1 ($@)3.008 E F0 .508(is set to the error message.)3.008 F .507 (The discrepanc)5.507 F 3.007(yi)-.15 G 3.007(nt)-3.007 G .507 (he return v)-3.007 F .507(alues in list conte)-.25 F .507(xt is)-.15 F .491(considered a b)128 586.8 R .491 (ug by some, and will probably be \214x)-.2 F .492 (ed in a future release.)-.15 F .492(If there w)5.492 F .492 (as no error)-.1 F(,)-.4 E F1($@)2.992 E F0(is)2.992 E 2.386 (guaranteed to be the empty string.)128 598.8 R(Be)7.386 E -.1(wa)-.25 G 2.386(re that using).1 F F1(eval)4.886 E F0 2.385 (neither silences Perl from printing)4.886 F -.1(wa)128 610.8 S .94 (rnings to).1 F F2(STDERR)3.44 E F0 3.44(,n)C .941(or does it stuf)-3.44 F 3.441(ft)-.25 G .941(he te)-3.441 F .941(xt of w)-.15 F .941 (arning messages into)-.1 F F1($@)3.441 E F0 5.941(.T)C 3.441(od)-6.741 G 3.441(oe)-3.441 G .941(ither of those,)-3.441 F 1.325(you ha)128 622.8 R 1.625 -.15(ve t)-.2 H 3.825(ou).15 G 1.325(se the)-3.825 F F1 -4.334 ($SIG{_ _WARN_ _})3.825 F F0 -.1(fa)3.825 G(cility).1 E 3.825(,o)-.65 G 3.825(rt)-3.825 G 1.325(urn of)-3.825 F 3.825(fw)-.25 G 1.325 (arnings inside the)-3.925 F F2(BLOCK)3.825 E F0(or)3.824 E F2(EXPR) 3.824 E F0(using)128 634.8 Q F1(no\302 warnings\302 \010all\010)2.5 E F0 5(.S)C(ee `)-5 E(`w)-.74 E(arn')-.1 E(', perlv)-.74 E(ar)-.25 E 2.5(,w) -.4 G(arnings and perlle)-2.6 E(xw)-.15 E(arn.)-.1 E .545 (Note that, because)128 652.8 R F1(eval)3.045 E F0 .546 (traps otherwise-f)3.045 F .546 (atal errors, it is useful for determining whether a particular)-.1 F 3.637(feature \(such as)128 664.8 R F1(socket)6.137 E F0(or)6.137 E F1 (symlink)6.137 E F0 6.137(\)i)C 6.137(si)-6.137 G 6.137(mplemented. It) -6.137 F 3.636(is also Perl')6.136 F 6.136(se)-.55 G(xception-trapping) -6.286 E(mechanism, where the die operator is used to raise e)128 676.8 Q(xceptions.)-.15 E .372(If you w)128 694.8 R .372 (ant to trap errors when loading an)-.1 F F2(XS)2.872 E F0 .372 (module, some problems with the binary interf)2.872 F .373(ace \(such) -.1 F .674(as Perl v)128 706.8 R .674(ersion sk)-.15 F -.25(ew)-.1 G 3.174(\)m).25 G .674(ay be f)-3.174 F .674(atal e)-.1 F -.15(ve)-.25 G 3.174(nw).15 G(ith)-3.174 E F1(eval)3.173 E F0(unless)3.173 E F1 ($ENV{PERL_DL_NONLAZY})3.173 E F0 .673(is set. See)3.173 F(perlrun.)128 718.8 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 20)162.62 F 0 Cg EP %%Page: 21 21 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.116 (If the code to be e)128 84 R -.15(xe)-.15 G 1.116(cuted doesn').15 F 3.616(tv)-.18 G(ary)-3.866 E 3.616(,y)-.65 G 1.116(ou may use the e) -3.616 F -.25(va)-.25 G 1.116(l-BLOCK form to trap run-time errors).25 F 1.797(without incurring the penalty of recompiling each time.)128 96 R 1.797(The error)6.797 F 4.297(,i)-.4 G 4.297(fa)-4.297 G -.15(ny)-4.297 G 4.297(,i)-.5 G 4.297(ss)-4.297 G 1.797(till returned in)-4.297 F/F1 10 /Courier@0 SF($@)4.296 E F0(.)A(Examples:)128 108 Q F1 6(#m)152 126 S (ake divide\255by\255zero nonfatal)-6 E (eval { $answer = $a / $b; }; warn $@ if $@;)152 138 Q 6(#s)152 162 S (ame thing, but less efficient)-6 E (eval \010$answer = $a / $b\010; warn $@ if $@;)152 174 Q 6(#ac)152 198 S(ompile\255time error)-6 E(eval { $answer = }; # WRONG)152 210 Q 6(#ar) 152 234 S(un\255time error)-6 E(eval \010$answer =\010;)152 246 Q 6(#s) 18 G(ets $@)-6 E F0 .794(Using the)128 264 R F1(eval{})3.294 E F0 .794 (form as an e)3.294 F .795(xception trap in libraries does ha)-.15 F 1.095 -.15(ve s)-.2 H .795(ome issues.).15 F .795(Due to the current) 5.795 F(ar)128 276 Q 1.12(guably brok)-.18 F 1.12(en state of)-.1 F F1 1.666(__)3.62 G -4.334(DIE_ _)-1.666 F F0 1.12 (hooks, you may wish not to trigger an)3.62 F(y)-.15 E F1 1.666(__)3.619 G -4.334(DIE_ _)-1.666 F F0 1.119(hooks that)3.619 F 2.782 (user code may ha)128 288 R 3.082 -.15(ve i)-.2 H 5.282(nstalled. Y).15 F 2.782(ou can use the)-1.1 F F1 2.782(local $SIG{_)5.282 F -4.334 (_DIE_ _})1.666 F F0 2.783(construct for this)5.282 F (purpose, as this e)128 300 Q(xample sho)-.15 E(ws:)-.25 E F1 6(#ap)152 318 S(rivate exception trap for divide\255by\255zero)-6 E (eval { local $SIG{\010_)152 330 Q -4.334(_DIE_ _\010};)1.666 F ($answer = $a / $b; };)6 E(warn $@ if $@;)152 342 Q F0 .381 (This is especially signi\214cant, gi)128 360 R -.15(ve)-.25 G 2.881(nt) .15 G(hat)-2.881 E F1 1.666(__)2.881 G -4.334(DIE_ _)-1.666 F F0 .381 (hooks can call)2.881 F F1(die)2.88 E F0(ag)2.88 E .38 (ain, which has the ef)-.05 F .38(fect of)-.25 F (changing their error messages:)128 372 Q F1 6(#_)152 390 S -4.334 (_DIE_ _)-4.334 F(hooks may modify error messages)6 E({)152 402 Q (local $SIG{\010_)170 414 Q -4.334(_DIE_ _\010})1.666 F(=)6 E (sub { \(my $x = $_[0]\) =~ s/foo/bar/g; die $x };)212 426 Q (eval { die "foo lives here" };)170 438 Q(print $@ if $@;)170 450 Q 6 (#p)96 G(rints "bar lives here")-6 E(})152 462 Q F0 1.557 (Because this promotes action at a distance, this counterintuiti)128 480 R 1.857 -.15(ve b)-.25 H(eha).15 E 1.558(vior may be \214x)-.2 F 1.558 (ed in a future)-.15 F(release.)128 492 Q -.4(Wi)128 510 S(th an).4 E F1 (eval)2.5 E F0 2.5(,y)C (ou should be especially careful to remember what')-2.5 E 2.5(sb)-.55 G (eing look)-2.5 E(ed at when:)-.1 E F1(eval $x;)152 528 Q 6(#C)48 G (ASE 1)-6 E(eval "$x";)152 540 Q 6(#C)36 G(ASE 2)-6 E(eval \010$x\010;) 152 564 Q 6(#C)36 G(ASE 3)-6 E(eval { $x };)152 576 Q 6(#C)24 G(ASE 4)-6 E(eval "\\$$x++";)152 600 Q 6(#C)12 G(ASE 5)-6 E 54($$x++; #)152 612 R (CASE 6)6 E F0 1.077(Cases 1 and 2 abo)128 630 R 1.377 -.15(ve b)-.15 H (eha).15 E 1.377 -.15(ve i)-.2 H 1.077(dentically: the).15 F 3.577(yr) -.15 G 1.077(un the code contained in the v)-3.577 F(ariable)-.25 E F1 ($x)3.576 E F0 6.076(.\()C(Although)-6.076 E .088 (case 2 has misleading double quotes making the reader w)128 642 R .089 (onder what else might be happening \(nothing)-.1 F 2.693(is\).\) Cases) 128 654 R 2.692(3a)2.693 G .192(nd 4 lik)-2.692 F -.25(ew)-.1 G .192 (ise beha).25 F .492 -.15(ve i)-.2 H 2.692(nt).15 G .192(he same w) -2.692 F .192(ay: the)-.1 F 2.692(yr)-.15 G .192(un the code)-2.692 F F1 <08247808>2.692 E F0 2.692(,w)C .192(hich does nothing b)-2.692 F(ut)-.2 E .451(return the v)128 666 R .451(alue of)-.25 F F1($x)2.951 E F0 5.451 (.\()C .451(Case 4 is preferred for purely visual reasons, b)-5.451 F .451(ut it also has the adv)-.2 F .452(antage of)-.25 F .143 (compiling at compile-time instead of at run-time.\))128 678 R .142 (Case 5 is a place where normally you)5.142 F/F2 10/Times-Italic@0 SF (would)2.642 E F0(lik)2.642 E 2.642(et)-.1 G(o)-2.642 E .11 (use double quotes, e)128 690 R .11(xcept that in this particular situa\ tion, you can just use symbolic references instead,)-.15 F (as in case 6.)128 702 Q .084(Before Perl 5.14, the assignment to)128 720 R F1($@)2.584 E F0 .083(occurred before restoration of localised v) 2.584 F .083(ariables, which means)-.25 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 21)162.62 F 0 Cg EP %%Page: 22 22 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .472 (that for your code to run on older v)128 84 R .473 (ersions, a temporary is required if you w)-.15 F .473 (ant to mask some b)-.1 F .473(ut not)-.2 F(all errors:)128 96 Q/F1 10 /Courier@0 SF 6(#a)152 114 S(lter $@ on nefarious repugnancy only)-6 E ({)152 126 Q(my $e;)170 138 Q({)170 150 Q (local $@; # protect existing $@)188 162 Q (eval { test_repugnancy\(\) };)188 174 Q 6(#$)188 186 S 6(@=)-6 G 6(~/) -6 G(nefarious/ and die $@; # Perl 5.14 and higher only)-6 E ($@ =~ /nefarious/ and $e = $@;)188 198 Q(})170 210 Q (die $e if defined $e)170 222 Q(})152 234 Q .247(eval BLOCK)128 252 R F0 (does)2.747 E/F2 10/Times-Italic@0 SF(not)2.747 E F0 .247 (count as a loop, so the loop control statements)2.747 F F1(next)2.746 E F0(,)A F1(last)2.746 E F0 2.746(,o)C(r)-2.746 E F1(redo)2.746 E F0 (cannot)2.746 E(be used to lea)128 264 Q .3 -.15(ve o)-.2 H 2.5(rr).15 G (estart the block.)-2.5 E(An)128 282 Q F1 1.13(eval \010\010)3.63 F F0 -.15(exe)3.63 G 1.13(cuted within the).15 F F1(DB)3.63 E F0 1.13 (package doesn')3.63 F 3.63(ts)-.18 G 1.13(ee the usual surrounding le) -3.63 F 1.13(xical scope, b)-.15 F(ut)-.2 E 1.195 (rather the scope of the \214rst non-DB piece of code that called it. Y) 128 294 R 1.195(ou don')-1.1 F 3.695(tn)-.18 G 1.195(ormally need to w) -3.695 F(orry)-.1 E(about this unless you are writing a Perl deb)128 306 Q(ugger)-.2 E(.)-.55 E -.15(exe)108 322.8 S(c).15 E/F3 9/Times-Roman@0 SF(LIST)2.5 E F0 -.15(exe)108 334.8 S(c).15 E F3(PR)2.5 E .25 (OGRAM LIST)-.36 F F0(The)128 346.8 Q F1(exec)3.258 E F0 .758 (function e)3.258 F -.15(xe)-.15 G .758(cutes a system command).15 F F2 .758(and ne)3.258 F .758(ver r)-.15 F(eturns)-.37 E F0 3.258(;u)C(se) -3.258 E F1(system)3.258 E F0 .758(instead of)3.258 F F1(exec)3.258 E F0 (if)3.258 E .668(you w)128 358.8 R .668(ant it to return.)-.1 F .668 (It f)5.668 F .668(ails and returns f)-.1 F .667 (alse only if the command does not e)-.1 F(xist)-.15 E F2(and)3.167 E F0 .667(it is e)3.167 F -.15(xe)-.15 G(cuted).15 E (directly instead of via your system')128 370.8 Q 2.5(sc)-.55 G (ommand shell \(see belo)-2.5 E(w\).)-.25 E .616(Since it')128 388.8 R 3.116(sac)-.55 G .616(ommon mistak)-3.116 F 3.116(et)-.1 G 3.116(ou) -3.116 G(se)-3.116 E F1(exec)3.116 E F0 .616(instead of)3.116 F F1 (system)3.116 E F0 3.116(,P)C .616(erl w)-3.116 F .616 (arns you if there is a follo)-.1 F(wing)-.25 E .154 (statement that isn')128 400.8 R(t)-.18 E F1(die)2.654 E F0(,)A F1(warn) 2.654 E F0 2.653(,o)C(r)-2.653 E F1(exit)2.653 E F0(\(if)2.653 E F1 2.653 E F0 .153(is set)2.653 F 1.666<8a62>1.666 G .153(ut you al) -1.866 F -.1(wa)-.1 G .153(ys do that, right?\).).1 F .153(If you)7.653 F F2 -.37(re)2.653 G(ally).37 E F0 -.1(wa)128 412.8 S 1.676(nt to follo) .1 F 4.176(wa)-.25 G(n)-4.176 E F1(exec)4.176 E F0 1.677 (with some other statement, you can use one of these styles to a)4.176 F -.2(vo)-.2 G 1.677(id the).2 F -.1(wa)128 424.8 S(rning:).1 E F1 (exec \(\010foo\010\))152 442.8 Q (or print STDERR "couldn\010t exec foo: $!";)18 E 6({e)152 454.8 S (xec \(\010foo\010\) }; print STDERR "couldn\010t exec foo: $!";)-6 E F0 1.364(If there is more than one ar)128 472.8 R 1.364(gument in)-.18 F F3 (LIST)3.864 E F0 3.864(,o)C 3.864(ri)-3.864 G(f)-3.864 E F3(LIST)3.864 E F0 1.364(is an array with more than one v)3.864 F 1.364(alue, calls)-.25 F F2 -.2(ex)128 484.8 S(ecvp).2 E F0 1.702(\(3\) with the ar)1.666 F 1.702(guments in)-.18 F F3(LIST)4.202 E F0 6.702(.I)C 4.202(ft)-6.702 G 1.702(here is only one scalar ar)-4.202 F 1.702 (gument or an array with one)-.18 F 2.404(element in it, the ar)128 496.8 R 2.404(gument is check)-.18 F 2.404 (ed for shell metacharacters, and if there are an)-.1 F 3.703 -.65(y, t) -.15 H 2.403(he entire).65 F(ar)128 508.8 Q 2.516 (gument is passed to the system')-.18 F 5.017(sc)-.55 G 2.517 (ommand shell for parsing \(this is)-5.017 F F1 2.517(/bin/sh \255c) 5.017 F F0 2.517(on Unix)5.017 F 1.107(platforms, b)128 520.8 R 1.107 (ut v)-.2 F 1.107(aries on other platforms\).)-.25 F 1.107 (If there are no shell metacharacters in the ar)6.107 F 1.106 (gument, it is)-.18 F(split into w)128 532.8 Q (ords and passed directly to)-.1 E F1(execvp)2.5 E F0 2.5(,w)C (hich is more ef)-2.5 E 2.5(\214cient. Examples:)-.25 F F1 (exec \010/bin/echo\010, \010Your arguments are: \010, @ARGV;)152 550.8 Q(exec "sort $outfile | uniq";)152 562.8 Q F0 .238(If you don')128 580.8 R 2.739(tr)-.18 G .239(eally w)-2.739 F .239(ant to e)-.1 F -.15(xe)-.15 G .239(cute the \214rst ar).15 F .239(gument, b)-.18 F .239(ut w)-.2 F .239(ant to lie to the program you are e)-.1 F -.15(xe)-.15 G(cuting).15 E 1.243(about its o)128 592.8 R 1.243 (wn name, you can specify the program you actually w)-.25 F 1.243 (ant to run as an `)-.1 F 1.242(`indirect object')-.74 F(')-.74 E .002 (\(without a comma\) in front of the)128 604.8 R F3(LIST)2.502 E F0 5.002(.\()C .002(This al)-5.002 F -.1(wa)-.1 G .003 (ys forces interpretation of the).1 F F3(LIST)2.503 E F0 .003 (as a multi)2.503 F -.25(va)-.25 G(lued).25 E(list, e)128 616.8 Q -.15 (ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G (here is only a single scalar in the list.\))-2.5 E(Example:)5 E F1 ($shell = \010/bin/csh\010;)152 634.8 Q(exec $shell \010\255sh\010;)152 646.8 Q 6(#p)24 G(retend it\010s a login shell)-6 E F0(or)128 664.8 Q 2.5(,m)-.4 G(ore directly)-2.5 E(,)-.65 E F1 (exec {\010/bin/csh\010} \010\255sh\010;)152 682.8 Q 6(#p)12 G (retend it\010s a login shell)-6 E F0 .124(When the ar)128 700.8 R .124 (guments get e)-.18 F -.15(xe)-.15 G .124(cuted via the system shell, r\ esults are subject to its quirks and capabilities.).15 F(See `)128 712.8 Q -.74(``)-.74 G(STRING`').74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlop for details.)-2.5 E .933(Using an indirect object with)128 730.8 R F1(exec)3.433 E F0(or)3.433 E F1(system)3.433 E F0 .933 (is also more secure.)3.433 F .933(This usage \(which also w)5.933 F (orks)-.1 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 22)162.62 F 0 Cg EP %%Page: 23 23 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .413(\214ne with) 128 84 R/F1 10/Times-Italic@0 SF(system\(\))2.913 E F0 2.913(\)f)C .413 (orces interpretation of the ar)-2.913 F .413(guments as a multi)-.18 F -.25(va)-.25 G .413(lued list, e).25 F -.15(ve)-.25 G 2.913(ni).15 G 2.913(ft)-2.913 G .413(he list had just)-2.913 F 1.113(one ar)128 96 R 3.613(gument. That)-.18 F -.1(wa)3.613 G 3.613(yy).1 G(ou')-3.613 E 1.113(re safe from the shell e)-.5 F 1.114 (xpanding wildcards or splitting up w)-.15 F 1.114(ords with)-.1 F (whitespace in them.)128 108 Q/F2 10/Courier@0 SF (@args = \( "echo surprise" \);)152 126 Q(exec @args;)152 150 Q 6(#s)90 G(ubject to shell escapes)-6 E 6(#i)320 162 S 6(f@)-6 G(args == 1)-6 E (exec { $args[0] } @args;)152 174 Q 6(#s)12 G (afe even with one\255arg list)-6 E F0 .601(The \214rst v)128 192 R .601 (ersion, the one without the indirect object, ran the)-.15 F F1(ec)3.1 E (ho)-.15 E F0 .6(program, passing it)3.1 F F2("surprise")3.1 E F0 .406 (an ar)128 204 R 2.906(gument. The)-.18 F .407(second v)2.907 F .407 (ersion didn')-.15 F .407(t; it tried to run a program named)-.18 F F1 -1.11(``)2.907 G(ec)1.11 E .407(ho surprise')-.15 F(')-1.11 E F0 2.907 (,d)C(idn')-2.907 E 2.907<748c>-.18 G(nd)-2.907 E(it, and set)128 216 Q F2($?)2.5 E F0(to a non-zero v)2.5 E(alue indicating f)-.25 E(ailure.) -.1 E(Be)128 234 Q .598(ginning with v5.6.0, Perl attempts to \215ush a\ ll \214les opened for output before the e)-.15 F -.15(xe)-.15 G .598 (c, b).15 F .598(ut this may)-.2 F 4.029 (not be supported on some platforms \(see perlport\).)128 246 R 5.629 -.8(To b)9.029 H 6.529(es).8 G 4.03(afe, you may need to set)-6.529 F F2 ($|)6.53 E F0(\($A)128 258 Q(UT)-.55 E 2.52 (OFLUSH in English\) or call the)-.18 F F2(autoflush\(\))5.02 E F0 2.52 (method of)5.02 F F2(IO::Handle)5.02 E F0 2.52(on an)5.02 F 5.02(yo)-.15 G(pen)-5.02 E(handles to a)128 270 Q -.2(vo)-.2 G(id lost output.).2 E (Note that)128 288 Q F2(exec)2.5 E F0(will not call your)2.5 E F2(END) 2.5 E F0(blocks, nor will it in)2.5 E -.2(vo)-.4 G -.1(ke).2 G F2 (DESTROY)2.6 E F0(methods on your objects.)2.5 E -.15(ex)108 304.8 S (ists).15 E/F3 9/Times-Roman@0 SF(EXPR)2.5 E F0(Gi)128 316.8 Q -.15(ve) -.25 G 3.7(na).15 G 3.7(ne)-3.7 G 1.2(xpression that speci\214es an ele\ ment of a hash, returns true if the speci\214ed element in the)-3.85 F (hash has e)128 328.8 Q -.15(ve)-.25 G 2.5(rb).15 G(een initialized, e) -2.5 E -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(he corresponding v)-2.5 E(alue is unde\214ned.)-.25 E F2(print "Exists\\n")152 346.8 Q (if exists $hash{$key};)24 E(print "Defined\\n")152 358.8 Q (if defined $hash{$key};)18 E(print "True\\n")152 370.8 Q (if $hash{$key};)36 E F0 -.15(ex)128 388.8 S .445 (ists may also be called on array elements, b).15 F .445(ut its beha)-.2 F .445(vior is much less ob)-.2 F .445(vious and is strongly tied)-.15 F .298(to the use of `)128 400.8 R(`delete')-.74 E 2.798('o)-.74 G 2.798 (na)-2.798 G(rrays.)-2.798 E/F4 10/Times-Bold@0 SF .298(Be awar)5.298 F (e)-.18 E F0 .298(that calling e)2.798 F .299(xists on array v)-.15 F .299(alues is deprecated and lik)-.25 F(ely)-.1 E(to be remo)128 412.8 Q -.15(ve)-.15 G 2.5(di).15 G 2.5(naf)-2.5 G(uture v)-2.5 E (ersion of Perl.)-.15 E F2(print "Exists\\n")152 430.8 Q (if exists $array[$index];)24 E(print "Defined\\n")152 442.8 Q (if defined $array[$index];)18 E(print "True\\n")152 454.8 Q (if $array[$index];)36 E F0 3.488(Ah)128 472.8 S .988 (ash or array element can be true only if it')-3.488 F 3.488(sd)-.55 G .988(e\214ned and de\214ned only if it e)-3.488 F .988(xists, b)-.15 F .988(ut the re)-.2 F -.15(ve)-.25 G(rse).15 E(doesn')128 484.8 Q 2.5(tn) -.18 G(ecessarily hold true.)-2.5 E(Gi)128 502.8 Q -.15(ve)-.25 G 2.646 (na).15 G 2.646(ne)-2.646 G .146(xpression that speci\214es the name of\ a subroutine, returns true if the speci\214ed subroutine has)-2.796 F -2.15 -.25(ev e)128 514.8 T 3.332(rb).25 G .832(een declared, e)-3.332 F -.15(ve)-.25 G 3.332(ni).15 G 3.331(fi)-3.332 G 3.331(ti)-3.331 G 3.331 (su)-3.331 G 3.331(nde\214ned. Mentioning)-3.331 F 3.331(as)3.331 G .831 (ubroutine name for e)-3.331 F .831(xists or de\214ned does)-.15 F .677 (not count as declaring it.)128 526.8 R .677 (Note that a subroutine that does not e)5.677 F .678 (xist may still be callable: its package)-.15 F .443(may ha)128 538.8 R .743 -.15(ve a)-.2 H(n).15 E F2(AUTOLOAD)2.943 E F0 .442 (method that mak)2.943 F .442(es it spring into e)-.1 F .442 (xistence the \214rst time that it is called; see)-.15 F(perlsub)128 550.8 Q(.)-.4 E F2(print "Exists\\n")152 568.8 Q(if exists &subroutine;) 12 E(print "Defined\\n" if defined &subroutine;)152 580.8 Q F0 .417 (Note that the)128 598.8 R F3(EXPR)2.917 E F0 .418(can be arbitrarily c\ omplicated as long as the \214nal operation is a hash or array k)2.917 F -.15(ey)-.1 G(lookup or subroutine name:)128 610.8 Q F2 (if \(exists $ref\255>{A}\255>{B}\255>{$key}\))152 628.8 Q 6({})12 G (if \(exists $hash{A}{B}{$key}\))152 640.8 Q 6({})42 G (if \(exists $ref\255>{A}\255>{B}\255>[$ix]\))152 664.8 Q 6({})18 G (if \(exists $hash{A}{B}[$ix]\))152 676.8 Q 6({})48 G (if \(exists &{$ref\255>{A}{B}{$key}}\))152 700.8 Q 6({})18 G F0 2.423 (Although the mostly deeply nested array or hash will not spring into e) 128 718.8 R 2.423(xistence just because its)-.15 F -.15(ex)128 730.8 S .164(istence w).15 F .164(as tested, an)-.1 F 2.664(yi)-.15 G(nterv) -2.664 E .164(ening ones will.)-.15 F(Thus)5.164 E F2($ref\255>{"A"}) 2.664 E F0(and)2.664 E F2($ref\255>{"A"}\255>{"B"})2.664 E F0 (perl v5.14.2)72 768 Q 198.17(2011-10-01 23)162.62 F 0 Cg EP %%Page: 24 24 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 2.484 (will spring into e)128 84 R 2.484(xistence due to the e)-.15 F 2.484 (xistence test for the)-.15 F/F1 10/Courier@0 SF($key)4.984 E F0 2.484 (element abo)4.984 F -.15(ve)-.15 G 7.484(.T).15 G 2.484(his happens) -7.484 F(an)128 96 Q(ywhere the arro)-.15 E 2.5(wo)-.25 G (perator is used, including e)-2.5 E -.15(ve)-.25 G 2.5(nh).15 G(ere:) -2.5 E F1(undef $ref;)152 114 Q(if \(exists $ref\255>{"Some key"}\))152 126 Q 6({})24 G(print $ref;)152 138 Q 6(#p)12 G(rints HASH\(0x80d3d5c\)) -6 E F0 1.076(This surprising auto)128 156 R(vi)-.15 E 1.077 (vi\214cation in what does not at \214rst)-.25 F 1.666<8a6f>1.666 G 3.577(re)-1.666 G -.15(ve)-3.827 G 3.577(ns).15 G -.834 (econd \212 glance)-3.577 F 1.077(appear to be an)3.577 F(lv)128 168 Q (alue conte)-.25 E(xt may be \214x)-.15 E(ed in a future release.)-.15 E (Use of a subroutine call, rather than a subroutine name, as an ar)128 186 Q(gument to)-.18 E/F2 10/Times-Italic@0 SF -.2(ex)2.5 G(ists\(\)).2 E F0(is an error)2.5 E(.)-.55 E F1(exists ⊂)152 204 Q 6(#O)24 G(K)-6 E(exists &sub\(\);)152 216 Q 6(#E)12 G(rror)-6 E F0 -.15(ex)108 232.8 S (it).15 E/F3 9/Times-Roman@0 SF(EXPR)2.5 E F0 -.15(ex)108 244.8 S(it).15 E(Ev)128 244.8 Q(aluates)-.25 E F3(EXPR)2.5 E F0(and e)2.5 E (xits immediately with that v)-.15 E 7.5(alue. Example:)-.25 F F1 ($ans = ;)152 262.8 Q(exit 0 if $ans =~ /^[Xx]/;)152 274.8 Q F0 1.285(See also)128 292.8 R F1(die)3.785 E F0 6.285(.I)C(f)-6.285 E F3 (EXPR)3.785 E F0 1.285(is omitted, e)3.785 F 1.285(xits with)-.15 F F1 (0)3.785 E F0 3.785(status. The)3.785 F 1.284(only uni)3.785 F -.15(ve) -.25 G 1.284(rsally recognized v).15 F 1.284(alues for)-.25 F F3(EXPR) 128 304.8 Q F0(are)3.699 E F1(0)3.699 E F0 1.199(for success and)3.699 F F1(1)3.7 E F0 1.2(for error; other v)3.7 F 1.2 (alues are subject to interpretation depending on the)-.25 F(en)128 316.8 Q .016(vironment in which the Perl program is running.)-.4 F -.15 (Fo)5.016 G 2.515(re).15 G .015(xample, e)-2.665 F .015(xiting 69 \() -.15 F F3(EX_UN)A -1.215(AVA)-.315 G(ILABLE)1.215 E F0 2.515(\)f)C(rom) -2.515 E(a)128 328.8 Q F2(sendmail)2.786 E F0 .286 (incoming-mail \214lter will cause the mailer to return the item undeli) 2.786 F -.15(ve)-.25 G .287(red, b).15 F .287(ut that')-.2 F 2.787(sn) -.55 G .287(ot true)-2.787 F -2.15 -.25(ev e)128 340.8 T(rywhere.).25 E (Don')128 358.8 Q 2.877(tu)-.18 G(se)-2.877 E F1(exit)2.877 E F0 .377 (to abort a subroutine if there')2.877 F 2.876(sa)-.55 G .676 -.15(ny c) -2.876 H .376(hance that someone might w).15 F .376(ant to trap whate) -.1 F -.15(ve)-.25 G(r).15 E(error happened.)128 370.8 Q(Use)5 E F1(die) 2.5 E F0(instead, which can be trapped by an)2.5 E F1(eval)2.5 E F0(.)A (The)128 388.8 Q F2 -.2(ex)2.797 G(it\(\)).2 E F0 .297 (function does not al)2.797 F -.1(wa)-.1 G .297(ys e).1 F .297 (xit immediately)-.15 F 5.297(.I)-.65 G 2.798(tc)-5.297 G .298(alls an) -2.798 F 2.798(yd)-.15 G(e\214ned)-2.798 E F1(END)2.798 E F0 .298 (routines \214rst, b)2.798 F .298(ut these)-.2 F F1(END)128 400.8 Q F0 .061(routines may not themselv)2.561 F .061(es abort the e)-.15 F 2.561 (xit. Lik)-.15 F -.25(ew)-.1 G .061(ise an).25 F 2.561(yo)-.15 G .06 (bject destructors that need to be called)-2.561 F .69 (are called before the real e)128 412.8 R(xit.)-.15 E F1(END)5.69 E F0 .691(routines and destructors can change the e)3.191 F .691 (xit status by modifying)-.15 F F1($?)128 424.8 Q F0 4.544(.I)C 4.544 (ft)-4.544 G 2.043(his is a problem, you can call)-4.544 F F1 (POSIX:_exit\($status\))4.543 E F0 2.043(to a)4.543 F -.2(vo)-.2 G(id).2 E F3(END)4.543 E F0 2.043(and destructor)4.543 F 2.5(processing. See)128 436.8 R(perlmod for details.)2.5 E -.15(ex)108 453.6 S(p).15 E F3(EXPR) 2.5 E F0 -.15(ex)108 465.6 S(p).15 E(Returns)128 465.6 Q F2(e)2.5 E F0 (\(the natural log)2.5 E(arithm base\) to the po)-.05 E(wer of)-.25 E F3 (EXPR)2.5 E F0 5(.I)C(f)-5 E F3(EXPR)2.5 E F0(is omitted, gi)2.5 E -.15 (ve)-.25 G(s).15 E F1(exp\($_\))2.5 E F0(.)A(fcntl)108 482.4 Q F3 (FILEHANDLE)2.5 E F0(,FUNCTION,SCALAR)A(Implements the)128 494.4 Q F2 (fcntl)2.5 E F0(\(2\) function.)1.666 E -1.1(Yo)5 G(u')1.1 E (ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1 (use Fcntl;)152 512.4 Q F0 1.342 (\214rst to get the correct constant de\214nitions.)128 530.4 R(Ar)6.342 E 1.342(gument processing and v)-.18 F 1.342(alue returned w)-.25 F 1.343(ork just lik)-.1 F(e)-.1 E F1(ioctl)128 542.4 Q F0(belo)2.5 E 3.8 -.65(w. F)-.25 H(or e).5 E(xample:)-.15 E F1(use Fcntl;)152 560.4 Q (fcntl\($filehandle, F_GETFL, $packed_return_buffer\))152 572.4 Q (or die "can\010t fcntl F_GETFL: $!";)176 584.4 Q F0 -1.1(Yo)128 602.4 S 3.3(ud)1.1 G(on')-3.3 E 3.3(th)-.18 G -2.25 -.2(av e)-3.3 H .8 (to check for)3.5 F F1(defined)3.3 E F0 .8(on the return from)3.3 F F1 (fcntl)3.3 E F0 5.8(.L)C(ik)-5.8 E(e)-.1 E F1(ioctl)3.3 E F0 3.3(,i)C 3.3(tm)-3.3 G .8(aps a)-3.3 F F1(0)3.3 E F0(return)3.3 E 1.023 (from the system call into)128 614.4 R F1 1.023("0 but true")3.523 F F0 1.023(in Perl.)3.523 F 1.023(This string is true in boolean conte)6.023 F 1.024(xt and)-.15 F F1(0)3.524 E F0(in)3.524 E(numeric conte)128 626.4 Q 2.5(xt. It)-.15 F(is also e)2.5 E -.15(xe)-.15 G(mpt from the normal) .15 E/F4 10/Times-Bold@0 SF2.5 E F0 -.1(wa)2.5 G (rnings on improper numeric con).1 E -.15(ve)-.4 G(rsions.).15 E .879 (Note that)128 644.4 R F1(fcntl)3.379 E F0 .879(raises an e)3.379 F .878 (xception if used on a machine that doesn')-.15 F 3.378(ti)-.18 G (mplement)-3.378 E F2(fcntl)3.378 E F0 3.378(\(2\). See)1.666 F(the) 3.378 E(Fcntl module or your)128 656.4 Q F2(fcntl)2.5 E F0 (\(2\) manpage to learn what functions are a)1.666 E -.25(va)-.2 G (ilable on your system.).25 E(Here')128 674.4 Q 4.125(sa)-.55 G 4.125 (ne)-4.125 G 1.625(xample of setting a \214lehandle named)-4.275 F F1 (REMOTE)4.125 E F0 1.626(to be non-blocking at the system le)4.125 F -.15(ve)-.25 G(l.).15 E -1.1(Yo)128 686.4 S(u')1.1 E(ll ha)-.1 E .3 -.15 (ve t)-.2 H 2.5(on).15 G -.15(eg)-2.5 G(otiate).15 E F1($|)2.5 E F0 (on your o)2.5 E(wn, though.)-.25 E F1 (use Fcntl qw\(F_GETFL F_SETFL O_NONBLOCK\);)152 704.4 Q ($flags = fcntl\(REMOTE, F_GETFL, 0\))152 728.4 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 24)162.62 F 0 Cg EP %%Page: 25 25 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (or die "Can\010t get flags for the socket: $!\\n";)224 84 Q ($flags = fcntl\(REMOTE, F_SETFL, $flags | O_NONBLOCK\))152 108 Q (or die "Can\010t set flags for the socket: $!\\n";)224 120 Q F0 (\214leno)108 136.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0 .138(Re\ turns the \214le descriptor for a \214lehandle, or unde\214ned if the \ \214lehandle is not open.)128 148.8 R .138(If there is no real)5.138 F .521(\214le descriptor at the)128 160.8 R F2(OS)3.021 E F0(le)3.022 E -.15(ve)-.25 G .522 (l, as can happen with \214lehandles connected to memory objects via).15 F F1(open)3.022 E F0(with a reference for the third ar)128 172.8 Q (gument, \2551 is returned.)-.18 E 3.204 (This is mainly useful for constructing bitmaps for)128 190.8 R F1 (select)5.704 E F0 3.204(and lo)5.704 F(w-le)-.25 E -.15(ve)-.25 G(l).15 E F2(POSIX)5.704 E F0(tty-handling)5.704 E 2.845(operations. If)128 202.8 R F2(FILEHANDLE)2.845 E F0 .345(is an e)2.845 F .345 (xpression, the v)-.15 F .345(alue is tak)-.25 F .346 (en as an indirect \214lehandle, generally its)-.1 F(name.)128 214.8 Q -1.1(Yo)128 232.8 S 2.5(uc)1.1 G(an use this to \214nd out whether tw) -2.5 E 2.5(oh)-.1 G(andles refer to the same underlying descriptor:)-2.5 E F1(if \(fileno\(THIS\) == fileno\(THAT\)\) {)152 250.8 Q (print "THIS and THAT are dups\\n";)176 262.8 Q(})152 274.8 Q F0 (\215ock)108 291.6 Q F2(FILEHANDLE)2.5 E F0(,OPERA)A(TION)-1.11 E(Calls) 128 303.6 Q/F3 10/Times-Italic@0 SF(\215oc)4.247 E(k)-.2 E F0 1.747 (\(2\), or an emulation of it, on)1.666 F F2(FILEHANDLE)4.246 E F0 6.746 (.R)C 1.746(eturns true for success, f)-6.746 F 1.746(alse on f)-.1 F (ailure.)-.1 E 2.003(Produces a f)128 315.6 R 2.004 (atal error if used on a machine that doesn')-.1 F 4.504(ti)-.18 G (mplement)-4.504 E F3(\215oc)4.504 E(k)-.2 E F0(\(2\),)1.666 E F3(fcntl) 4.504 E F0 2.004(\(2\) locking, or)1.666 F F3(loc)128 327.6 Q(kf)-.2 E F0(\(3\).)1.666 E F1(flock)7.516 E F0 2.516(is Perl')5.016 F 5.016(sp) -.55 G 2.516(ortable \214le-locking interf)-5.016 F 2.516 (ace, although it locks entire \214les only)-.1 F 5.015(,n)-.65 G(ot) -5.015 E(records.)128 339.6 Q -1 -.8(Tw o)128 357.6 T 1.262 (potentially non-ob)4.562 F 1.262(vious b)-.15 F 1.262(ut traditional) -.2 F F1(flock)3.762 E F0 1.262(semantics are that it w)3.762 F 1.263 (aits inde\214nitely until the)-.1 F .093 (lock is granted, and that its locks are)128 369.6 R/F4 10/Times-Bold@0 SF(mer)2.593 E .092(ely advisory)-.18 F F0 5.092(.S)C .092 (uch discretionary locks are more \215e)-5.092 F .092(xible, b)-.15 F (ut)-.2 E(of)128 381.6 Q 1.93(fer fe)-.25 F 1.93(wer guarantees.)-.25 F 1.93(This means that programs that do not also use)6.93 F F1(flock)4.43 E F0 1.93(may modify \214les)4.43 F(lock)128 393.6 Q .55(ed with)-.1 F F1(flock)3.05 E F0 5.549(.S)C .549(ee perlport, your port')-5.549 F 3.049(ss)-.55 G .549 (peci\214c documentation, and your system-speci\214c local)-3.049 F 1.622(manpages for details.)128 405.6 R(It')6.622 E 4.122(sb)-.55 G 1.622(est to assume traditional beha)-4.122 F 1.622(vior if you')-.2 F 1.623(re writing portable programs.)-.5 F 3.366(\(But if you')128 417.6 R 3.366(re not, you should as al)-.5 F -.1(wa)-.1 G 3.365 (ys feel perfectly free to write for your o).1 F 3.365(wn system')-.25 F (s)-.55 E .394(idiosyncrasies \(sometimes called `)128 429.6 R (`features')-.74 E 2.894('\). Sla)-.74 F .394 (vish adherence to portability concerns shouldn')-.2 F 2.894(tg)-.18 G (et)-2.894 E(in the w)128 441.6 Q(ay of your getting your job done.\)) -.1 E F2(OPERA)128 459.6 Q(TION)-.999 E F0 .193(is one of)2.693 F F2 (LOCK_SH)2.692 E F0(,)A F2(LOCK_EX)2.692 E F0 2.692(,o)C(r)-2.692 E F2 (LOCK_UN)2.692 E F0 2.692(,p)C .192(ossibly combined with)-2.692 F F2 (LOCK_NB)2.692 E F0 5.192(.T)C(hese)-5.192 E .043 (constants are traditionally v)128 471.6 R .043(alued 1, 2, 8 and 4, b) -.25 F .043(ut you can use the symbolic names if you import them)-.2 F .333(from the Fcntl module, either indi)128 483.6 R(vidually)-.25 E 2.833(,o)-.65 G 2.833(ra)-2.833 G 2.833(sa)-2.833 G .332 (group using the)-.001 F F1(:flock)2.832 E F0(tag.)2.832 E F2(LOCK_SH) 5.332 E F0 .332(requests a)2.832 F .077(shared lock,)128 495.6 R F2 (LOCK_EX)2.577 E F0 .077(requests an e)2.577 F(xclusi)-.15 E .377 -.15 (ve l)-.25 H .077(ock, and).15 F F2(LOCK_UN)2.577 E F0 .077 (releases a pre)2.577 F .077(viously requested lock.)-.25 F(If)128 507.6 Q F2(LOCK_NB)3.787 E F0 1.287(is bitwise-or'ed with)3.787 F F2(LOCK_SH) 3.786 E F0(or)3.786 E F2(LOCK_EX)3.786 E F0 3.786(,t)C(hen)-3.786 E F1 (flock)3.786 E F0 1.286(returns immediately rather)3.786 F (than blocking w)128 519.6 Q (aiting for the lock; check the return status to see if you got it.)-.1 E 4.885 -.8(To a)128 537.6 T -.2(vo).6 G 3.285 (id the possibility of miscoordination, Perl no).2 F 5.785<778d>-.25 G (ushes)-5.785 E F2(FILEHANDLE)5.785 E F0 3.285(before locking or)5.785 F (unlocking it.)128 549.6 Q 3.234(Note that the emulation b)128 567.6 R 3.234(uilt with)-.2 F F3(loc)5.734 E(kf)-.2 E F0 3.234(\(3\) doesn') 1.666 F 5.734(tp)-.18 G(ro)-5.734 E 3.234 (vide shared locks, and it requires that)-.15 F F2(FILEHANDLE)128 579.6 Q F0 .883(be open with write intent.)3.383 F .883 (These are the semantics that)5.883 F F3(loc)3.383 E(kf)-.2 E F0 .884 (\(3\) implements.)1.666 F .884(Most if)5.884 F 1.407 (not all systems implement)128 591.6 R F3(loc)3.907 E(kf)-.2 E F0 1.407 (\(3\) in terms of)1.666 F F3(fcntl)3.907 E F0 1.407 (\(2\) locking, though, so the dif)1.666 F 1.407(fering semantics)-.25 F (shouldn')128 603.6 Q 2.5(tb)-.18 G(ite too man)-2.5 E 2.5(yp)-.15 G (eople.)-2.5 E .183(Note that the)128 621.6 R F3(fcntl)2.683 E F0 .183 (\(2\) emulation of)1.666 F F3(\215oc)2.684 E(k)-.2 E F0 .184 (\(3\) requires that)1.666 F F2(FILEHANDLE)2.684 E F0 .184 (be open with read intent to use)2.684 F F2(LOCK_SH)128 633.6 Q F0 (and requires that it be open with write intent to use)2.5 E F2(LOCK_EX) 2.5 E F0(.)A .763(Note also that some v)128 651.6 R .763(ersions of)-.15 F F1(flock)3.263 E F0 .763(cannot lock things o)3.263 F -.15(ve)-.15 G 3.263(rt).15 G .763(he netw)-3.263 F .763(ork; you w)-.1 F .763 (ould need to use)-.1 F 1.731(the more system-speci\214c)128 663.6 R F1 (fcntl)4.232 E F0 1.732(for that.)4.232 F 1.732(If you lik)6.732 F 4.232 (ey)-.1 G 1.732(ou can force Perl to ignore your system')-4.232 F(s)-.55 E F3(\215oc)128 675.6 Q(k)-.2 E F0 4.473(\(2\) function, and so pro) 1.666 F 4.472(vide its o)-.15 F(wn)-.25 E F3(fcntl)6.972 E F0 4.472 (\(2\)\255based emulation, by passing the switch)1.666 F F1 (\255Ud_flock)128 687.6 Q F0(to the)2.5 E F3(Con\214gur)2.5 E(e)-.37 E F0(program when you con\214gure and b)2.5 E(uild a ne)-.2 E 2.5(wP)-.25 G(erl.)-2.5 E(Here')128 705.6 Q 2.5(sam)-.55 G(ailbox appender for)-2.5 E F2(BSD)2.5 E F0(systems.)2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 25)162.62 F 0 Cg EP %%Page: 26 26 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Fcntl qw\(:flock SEEK_END\); # import LOCK_* and SEEK_END constant\ s)152 84 Q(sub lock {)152 108 Q(my \($fh\) = @_;)176 120 Q (flock\($fh, LOCK_EX\) or die "Cannot lock mailbox \255 $!\\n";)176 132 Q 6(#a)176 156 S(nd, in case someone appended while we were waiting...) -6 E(seek\($fh, 0, SEEK_END\) or die "Cannot seek \255 $!\\n";)176 168 Q (})152 180 Q(sub unlock {)152 204 Q(my \($fh\) = @_;)176 216 Q (flock\($fh, LOCK_UN\) or die "Cannot unlock mailbox \255 $!\\n";)176 228 Q(})152 240 Q (open\(my $mbox, ">>", "/usr/spool/mail/$ENV{\010USER\010}"\))152 264 Q (or die "Can\010t open mailbox: $!";)176 276 Q(lock\($mbox\);)152 300 Q (print $mbox $msg,"\\n\\n";)152 312 Q(unlock\($mbox\);)152 324 Q F0 .212 (On systems that support a real)128 342 R/F2 10/Times-Italic@0 SF (\215oc)2.712 E(k)-.2 E F0 .212(\(2\), locks are inherited across)1.666 F F2(fork\(\))2.712 E F0 .212(calls, whereas those that must)2.712 F 1.471(resort to the more capricious)128 354 R F2(fcntl)3.97 E F0 1.47 (\(2\) function lose their locks, making it seriously harder to write) 1.666 F(serv)128 366 Q(ers.)-.15 E(See also DB_File for other)128 384 Q F2(\215oc)2.5 E(k\(\))-.2 E F0 -.15(ex)2.5 G(amples.).15 E(fork)108 400.8 Q 1.024(Does a)128 412.8 R F2(fork)3.524 E F0 1.024 (\(2\) system call to create a ne)1.666 F 3.525(wp)-.25 G 1.025 (rocess running the same program at the same point.)-3.525 F(It)6.025 E .115(returns the child pid to the parent process,)128 424.8 R F1(0)2.614 E F0 .114(to the child process, or)2.614 F F1(undef)2.614 E F0 .114 (if the fork is unsuccessful.)2.614 F .057(File descriptors \(and somet\ imes locks on those descriptors\) are shared, while e)128 436.8 R -.15 (ve)-.25 G .058(rything else is copied.).15 F 2.695 (On most systems supporting)128 448.8 R F2(fork\(\))5.195 E F0 5.195(,g) C 2.695(reat care has gone into making it e)-5.195 F 2.695(xtremely ef) -.15 F 2.695(\214cient \(for)-.25 F -.15(ex)128 460.8 S 2.738 (ample, using cop).15 F 2.738(y-on-write technology on data pages\), ma\ king it the dominant paradigm for)-.1 F(multitasking o)128 472.8 Q -.15 (ve)-.15 G 2.5(rt).15 G(he last fe)-2.5 E 2.5(wd)-.25 G(ecades.)-2.5 E (Be)128 490.8 Q 2.033(ginning with v5.6.0, Perl attempts to \215ush all\ \214les opened for output before forking the child)-.15 F .324 (process, b)128 502.8 R .324 (ut this may not be supported on some platforms \(see perlport\).)-.2 F 1.925 -.8(To b)5.325 H 2.825(es).8 G .325(afe, you may need to)-2.825 F (set)128 514.8 Q F1($|)2.653 E F0(\($A)2.653 E(UT)-.55 E .152 (OFLUSH in English\) or call the)-.18 F F1(autoflush\(\))2.652 E F0 .152 (method of)2.652 F F1(IO::Handle)2.652 E F0 .152(on an)2.652 F 2.652(yo) -.15 G(pen)-2.652 E(handles to a)128 526.8 Q -.2(vo)-.2 G (id duplicate output.).2 E .402(If you)128 544.8 R F1(fork)2.902 E F0 .402(without e)2.902 F -.15(ve)-.25 G 2.902(rw).15 G .403 (aiting on your children, you will accumulate zombies.)-3.002 F .403 (On some systems,)5.403 F 1.028(you can a)128 556.8 R -.2(vo)-.2 G 1.028 (id this by setting).2 F F1($SIG{CHLD})3.528 E F0(to)3.528 E F1 ("IGNORE")3.528 E F0 6.028(.S)C 1.028(ee also perlipc for more e)-6.028 F 1.028(xamples of)-.15 F(forking and reaping morib)128 568.8 Q (und children.)-.2 E .154(Note that if your fork)128 586.8 R .155 (ed child inherits system \214le descriptors lik)-.1 F(e)-.1 E/F3 9 /Times-Roman@0 SF(STDIN)2.655 E F0(and)2.655 E F3(STDOUT)2.655 E F0 .155 (that are actually)2.655 F .476(connected by a pipe or sock)128 598.8 R .476(et, e)-.1 F -.15(ve)-.25 G 2.976(ni).15 G 2.976(fy)-2.976 G .476 (ou e)-2.976 F .476(xit, then the remote serv)-.15 F .476 (er \(such as, say)-.15 F 2.976(,a)-.65 G F3(CGI)-.001 E F0 .475 (script or a)2.975 F .17 (backgrounded job launched from a remote shell\) w)128 610.8 R(on')-.1 E 2.671(tt)-.18 G .171(hink you')-2.671 F .171(re done.)-.5 F -1.1(Yo) 5.171 G 2.671(us)1.1 G .171(hould reopen those to)-2.671 F F2(/de)128 622.8 Q(v/null)-.15 E F0(if it')2.5 E 2.5(sa)-.55 G .3 -.15(ny i)-2.5 H (ssue.).15 E(format)108 639.6 Q(Declare a picture format for use by the) 128 651.6 Q F1(write)2.5 E F0 2.5(function. F)2.5 F(or e)-.15 E(xample:) -.15 E F1(format Something =)152 669.6 Q(Test: @<<<<<<<< @||||| @>>>>>) 176 681.6 Q 24($str, $%,)212 693.6 R(\010$\010 . int\($num\))24 E(.)152 705.6 Q($str = "widget";)152 729.6 Q F0(perl v5.14.2)72 768 Q 198.17 (2011-10-01 26)162.62 F 0 Cg EP %%Page: 27 27 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($num = $cost/$quantity;)152 84 Q($~ = \010Something\010;)152 96 Q (write;)152 108 Q F0(See perlform for man)128 126 Q 2.5(yd)-.15 G (etails and e)-2.5 E(xamples.)-.15 E(formline)108 142.8 Q/F2 9 /Times-Roman@0 SF(PICTURE)2.5 E F0(,LIST)A .151 (This is an internal function used by)128 154.8 R F1(format)2.651 E F0 .151(s, though you may call it, too.)B .15 (It formats \(see perlform\) a)5.15 F 2.688(list of v)128 166.8 R 2.688 (alues according to the contents of)-.25 F F2(PICTURE)5.188 E F0 5.189 (,p)C 2.689(lacing the output into the format output)-5.189 F (accumulator)128 178.8 Q(,)-.4 E F1($^A)2.835 E F0(\(or)2.835 E F1 ($ACCUMULATOR)2.835 E F0 .335(in English\).)2.835 F(Ev)5.335 E(entually) -.15 E 2.835(,w)-.65 G .335(hen a)-2.835 F F1(write)2.834 E F0 .334 (is done, the contents)2.834 F(of)128 190.8 Q F1($^A)3.066 E F0 .567 (are written to some \214lehandle.)3.066 F -1.1(Yo)5.567 G 3.067(uc)1.1 G .567(ould also read)-3.067 F F1($^A)3.067 E F0 .567(and then set)3.067 F F1($^A)3.067 E F0 .567(back to)3.067 F F1("")3.067 E F0 5.567(.N)C (ote)-5.567 E 1.898(that a format typically does one)128 202.8 R F1 (formline)4.397 E F0 1.897(per line of form, b)4.397 F 1.897(ut the)-.2 F F1(formline)4.397 E F0 1.897(function itself)4.397 F(doesn')128 214.8 Q 2.761(tc)-.18 G .261(are ho)-2.761 F 2.761(wm)-.25 G(an)-2.761 E 2.761 (yn)-.15 G -.25(ew)-2.761 G .261(lines are embedded in the).25 F F2 (PICTURE)2.761 E F0 5.261(.T)C .261(his means that the)-5.261 F F1(~) 2.761 E F0(and)2.761 E F1(~~)2.761 E F0(tok)2.761 E(ens)-.1 E 2.263 (treat the entire)128 226.8 R F2(PICTURE)4.763 E F0 2.263 (as a single line.)4.763 F -1.1(Yo)7.263 G 4.763(um)1.1 G 2.263 (ay therefore need to use multiple formlines to)-4.763 F (implement a single record format, just lik)128 238.8 Q 2.5(et)-.1 G(he) -2.5 E F1(format)2.5 E F0(compiler)2.5 E(.)-.55 E .514 (Be careful if you put double quotes around the picture, because an)128 256.8 R F1(@)3.015 E F0 .515(character may be tak)3.015 F .515 (en to mean)-.1 F(the be)128 268.8 Q(ginning of an array name.)-.15 E F1 (formline)5 E F0(al)2.5 E -.1(wa)-.1 G(ys returns true.).1 E (See perlform for other e)5 E(xamples.)-.15 E .653 (If you are trying to use this instead of)128 286.8 R F1(write)3.153 E F0 .653(to capture the output, you may \214nd it easier to open a)3.153 F(\214lehandle to a scalar \()128 298.8 Q F1(open $fh, ">", \\$output)A F0 2.5(\)a)C(nd write to that instead.)-2.5 E(getc)108 315.6 Q F2 (FILEHANDLE)2.5 E F0(getc)108 327.6 Q .456(Returns the ne)128 339.6 R .457(xt character from the input \214le attached to)-.15 F F2 (FILEHANDLE)2.957 E F0 2.957(,o)C 2.957(rt)-2.957 G .457 (he unde\214ned v)-2.957 F .457(alue at end)-.25 F 1.001 (of \214le or if there w)128 351.6 R 1.001 (as an error \(in the latter case)-.1 F F1($!)3.501 E F0 1.001 (is set\).)3.501 F(If)6.001 E F2(FILEHANDLE)3.501 E F0 1.001 (is omitted, reads from)3.501 F F2(STDIN)128 363.6 Q F0 7.826(.T)C 2.827 (his is not particularly ef)-7.826 F 5.327(\214cient. Ho)-.25 F(we)-.25 E -.15(ve)-.25 G 3.627 -.4(r, i).15 H 5.327(tc).4 G 2.827 (annot be used by itself to fetch single)-5.327 F(characters without w) 128 375.6 Q(aiting for the user to hit enter)-.1 E 5(.F)-.55 G (or that, try something more lik)-5.15 E(e:)-.1 E F1 (if \($BSD_STYLE\) {)152 393.6 Q (system "stty cbreak /dev/tty 2>&1";)176 405.6 Q(})152 417.6 Q(else {)152 429.6 Q (system "stty", \010\255icanon\010, \010eol\010, "\\001";)176 441.6 Q(}) 152 453.6 Q($key = getc\(STDIN\);)152 477.6 Q(if \($BSD_STYLE\) {)152 501.6 Q(system "stty \255cbreak /dev/tty 2>&1";)176 513.6 Q (})152 525.6 Q(else {)152 537.6 Q(system \010stty\010, \010icanon\010, \ \010eol\010, \010^@\010; # ASCII NUL)176 549.6 Q(})152 561.6 Q (print "\\n";)152 573.6 Q F0(Determination of whether)128 591.6 Q F1 ($BSD_STYLE)2.5 E F0(should be set is left as an e)2.5 E -.15(xe)-.15 G (rcise to the reader).15 E(.)-.55 E(The)128 609.6 Q F1(POSIX::getattr) 7.002 E F0 4.502 (function can do this more portably on systems purporting)7.002 F F2 (POSIX)7.001 E F0 3.454(compliance. See)128 621.6 R .954(also the)3.454 F F1(Term::ReadKey)3.454 E F0 .955(module from your nearest)3.454 F F2 (CP)3.455 E(AN)-.828 E F0 .955(site; details on)3.455 F F2(CP)3.455 E (AN)-.828 E F0(can be found under `)128 633.6 Q(`)-.74 E F2(CP)A(AN) -.828 E F0 1.48 -.74('' i)D 2.5(np).74 G(erlmodlib)-2.5 E(.)-.4 E (getlogin)108 650.4 Q .596(This implements the C library function of th\ e same name, which on most systems returns the current)128 662.4 R (login from)128 674.4 Q/F3 10/Times-Italic@0 SF(/etc/utmp)2.5 E F0 2.5 (,i)C 2.5(fa)-2.5 G -.15(ny)-2.5 G 5(.I)-.5 G 2.5(fi)-5 G 2.5(tr)-2.5 G (eturns the empty string, use)-2.5 E F1(getpwuid)2.5 E F0(.)A F1 ($login = getlogin || getpwuid\($<\) || "Kilroy";)152 692.4 Q F0 (Do not consider)128 710.4 Q F1(getlogin)2.5 E F0 (for authentication: it is not as secure as)2.5 E F1(getpwuid)2.5 E F0 (.)A(perl v5.14.2)72 768 Q 198.17(2011-10-01 27)162.62 F 0 Cg EP %%Page: 28 28 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(getpeername)108 84 Q/F1 9/Times-Roman@0 SF(SOCKET)2.5 E F0(Returns the pack)128 96 Q (ed sockaddr address of the other end of the)-.1 E F1(SOCKET)2.5 E F0 (connection.)2.5 E/F2 10/Courier@0 SF(use Socket;)152 114 Q 18 ($hersockaddr =)152 126 R(getpeername\(SOCK\);)6 E (\($port, $iaddr\) = sockaddr_in\($hersockaddr\);)152 138 Q 18 ($herhostname =)152 150 R(gethostbyaddr\($iaddr, AF_INET\);)6 E 24 ($herstraddr =)152 162 R(inet_ntoa\($iaddr\);)6 E F0(getpgrp)108 178.8 Q F1(PID)2.5 E F0 1.319 (Returns the current process group for the speci\214ed)128 190.8 R F1 (PID)3.819 E F0 6.32(.U)C 1.32(se a)-6.32 F F1(PID)3.82 E F0(of)3.82 E F2(0)3.82 E F0 1.32(to get the current process)3.82 F 1.079 (group for the current process.)128 202.8 R -.4(Wi)6.078 G 1.078 (ll raise an e).4 F 1.078(xception if used on a machine that doesn')-.15 F 3.578(ti)-.18 G(mplement)-3.578 E/F3 10/Times-Italic@0 SF -.1(ge)128 214.8 S(tpgrp).1 E F0 3.246(\(2\). If)1.666 F F1(PID)3.246 E F0 .746 (is omitted, returns the process group of the current process.)3.246 F .747(Note that the)5.747 F F1(POSIX)3.247 E F0 -.15(ve)128 226.8 S (rsion of).15 E F2(getpgrp)2.5 E F0(does not accept a)2.5 E F1(PID)2.5 E F0(ar)2.5 E(gument, so only)-.18 E F2(PID==0)2.5 E F0 (is truly portable.)2.5 E(getppid)108 243.6 Q (Returns the process id of the parent process.)128 255.6 Q .456 (Note for Linux users: on Linux, the C functions)128 273.6 R F2 (getpid\(\))2.956 E F0(and)2.956 E F2(getppid\(\))2.955 E F0 .455 (return dif)2.955 F .455(ferent v)-.25 F(alues)-.25 E .495(from dif)128 285.6 R .495(ferent threads. In order to be portable, this beha)-.25 F .496(vior is not re\215ected by the Perl-le)-.2 F -.15(ve)-.25 G 2.996 (lf).15 G(unction)-2.996 E F2(getppid\(\))128 297.6 Q F0 5.125(,t)C 2.625(hat returns a consistent v)-5.125 F 2.624 (alue across threads. If you w)-.25 F 2.624(ant to call the underlying) -.1 F F2(getppid\(\))128 309.6 Q F0 2.5(,y)C(ou may use the)-2.5 E F1 (CP)2.5 E(AN)-.828 E F0(module)2.5 E F2(Linux::Pid)2.5 E F0(.)A (getpriority)108 326.4 Q F1(WHICH)2.5 E F0(,WHO)A .176 (Returns the current priority for a process, a process group, or a user) 128 338.4 R 5.176(.\()-.55 G(See)-5.176 E F2(getpriority\(2\))2.676 E F0 2.676(.\) W)B(ill)-.4 E(raise a f)128 350.4 Q(atal e)-.1 E (xception if used on a machine that doesn')-.15 E 2.5(ti)-.18 G (mplement)-2.5 E F3 -.1(ge)2.5 G(tpriority).1 E F0(\(2\).)1.666 E (getpwnam)108 367.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(getgrnam)108 379.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(gethostbyname)108 391.2 Q F1 -.315(NA) 2.5 G(ME).315 E F0(getnetbyname)108 403.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(getprotobyname)108 415.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(getpwuid) 108 427.2 Q F1(UID)2.5 E F0(getgr)108 439.2 Q(gid)-.18 E F1(GID)2.5 E F0 (getservbyname)108 451.2 Q F1 -.315(NA)2.5 G(ME).315 E F0(,PR)A -1.88 -.4(OT O)-.4 H(gethostbyaddr)108 463.2 Q F1(ADDR)2.5 E F0(,ADDR)A(TYPE) -.6 E(getnetbyaddr)108 475.2 Q F1(ADDR)2.5 E F0(,ADDR)A(TYPE)-.6 E (getprotobynumber)108 487.2 Q F1(NUMBER)2.5 E F0(getservbyport)108 499.2 Q F1(POR)2.5 E(T)-.54 E F0(,PR)A -1.88 -.4(OT O)-.4 H(getpwent)108 511.2 Q(getgrent)108 523.2 Q(gethostent)108 535.2 Q(getnetent)108 547.2 Q (getprotoent)108 559.2 Q(getserv)108 571.2 Q(ent)-.15 E(setpwent)108 583.2 Q(setgrent)108 595.2 Q(sethostent)108 607.2 Q F1(ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(setnetent)108 619.2 Q F1(ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(setprotoent)108 631.2 Q F1(ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(setserv)108 643.2 Q(ent)-.15 E F1 (ST)2.5 E -.63 -.945(AY O)-.837 H(PEN).945 E F0(endpwent)108 655.2 Q (endgrent)108 667.2 Q(endhostent)108 679.2 Q(endnetent)108 691.2 Q (endprotoent)108 703.2 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 28) 162.62 F 0 Cg EP %%Page: 29 29 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(endserv)108 84 Q (ent)-.15 E 1.084(These routines are the same as their counterparts in \ the system C library)128 96 R 6.083(.I)-.65 G 3.583(nl)-6.083 G 1.083 (ist conte)-3.583 F 1.083(xt, the return)-.15 F -.25(va)128 108 S (lues from the v).25 E(arious get routines are as follo)-.25 E(ws:)-.25 E/F1 10/Courier@0 SF(\($name,$passwd,$uid,$gid,)152 126 Q ($quota,$comment,$gcos,$dir,$shell,$expire\) = getpw*)170 138 Q (\($name,$passwd,$gid,$members\) = getgr*)152 150 Q (\($name,$aliases,$addrtype,$length,@addrs\) = gethost*)152 162 Q (\($name,$aliases,$addrtype,$net\) = getnet*)152 174 Q (\($name,$aliases,$proto\) = getproto*)152 186 Q (\($name,$aliases,$port,$proto\) = getserv*)152 198 Q F0 (\(If the entry doesn')128 216 Q 2.5(te)-.18 G (xist you get an empty list.\))-2.65 E 1.444(The e)128 234 R 1.444 (xact meaning of the)-.15 F F1($gcos)3.944 E F0 1.444(\214eld v)3.944 F 1.444(aries b)-.25 F 1.445 (ut it usually contains the real name of the user \(as)-.2 F 1.36(oppos\ ed to the login name\) and other information pertaining to the user)128 246 R 6.36(.B)-.55 G -2.1 -.25(ew a)-6.36 H 1.36(re, ho).25 F(we)-.25 E -.15(ve)-.25 G 2.16 -.4(r, t).15 H 1.36(hat in).4 F(man)128 258 Q 2.813 (ys)-.15 G .314(ystem users are able to change this information and the\ refore it cannot be trusted and therefore)-2.813 F(the)128 270 Q F1 ($gcos)2.659 E F0 .159(is tainted \(see perlsec\).)2.659 F(The)5.159 E F1($passwd)2.659 E F0(and)2.659 E F1($shell)2.658 E F0 2.658(,u)C(ser') -2.658 E 2.658(se)-.55 G .158(ncrypted passw)-2.658 F .158 (ord and login)-.1 F(shell, are also tainted, for the same reason.)128 282 Q .443(In scalar conte)128 300 R .443 (xt, you get the name, unless the function w)-.15 F .444 (as a lookup by name, in which case you get)-.1 F (the other thing, whate)128 312 Q -.15(ve)-.25 G 2.5(ri).15 G 2.5(ti) -2.5 G 2.5(s. \(If)-2.5 F(the entry doesn')2.5 E 2.5(te)-.18 G (xist you get the unde\214ned v)-2.65 E 2.5(alue.\) F)-.25 F(or e)-.15 E (xample:)-.15 E F1 12($uid =)152 330 R(getpwnam\($name\);)6 E 6($name =) 152 342 R(getpwuid\($num\);)6 E 6($name =)152 354 R(getpwent\(\);)6 E 12 ($gid =)152 366 R(getgrnam\($name\);)6 E 6($name =)152 378 R (getgrgid\($num\);)6 E 6($name =)152 390 R(getgrent\(\);)6 E(#etc.)152 402 Q F0(In)128 420 Q/F2 10/Times-Italic@0 SF -.1(ge)3.387 G(tpw*\(\)).1 E F0 .887(the \214elds)3.387 F F1($quota)3.387 E F0(,)A F1($comment) 3.387 E F0 3.387(,a)C(nd)-3.387 E F1($expire)3.386 E F0 .886 (are special in that the)3.386 F 3.386(ya)-.15 G .886(re unsupported) -3.386 F .836(on man)128 432 R 3.336(ys)-.15 G 3.336(ystems. If)-3.336 F (the)3.336 E F1($quota)3.336 E F0 .836 (is unsupported, it is an empty scalar)3.336 F 5.836(.I)-.55 G 3.336(fi) -5.836 G 3.336(ti)-3.336 G 3.336(ss)-3.336 G .837(upported, it usually) -3.336 F .147(encodes the disk quota.)128 444 R .147(If the)5.147 F F1 ($comment)2.647 E F0 .147(\214eld is unsupported, it is an empty scalar) 2.647 F 5.146(.I)-.55 G 2.646(fi)-5.146 G 2.646(ti)-2.646 G 2.646(ss) -2.646 G(upported)-2.646 E .895(it usually encodes some administrati)128 456 R 1.195 -.15(ve c)-.25 H .895(omment about the user).15 F 5.895(.I) -.55 G 3.395(ns)-5.895 G .895(ome systems the)-3.395 F F1($quota)3.395 E F0(\214eld)3.395 E 2.471(may be)128 468 R F1($change)4.971 E F0(or)4.971 E F1($age)4.971 E F0 4.971<2c8c>C 2.471(elds that ha)-4.971 F 2.771 -.15 (ve t)-.2 H 4.971(od).15 G 4.971(ow)-4.971 G 2.47(ith passw)-4.971 F 2.47(ord aging.)-.1 F 2.47(In some systems the)7.47 F F1($comment)128 480 Q F0 .68(\214eld may be)3.18 F F1($class)3.18 E F0 5.681(.T)C(he) -5.681 E F1($expire)3.181 E F0 .681(\214eld, if present, encodes the e) 3.181 F .681(xpiration period of)-.15 F .204(the account or the passw) 128 492 R 2.704(ord. F)-.1 F .204(or the a)-.15 F -.25(va)-.2 G .204 (ilability and the e).25 F .203 (xact meaning of these \214elds in your system,)-.15 F 1.436 (please consult)128 504 R F2 -.1(ge)3.937 G(tpwnam).1 E F0 1.437 (\(3\) and your system')1.666 F(s)-.55 E F2(pwd.h)3.937 E F0 3.937 (\214le. Y)3.937 F 1.437(ou can also \214nd out from within Perl)-1.1 F .741(what your)128 516 R F1($quota)3.241 E F0(and)3.241 E F1($comment) 3.241 E F0 .741(\214elds mean and whether you ha)3.241 F 1.04 -.15(ve t) -.2 H(he).15 E F1($expire)3.24 E F0 .74(\214eld by using)3.24 F(the)128 528 Q F1(Config)3.538 E F0 1.038(module and the v)3.538 F(alues)-.25 E F1(d_pwquota)3.538 E F0(,)A F1(d_pwage)3.538 E F0(,)A F1(d_pwchange) 3.538 E F0(,)A F1(d_pwcomment)3.538 E F0 3.538(,a)C(nd)-3.538 E F1 (d_pwexpire)128 540 Q F0 6.029(.S)C(hado)-6.029 E 3.529(wp)-.25 G(assw) -3.529 E 1.029(ord \214les are supported only if your v)-.1 F 1.028 (endor has implemented them in)-.15 F 1.888(the intuiti)128 552 R 2.188 -.15(ve f)-.25 H 1.888(ashion that calling the re).05 F 1.888 (gular C library routines gets the shado)-.15 F 4.388(wv)-.25 G 1.888 (ersions if you')-4.538 F(re)-.5 E .336(running under pri)128 564 R (vile)-.25 E .336(ge or if there e)-.15 F .335(xists the)-.15 F F2 (shadow)2.835 E F0 .335 (\(3\) functions as found in System V \(this includes)1.666 F .093 (Solaris and Linux\).)128 576 R .093 (Those systems that implement a proprietary shado)5.093 F 2.593(wp)-.25 G(assw)-2.593 E .093(ord f)-.1 F .093(acility are unlik)-.1 F(ely)-.1 E (to be supported.)128 588 Q(The)128 606 Q F1($members)2.534 E F0 -.25 (va)2.534 G .034(lue returned by).25 F F2 -.1(ge)2.534 G(tgr*\(\)).1 E F0 .034(is a space-separated list of the login names of the members) 2.534 F(of the group.)128 618 Q -.15(Fo)128 636 S 2.868(rt).15 G(he) -2.868 E F2 -.1(ge)2.868 G(thost*\(\)).1 E F0 .369(functions, if the) 2.869 F F1(h_errno)2.869 E F0 -.25(va)2.869 G .369 (riable is supported in C, it will be returned to you via).25 F F1($?) 128 648 Q F0 .168(if the function call f)2.668 F 2.668(ails. The)-.1 F F1(@addrs)2.668 E F0 -.25(va)2.668 G .168 (lue returned by a successful call is a list of ra).25 F 2.667(wa)-.15 G (ddresses)-2.667 E .043(returned by the corresponding library call.)128 660 R .043(In the Internet domain, each address is four bytes long; you) 5.043 F(can unpack it by saying something lik)128 672 Q(e:)-.1 E F1 (\($a,$b,$c,$d\) = unpack\(\010W4\010,$addr[0]\);)152 690 Q F0(The Sock) 128 708 Q(et library mak)-.1 E(es this slightly easier:)-.1 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 29)162.62 F 0 Cg EP %%Page: 30 30 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Socket;)152 84 Q ($iaddr = inet_aton\("127.1"\); # or whatever address)152 96 Q 6 ($name =)152 108 R(gethostbyaddr\($iaddr, AF_INET\);)6 E 6(#o)152 132 S 6(rg)-6 G(oing the other way)-6 E($straddr = inet_ntoa\($iaddr\);)152 144 Q F0(In the opposite w)128 162 Q(ay)-.1 E 2.5(,t)-.65 G 2.5(or)-2.5 G(esolv)-2.5 E 2.5(eah)-.15 G(ostname to the)-2.5 E/F2 9/Times-Roman@0 SF(IP)2.5 E F0(address you can write this:)2.5 E F1(use Socket;)152 180 Q($packed_ip = gethostbyname\("www.perl.org"\);)152 192 Q (if \(defined $packed_ip\) {)152 204 Q ($ip_address = inet_ntoa\($packed_ip\);)176 216 Q(})152 228 Q F0(Mak)128 246 Q 3.77(es)-.1 G 1.27(ure <)-3.77 F/F3 10/Times-Italic@0 SF -.1(ge)C (thostbyname\(\)).1 E F0 3.77(>i)C 3.77(sc)-3.77 G 1.27(alled in)-3.77 F F2(SCALAR)3.77 E F0(conte)3.77 E 1.27(xt and that its return v)-.15 F 1.269(alue is check)-.25 F 1.269(ed for)-.1 F(de\214nedness.)128 258 Q .302(If you get tired of remembering which element of the return list c\ ontains which return v)128 276 R .302(alue, by-name)-.25 F(interf)128 288 Q 2.724(aces are pro)-.1 F 2.724(vided in standard modules:)-.15 F F1(File::stat)5.224 E F0(,)A F1(Net::hostent)5.223 E F0(,)A F1 (Net::netent)5.223 E F0(,)A F1(Net::protoent)128 300 Q F0(,)A F1 (Net::servent)18.89 E F0(,)A F1(Time::gmtime)18.89 E F0(,)A F1 (Time::localtime)18.89 E F0 18.89(,a)C(nd)-18.89 E F1(User::grent)128 312 Q F0 5.673(.T)C .673(hese o)-5.673 F -.15(ve)-.15 G .673 (rride the normal b).15 F .673(uilt-ins, supplying v)-.2 F .672 (ersions that return objects with the)-.15 F (appropriate names for each \214eld.)128 324 Q -.15(Fo)5 G 2.5(re).15 G (xample:)-2.65 E F1(use File::stat;)146 342 Q(use User::pwent;)146 354 Q ($is_his = \(stat\($filename\)\255>uid == pwent\($whoever\)\255>uid\);) 146 366 Q F0(Ev)128 384 Q 3.564(en though it looks as though the)-.15 F (y')-.15 E 3.565(re the same method calls \(uid\), the)-.5 F 6.065(ya) -.15 G(ren')-6.065 E 3.565(t, because a)-.18 F F1(File::stat)128 396 Q F0(object is dif)2.5 E(ferent from a)-.25 E F1(User::pwent)2.5 E F0 (object.)2.5 E(getsockname)108 412.8 Q F2(SOCKET)2.5 E F0 .77 (Returns the pack)128 424.8 R .77 (ed sockaddr address of this end of the)-.1 F F2(SOCKET)3.27 E F0 .77 (connection, in case you don')3.27 F 3.269(tk)-.18 G(no)-3.269 E(w)-.25 E(the address because you ha)128 436.8 Q .3 -.15(ve s)-.2 H -2.15 -.25 (ev e).15 H(ral dif).25 E(ferent IPs that the connection might ha)-.25 E .3 -.15(ve c)-.2 H(ome in on.).15 E F1(use Socket;)152 454.8 Q ($mysockaddr = getsockname\(SOCK\);)152 466.8 Q (\($port, $myaddr\) = sockaddr_in\($mysockaddr\);)152 478.8 Q (printf "Connect to %s [%s]\\n",)152 490.8 Q (scalar gethostbyaddr\($myaddr, AF_INET\),)170 502.8 Q (inet_ntoa\($myaddr\);)170 514.8 Q F0(getsock)108 531.6 Q(opt)-.1 E F2 (SOCKET)2.5 E F0(,LEVEL,OPTN)A(AME)-.35 E .004(Queries the option named) 128 543.6 R F2(OPTN)2.505 E(AME)-.315 E F0 .005(associated with)2.505 F F2(SOCKET)2.505 E F0 .005(at a gi)2.505 F -.15(ve)-.25 G(n).15 E F2 (LEVEL)2.505 E F0 5.005(.O)C .005(ptions may e)-5.005 F .005(xist at) -.15 F 2.95(multiple protocol le)128 555.6 R -.15(ve)-.25 G 2.95 (ls depending on the sock).15 F 2.949(et type, b)-.1 F 2.949 (ut at least the uppermost sock)-.2 F 2.949(et le)-.1 F -.15(ve)-.25 G (l).15 E F2(SOL_SOCKET)128 567.6 Q F0 2.185(\(de\214ned in the)4.685 F F1(Socket)4.685 E F0 2.185(module\) will e)4.685 F 2.186(xist. T)-.15 F 4.686(oq)-.8 G 2.186(uery options at another le)-4.686 F -.15(ve)-.25 G 4.686(lt).15 G(he)-4.686 E .127(protocol number of the appropriate prot\ ocol controlling the option should be supplied. F)128 579.6 R .127(or e) -.15 F .127(xample, to)-.15 F .807 (indicate that an option is to be interpreted by the)128 591.6 R F2(TCP) 3.307 E F0(protocol,)3.307 E F2(LEVEL)3.307 E F0 .808 (should be set to the protocol)3.307 F(number of)128 603.6 Q F2(TCP)2.5 E F0 2.5(,w)C(hich you can get using)-2.5 E F1(getprotobyname)2.5 E F0 (.)A .086(The function returns a pack)128 621.6 R .086 (ed string representing the requested sock)-.1 F .086(et option, or)-.1 F F1(undef)2.586 E F0 .086(on error)2.586 F 2.586(,w)-.4 G(ith)-2.586 E 2.145(the reason for the error placed in)128 633.6 R F1($!)4.645 E F0 4.645(.J)C 2.145(ust what is in the pack)-4.645 F 2.146 (ed string depends on)-.1 F F2(LEVEL)4.646 E F0(and)4.646 E F2(OPTN)128 645.6 Q(AME)-.315 E F0 2.61(;c)C(onsult)-2.61 E F3 -.1(ge)2.61 G(tsoc).1 E -.1(ko)-.2 G(pt).1 E F0 .11(\(2\) for details.)1.666 F 2.61(Ac)5.11 G .109(ommon case is that the option is an inte)-2.61 F(ger)-.15 E 2.609 (,i)-.4 G 2.609(nw)-2.609 G(hich)-2.609 E(case the result is a pack)128 657.6 Q(ed inte)-.1 E(ger)-.15 E 2.5(,w)-.4 G(hich you can decode using) -2.5 E F1(unpack)2.5 E F0(with the)2.5 E F1(i)2.5 E F0(\(or)2.5 E F1(I) 2.5 E F0 2.5(\)f)C(ormat.)-2.5 E(Here')128 675.6 Q 2.5(sa)-.55 G 2.5(ne) -2.5 G(xample to test whether Nagle')-2.65 E 2.5(sa)-.55 G (lgorithm is enabled on a sock)-2.5 E(et:)-.1 E F1 (use Socket qw\(:all\);)152 693.6 Q (defined\(my $tcp = getprotobyname\("tcp"\)\))152 717.6 Q (or die "Could not determine the protocol number for tcp";)176 729.6 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 30)162.62 F 0 Cg EP %%Page: 31 31 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#m)152 84 S 6(y$)-6 G(tcp = IPPROTO_TCP; # Alternative)-6 E (my $packed = getsockopt\($socket, $tcp, TCP_NODELAY\))152 96 Q (or die "getsockopt TCP_NODELAY: $!";)176 108 Q (my $nodelay = unpack\("I", $packed\);)152 120 Q(print "Nagle\010s algo\ rithm is turned ", $nodelay ? "off\\n" : "on\\n";)152 132 Q F0(gi)108 148.8 Q -.15(ve)-.25 G(n).15 E/F2 9/Times-Roman@0 SF .25(EXPR BLOCK)2.5 F F0(gi)108 160.8 Q -.15(ve)-.25 G(n).15 E F2(BLOCK)2.5 E F1(given)128 172.8 Q F0 .01(is analogous to the)2.51 F F1(switch)2.51 E F0 -.1(ke) 2.51 G(yw)-.05 E .01(ord in other languages.)-.1 F F1(given)2.51 E F0 (and)2.51 E F1(when)2.51 E F0 .01(are used in Perl to)2.51 F(implement) 128 184.8 Q F1(switch)2.5 E F0(/)A F1(case)A F0(lik)2.5 E 2.5(es)-.1 G 2.5(tatements. Only)-2.5 F -.2(av)2.5 G(ailable after Perl 5.10.)-.05 E -.15(Fo)5 G 2.5(re).15 G(xample:)-2.65 E F1(use v5.10;)152 202.8 Q (given \($fruit\) {)152 214.8 Q(when \(/apples?/\) {)176 226.8 Q (print "I like apples.")200 238.8 Q(})176 250.8 Q(when \(/oranges?/\) {) 176 262.8 Q(print "I don\010t like oranges.")200 274.8 Q(})176 286.8 Q (default {)176 298.8 Q(print "I don\010t like anything")200 310.8 Q(}) 176 322.8 Q(})152 334.8 Q F0(See `)128 352.8 Q(`Switch statements')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlsyn for detailed information.)-2.5 E (glob)108 369.6 Q F2(EXPR)2.5 E F0(glob)108 381.6 Q .24(In list conte) 128 393.6 R .239(xt, returns a \(possibly empty\) list of \214lename e) -.15 F .239(xpansions on the v)-.15 F .239(alue of)-.25 F F2(EXPR)2.739 E F0 .239(such as the)2.739 F 3.36(standard Unix shell)128 405.6 R/F3 10 /Times-Italic@0 SF(/bin/csh)5.86 E F0 -.1(wo)5.86 G 3.36 (uld do. In scalar conte).1 F 3.36 (xt, glob iterates through such \214lename)-.15 F -.15(ex)128 417.6 S .524(pansions, returning undef when the list is e).15 F .523 (xhausted. This is the internal function implementing the)-.15 F F1 (<*.c>)128 429.6 Q F0(operator)3.16 E 3.16(,b)-.4 G .661 (ut you can use it directly)-3.36 F 3.161(.I)-.65 G(f)-3.161 E F2(EXPR) 3.161 E F0 .661(is omitted,)3.161 F F1($_)3.161 E F0 .661(is used.)3.161 F(The)5.661 E F1(<*.c>)3.161 E F0 .661(operator is)3.161 F (discussed in more detail in `)128 441.6 Q(`I/O Operators')-.74 E 2.5 ('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E 1.134(Note that)128 459.6 R F1 (glob)3.634 E F0 1.134(splits its ar)3.634 F 1.134 (guments on whitespace and treats each se)-.18 F 1.134 (gment as separate pattern.)-.15 F(As)6.134 E(such,)128 471.6 Q F1 1.063 (glob\("*.c *.h"\))3.563 F F0 1.063(matches all \214les with a)3.563 F F3(.c)3.564 E F0(or)3.564 E F3(.h)3.564 E F0 -.15(ex)3.564 G 3.564 (tension. The).15 F -.15(ex)3.564 G(pression).15 E F1(glob\(".*)3.564 E (*"\))128 483.6 Q F0(matches all \214les in the current w)2.5 E (orking directory)-.1 E(.)-.65 E .276 (If non-empty braces are the only wildcard characters used in the)128 501.6 R F1(glob)2.775 E F0 2.775(,n)C 2.775<6f8c>-2.775 G .275 (lenames are matched, b)-2.775 F(ut)-.2 E .297(potentially man)128 513.6 R 2.797(ys)-.15 G .297(trings are returned.)-2.797 F -.15(Fo)5.297 G 2.797(re).15 G .298 (xample, this produces nine strings, one for each pairing of)-2.947 F (fruits and colors:)128 525.6 Q F1(@many =)152 543.6 Q (glob "{apple,tomato,cherry}={green,yellow,red}";)12 E F0(Be)128 561.6 Q .263 (ginning with v5.6.0, this operator is implemented using the standard) -.15 F F1(File::Glob)2.762 E F0 -.15(ex)2.762 G 2.762(tension. See).15 F (File::Glob for details, including)128 573.6 Q F1(bsd_glob)2.5 E F0 (which does not treat whitespace as a pattern separator)2.5 E(.)-.55 E (gmtime)108 590.4 Q F2(EXPR)2.5 E F0(gmtime)108 602.4 Q -.8(Wo)128 614.4 S(rks just lik).8 E 2.5(el)-.1 G(ocaltime b)-2.5 E(ut the returned v)-.2 E(alues are localized for the standard Greenwich time zone.)-.25 E .593 (Note: When called in list conte)128 632.4 R(xt,)-.15 E F1($isdst)3.093 E F0 3.093(,t)C .593(he last v)-3.093 F .594 (alue returned by gmtime, is al)-.25 F -.1(wa)-.1 G(ys).1 E F1(0)3.094 E F0 5.594(.T)C .594(here is)-5.594 F(no Daylight Sa)128 644.4 Q(ving T) -.2 E(ime in)-.35 E F2(GMT)2.5 E F0(.)A(See `)128 662.4 Q(`gmtime')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlport for portability concerns.)-2.5 E (goto)108 679.2 Q F2(LABEL)2.5 E F0(goto)108 691.2 Q F2(EXPR)2.5 E F0 (goto &N)108 703.2 Q(AME)-.35 E(The)128 715.2 Q F1(goto\255LABEL)2.654 E F0 .154(form \214nds the statement labeled with)2.654 F F2(LABEL)2.654 E F0 .154(and resumes e)2.654 F -.15(xe)-.15 G .153(cution there. It can') .15 F(t)-.18 E .396(be used to get out of a block or subroutine gi)128 727.2 R -.15(ve)-.25 G 2.897(nt).15 G(o)-2.897 E F1(sort)2.897 E F0 5.397(.I)C 2.897(tc)-5.397 G .397(an be used to go almost an)-2.897 F .397(ywhere else)-.15 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 31) 162.62 F 0 Cg EP %%Page: 32 32 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 2.018 (within the dynamic scope, including out of subroutines, b)128 84 R 2.018(ut it')-.2 F 4.518(su)-.55 G 2.018 (sually better to use some other)-4.518 F .545(construct such as)128 96 R/F1 10/Courier@0 SF(last)3.045 E F0(or)3.045 E F1(die)3.045 E F0 5.545 (.T)C .545(he author of Perl has ne)-5.545 F -.15(ve)-.25 G 3.046(rf).15 G .546(elt the need to use this form of)-3.046 F F1(goto)3.046 E F0 .559 (\(in Perl, that is; C is another matter\).)128 108 R .559(\(The dif) 5.559 F .559(ference is that C does not of)-.25 F .558 (fer named loops combined)-.25 F(with loop control.)128 120 Q (Perl does, and this replaces most structured uses of)5 E F1(goto)2.5 E F0(in other languages.\))2.5 E(The)128 138 Q F1(goto\255EXPR)2.903 E F0 .403(form e)2.903 F .404 (xpects a label name, whose scope will be resolv)-.15 F .404 (ed dynamically)-.15 F 5.404(.T)-.65 G .404(his allo)-5.404 F(ws)-.25 E 2.359(for computed)128 150 R F1(goto)4.859 E F0 4.859(sp)C(er)-4.859 E /F2 9/Times-Roman@0 SF(FOR)4.859 E(TRAN)-.54 E F0 4.859(,b)C 2.359 (ut isn')-5.059 F 4.859(tn)-.18 G 2.359(ecessarily recommended if you') -4.859 F 2.359(re optimizing for)-.5 F(maintainability:)128 162 Q F1 (goto \("FOO", "BAR", "GLARCH"\)[$i];)152 180 Q F0 1.015(As sho)128 198 R 1.016(wn in this e)-.25 F(xample,)-.15 E F1(goto\255EXPR)3.516 E F0 1.016(is e)3.516 F -.15(xe)-.15 G 1.016(mpt from the `).15 F 1.016 (`looks lik)-.74 F 3.516(eaf)-.1 G(unction')-3.516 E 3.516('r)-.74 G 1.016(ule. A pair of)-3.516 F 3.94(parentheses follo)128 210 R 3.94 (wing it does not \(necessarily\) delimit its ar)-.25 F(gument.)-.18 E F1(goto\("NE"\)."XT")6.44 E F0(is)6.44 E(equi)128 222 Q -.25(va)-.25 G (lent to).25 E F1(goto NEXT)2.5 E F0(.)A .075(Use of)128 240 R F1 (goto\255LABEL)2.575 E F0(or)2.575 E F1(goto\255EXPR)2.575 E F0 .075 (to jump into a construct is deprecated and will issue a w)2.575 F (arning.)-.1 E(Ev)128 252 Q .315 (en then, it may not be used to go into an)-.15 F 2.815(yc)-.15 G .315 (onstruct that requires initialization, such as a subroutine)-2.815 F (or a)128 264 Q F1(foreach)2.5 E F0 2.5(loop. It)2.5 F(also can')2.5 E 2.5(tb)-.18 G 2.5(eu)-2.5 G (sed to go into a construct that is optimized a)-2.5 E -.1(wa)-.15 G -.65(y.).1 G(The)128 282 Q F1(goto\255&NAME)2.746 E F0 .247 (form is quite dif)2.746 F .247(ferent from the other forms of)-.25 F F1 (goto)2.747 E F0 5.247(.I)C 2.747(nf)-5.247 G .247(act, it isn')-2.847 F 2.747(tag)-.18 G .247(oto in the)-2.747 F 1.698 (normal sense at all, and doesn')128 294 R 4.198(th)-.18 G -2.25 -.2 (av e)-4.198 H 1.698(the stigma associated with other gotos.)4.398 F 1.698(Instead, it e)6.698 F 1.698(xits the)-.15 F 1.24 (current subroutine \(losing an)128 306 R 3.74(yc)-.15 G 1.24 (hanges set by)-3.74 F/F3 10/Times-Italic@0 SF(local\(\))3.74 E F0 3.74 (\)a)C 1.24(nd immediately calls in its place the named)-3.74 F .941 (subroutine using the current v)128 318 R .941(alue of)-.25 F F1(@_) 3.441 E F0 5.941(.T)C .941(his is used by)-5.941 F F1(AUTOLOAD)3.44 E F0 .94(subroutines that wish to load)3.44 F .313(another subroutine and th\ en pretend that the other subroutine had been called in the \214rst pla\ ce \(e)128 330 R(xcept)-.15 E .777(that an)128 342 R 3.277(ym)-.15 G .777(odi\214cations to)-3.277 F F1(@_)3.277 E F0 .777 (in the current subroutine are propag)3.277 F .776 (ated to the other subroutine.\))-.05 F(After)5.776 E(the)128 354 Q F1 (goto)2.5 E F0 2.5(,n)C(ot e)-2.5 E -.15(ve)-.25 G(n).15 E F1(caller)2.5 E F0(will be able to tell that this routine w)2.5 E(as called \214rst.) -.1 E F2 -.315(NA)128 372 S(ME).315 E F0(needn')2.674 E 2.674(tb)-.18 G 2.674(et)-2.674 G .175(he name of a subroutine; it can be a scalar v) -2.674 F .175(ariable containing a code reference or a)-.25 F (block that e)128 384 Q -.25(va)-.25 G(luates to a code reference.).25 E (grep)108 400.8 Q F2 .25(BLOCK LIST)2.5 F F0(grep)108 412.8 Q F2(EXPR) 2.5 E F0(,LIST)A .322(This is similar in spirit to, b)128 424.8 R .322 (ut not the same as,)-.2 F F3(gr)2.822 E(ep)-.37 E F0 .322 (\(1\) and its relati)1.666 F -.15(ve)-.25 G 2.821(s. In).15 F (particular)2.821 E 2.821(,i)-.4 G 2.821(ti)-2.821 G 2.821(sn)-2.821 G .321(ot limited)-2.821 F(to using re)128 436.8 Q(gular e)-.15 E (xpressions.)-.15 E(Ev)128 454.8 Q 1.599(aluates the)-.25 F F2(BLOCK) 4.099 E F0(or)4.099 E F2(EXPR)4.099 E F0 1.6(for each element of)4.1 F F2(LIST)4.1 E F0 1.6(\(locally setting)4.1 F F1($_)4.1 E F0 1.6 (to each element\) and)4.1 F .255(returns the list v)128 466.8 R .255 (alue consisting of those elements for which the e)-.25 F .255 (xpression e)-.15 F -.25(va)-.25 G .255(luated to true.).25 F .255 (In scalar)5.255 F(conte)128 478.8 Q (xt, returns the number of times the e)-.15 E(xpression w)-.15 E (as true.)-.1 E F1(@foo = grep\(!/^#/, @bar\);)152 496.8 Q 6(#w)24 G (eed out comments)-6 E F0(or equi)128 514.8 Q -.25(va)-.25 G(lently).25 E(,)-.65 E F1(@foo = grep {!/^#/} @bar;)152 532.8 Q 6(#w)24 G (eed out comments)-6 E F0 .475(Note that)128 550.8 R F1($_)2.975 E F0 .475(is an alias to the list v)2.975 F .475 (alue, so it can be used to modify the elements of the)-.25 F F2(LIST) 2.975 E F0 5.476(.W)C(hile)-5.476 E 1.617(this is useful and supported,\ it can cause bizarre results if the elements of)128 562.8 R F2(LIST) 4.117 E F0 1.617(are not v)4.117 F(ariables.)-.25 E(Similarly)128 574.8 Q 2.991(,g)-.65 G .492 (rep returns aliases into the original list, much as a for loop')-2.991 F 2.992(si)-.55 G(nde)-2.992 E 2.992(xv)-.15 G .492 (ariable aliases the list)-3.242 F 2.892(elements. That)128 586.8 R .391 (is, modifying an element of a list returned by grep \(for e)2.892 F .391(xample, in a)-.15 F F1(foreach)2.891 E F0(,)A F1(map)2.891 E F0 .986(or another)128 598.8 R F1(grep)3.486 E F0 3.487(\)a)C .987 (ctually modi\214es the element in the original list.)-3.487 F .987 (This is usually something to be)5.987 F -.2(avo)128 610.8 S (ided when writing clear code.).2 E(If)128 628.8 Q F1($_)2.698 E F0 .198 (is le)2.698 F .198(xical in the scope where the)-.15 F F1(grep)2.697 E F0 .197(appears \(because it has been declared with)2.697 F F1 .197 (my $_)2.697 F F0 2.697(\)t)C(hen,)-2.697 E .354 (in addition to being locally aliased to the list elements,)128 640.8 R F1($_)2.854 E F0 -.1(ke)2.855 G .355(eps being le).1 F .355 (xical inside the block; i.e., it)-.15 F(can')128 652.8 Q 2.5(tb)-.18 G 2.5(es)-2.5 G(een from the outside, a)-2.5 E -.2(vo)-.2 G(iding an).2 E 2.5(yp)-.15 G(otential side-ef)-2.5 E(fects.)-.25 E(See also `)128 670.8 Q(`map')-.74 E 2.5('f)-.74 G(or a list composed of the results of the) -2.5 E F2(BLOCK)2.5 E F0(or)2.5 E F2(EXPR)2.5 E F0(.)A(he)108 687.6 Q(x) -.15 E F2(EXPR)2.5 E F0(he)108 699.6 Q(x)-.15 E(Interprets)128 699.6 Q F2(EXPR)3.647 E F0 1.147(as a he)3.647 F 3.647(xs)-.15 G 1.146 (tring and returns the corresponding v)-3.647 F 3.646(alue. \(T)-.25 F 3.646(oc)-.8 G(on)-3.646 E -.15(ve)-.4 G 1.146(rt strings that might).15 F(start with either)128 711.6 Q F1(0)2.5 E F0(,)A F1(0x)2.5 E F0 2.5(,o) C(r)-2.5 E F1(0b)2.5 E F0 2.5(,s)C(ee `)-2.5 E(`oct')-.74 E 2.5('.\) If) -.74 F F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A (perl v5.14.2)72 768 Q 198.17(2011-10-01 32)162.62 F 0 Cg EP %%Page: 33 33 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (print hex \0100xAf\010; # prints \010175\010)152 84 Q (print hex \010aF\010;)152 96 Q 6(#s)18 G(ame)-6 E F0(He)128 114 Q 2.951 (xs)-.15 G .451(trings may only represent inte)-2.951 F 2.951 (gers. Strings)-.15 F .451(that w)2.951 F .452(ould cause inte)-.1 F .452(ger o)-.15 F -.15(ve)-.15 G(r\215o).15 E 2.952(wt)-.25 G .452 (rigger a w)-2.952 F(arning.)-.1 E 1.637 (Leading whitespace is not stripped, unlik)128 126 R(e)-.1 E/F2 10 /Times-Italic@0 SF(oct\(\))4.137 E F0 4.137(.T)C 4.137(op)-4.937 G 1.637 (resent something as he)-4.137 F 1.637(x, look into `)-.15 F -1.95 (`printf ')-.74 F(',)-.74 E -.74(``)128 138 S -1.95(sprintf ').74 F (', and `)-.74 E(`unpack')-.74 E('.)-.74 E(import)108 154.8 Q/F3 9 /Times-Roman@0 SF(LIST)2.5 E F0 .323(There is no b)128 166.8 R(uiltin) -.2 E F1(import)2.823 E F0 2.823(function. It)2.823 F .324 (is just an ordinary method \(subroutine\) de\214ned \(or inherited\)) 2.823 F 2.12(by modules that wish to e)128 178.8 R 2.119 (xport names to another module.)-.15 F(The)7.119 E F1(use)4.619 E F0 2.119(function calls the)4.619 F F1(import)4.619 E F0 (method for the package used.)128 190.8 Q(See also `)5 E(`use')-.74 E (', perlmod, and Exporter)-.74 E(.)-.55 E(inde)108 207.6 Q(x)-.15 E F3 (STR)2.5 E F0(,SUBSTR,POSITION)A(inde)108 219.6 Q(x)-.15 E F3(STR)2.5 E F0(,SUBSTR)A .467(The inde)128 231.6 R 2.967(xf)-.15 G .467 (unction searches for one string within another)-2.967 F 2.967(,b)-.4 G .468(ut without the wildcard-lik)-3.167 F 2.968(eb)-.1 G(eha)-2.968 E .468(vior of a)-.2 F .304(full re)128 243.6 R(gular)-.15 E(-e)-.2 E .304 (xpression pattern match.)-.15 F .304 (It returns the position of the \214rst occurrence of)5.304 F F3(SUBSTR) 2.803 E F0(in)2.803 E F3(STR)2.803 E F0 2.032(at or after)128 255.6 R F3 (POSITION)4.532 E F0 7.032(.I)C(f)-7.032 E F3(POSITION)4.532 E F0 2.032 (is omitted, starts searching from the be)4.532 F 2.032 (ginning of the string.)-.15 F F3(POSITION)128 267.6 Q F0 .18 (before the be)2.68 F .18 (ginning of the string or after its end is treated as if it were the be) -.15 F .179(ginning or the)-.15 F 1.955(end, respecti)128 279.6 R -.15 (ve)-.25 G(ly).15 E(.)-.65 E F3(POSITION)6.955 E F0 1.955 (and the return v)4.455 F 1.955(alue are based at)-.25 F F1(0)4.455 E F0 1.956(\(or whate)4.455 F -.15(ve)-.25 G 4.456(ry).15 G(ou')-4.456 E 2.256 -.15(ve s)-.5 H 1.956(et the).15 F F1($[)4.456 E F0 -.25(va)128 291.6 S .697(riable to).25 F 1.666<8a62>1.666 G .697(ut don')-1.866 F 3.197(td)-.18 G 3.197(ot)-3.197 G 3.197(hat\). If)-3.197 F .696 (the substring is not found,)3.197 F F1(index)3.196 E F0 .696 (returns one less than the base,)3.196 F(ordinarily)128 303.6 Q F1 2.5 E F0(.)A(int)108 320.4 Q F3(EXPR)2.5 E F0(int)108 332.4 Q .766 (Returns the inte)128 332.4 R .766(ger portion of)-.15 F F3(EXPR)3.266 E F0 5.766(.I)C(f)-5.766 E F3(EXPR)3.266 E F0 .767(is omitted, uses)3.267 F F1($_)3.267 E F0 5.767(.Y)C .767(ou should not use this function) -6.867 F .09(for rounding: one because it truncates to)128 344.4 R -.1 (wa)-.25 G(rds).1 E F1(0)2.59 E F0 2.59(,a)C .09(nd tw)-2.59 F 2.59(ob) -.1 G .09(ecause machine representations of \215oating-)-2.59 F 13.015 (point numbers can sometimes produce counterintuiti)128 356.4 R 13.315 -.15(ve r)-.25 H 15.515(esults. F).15 F 13.015(or e)-.15 F(xample,)-.15 E F1(int\(\2556.725/0.025\))128 368.4 Q F0 .871 (produces \255268 rather than the correct \255269; that')3.371 F 3.371 (sb)-.55 G .871(ecause it')-3.371 F 3.37(sr)-.55 G .87(eally more)-3.37 F(lik)128 380.4 Q 11.487<65ad>-.1 G 8.987 (268.99999999999994315658 instead.)-11.487 F(Usually)13.987 E 11.487(,t) -.65 G(he)-11.487 E F1(sprintf)11.488 E F0(,)A F1(printf)11.488 E F0 11.488(,o)C 11.488(rt)-11.488 G(he)-11.488 E F1(POSIX::floor)128 392.4 Q F0(and)2.5 E F1(POSIX::ceil)2.5 E F0(functions will serv)2.5 E 2.5(ey) -.15 G(ou better than will)-2.5 E F2(int\(\))2.5 E F0(.)A(ioctl)108 409.2 Q F3(FILEHANDLE)2.5 E F0(,FUNCTION,SCALAR)A(Implements the)128 421.2 Q F2(ioctl)2.5 E F0(\(2\) function.)1.666 E -1.1(Yo)5 G(u')1.1 E (ll probably \214rst ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1(require "sys/ioctl.ph";)152 439.2 Q 6(#p)12 G (robably in $Config{archlib}/sys/ioctl.ph)-6 E F0 2.887 (to get the correct function de\214nitions.)128 457.2 R(If)7.887 E F2 (sys/ioctl.ph)5.387 E F0(doesn')5.387 E 5.387(te)-.18 G 2.887 (xist or doesn')-5.537 F 5.387(th)-.18 G -2.25 -.2(av e)-5.387 H 2.887 (the correct)5.587 F .331(de\214nitions you')128 469.2 R .331(ll ha)-.1 F .631 -.15(ve t)-.2 H 2.831(or).15 G .331(oll your o)-2.831 F .331 (wn, based on your C header \214les such as)-.25 F F2() 2.832 E F0 5.332(.\()C .332(There is)-5.332 F 3.579(aP)128 481.2 S 1.079 (erl script called)-3.579 F/F4 10/Times-Bold@0 SF(h2ph)3.579 E F0 1.079 (that comes with the Perl kit that may help you in this, b)3.579 F 1.079 (ut it')-.2 F 3.578(sn)-.55 G(ontri)-3.578 E(vial.\))-.25 E F3(SCALAR) 128 493.2 Q F0 .811(will be read and/or written depending on the)3.311 F F3(FUNCTION)3.311 E F0 3.311(;aCp)C .811(ointer to the string v)-3.311 F .812(alue of)-.25 F F3(SCALAR)128 505.2 Q F0 1.167 (will be passed as the third ar)3.667 F 1.166(gument of the actual)-.18 F F1(ioctl)3.666 E F0 3.666(call. \(If)3.666 F F3(SCALAR)3.666 E F0 1.166(has no string)3.666 F -.25(va)128 517.2 S .234(lue b).25 F .234 (ut does ha)-.2 F .534 -.15(ve a n)-.2 H .235(umeric v).15 F .235 (alue, that v)-.25 F .235 (alue will be passed rather than a pointer to the string v)-.25 F(alue.) -.25 E 2.079 -.8(To g)128 529.2 T .479(uarantee this to be true, add a) .8 F F1(0)2.979 E F0 .478(to the scalar before using it.\))2.978 F(The) 5.478 E F1(pack)2.978 E F0(and)2.978 E F1(unpack)2.978 E F0(functions) 2.978 E(may be needed to manipulate the v)128 541.2 Q (alues of structures used by)-.25 E F1(ioctl)2.5 E F0(.)A(The return v) 128 559.2 Q(alue of)-.25 E F1(ioctl)2.5 E F0(\(and)2.5 E F1(fcntl)2.5 E F0 2.5(\)i)C 2.5(sa)-2.5 G 2.5(sf)-2.5 G(ollo)-2.5 E(ws:)-.25 E F1 (if OS returns:)152 577.2 Q(then Perl returns:)36 E 84(\2551 undefined) 176 589.2 R(value)6 E 84(0s)182 601.2 S(tring "0 but true")-84 E (anything else)152 613.2 Q(that number)66 E F0 1.343 (Thus Perl returns true on success and f)128 631.2 R 1.343(alse on f)-.1 F 1.343(ailure, yet you can still easily determine the actual)-.1 F -.25 (va)128 643.2 S(lue returned by the operating system:).25 E F1 ($retval = ioctl\(...\) || \2551;)152 661.2 Q (printf "System returned %d\\n", $retval;)152 673.2 Q F0 3.284 (The special string)128 691.2 R F1 3.284("0 but true")5.784 F F0 3.284 (is e)5.784 F -.15(xe)-.15 G 3.284(mpt from).15 F F45.784 E F0 3.283(complaints about improper numeric)5.784 F(con)128 703.2 Q -.15(ve) -.4 G(rsions.).15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 33)162.62 F 0 Cg EP %%Page: 34 34 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(join)108 84 Q/F1 9 /Times-Roman@0 SF(EXPR)2.5 E F0(,LIST)A .648 (Joins the separate strings of)128 96 R F1(LIST)3.148 E F0 .649 (into a single string with \214elds separated by the v)3.149 F .649 (alue of)-.25 F F1(EXPR)3.149 E F0 3.149(,a)C(nd)-3.149 E (returns that ne)128 108 Q 2.5(ws)-.25 G 2.5(tring. Example:)-2.5 F/F2 10/Courier@0 SF ($rec = join\(\010:\010, $login,$passwd,$uid,$gid,$gcos,$home,$shell\);) 152 126 Q F0(Be)128 144 Q -.1(wa)-.25 G(re that unlik).1 E(e)-.1 E F2 (split)2.5 E F0(,)A F2(join)2.5 E F0(doesn')2.5 E 2.5(tt)-.18 G(ak)-2.5 E 2.5(eap)-.1 G(attern as its \214rst ar)-2.5 E 2.5(gument. Compare)-.18 F -.74(``)2.5 G(split').74 E('.)-.74 E -.1(ke)108 160.8 S(ys)-.05 E F1 (HASH)2.5 E F0 -.1(ke)108 172.8 S(ys)-.05 E F1(ARRA)2.5 E(Y)-.945 E F0 -.1(ke)108 184.8 S(ys)-.05 E F1(EXPR)2.5 E F0 .059 (Returns a list consisting of all the k)128 196.8 R -.15(ey)-.1 G 2.559 (so).15 G 2.559(ft)-2.559 G .059 (he named hash, or the indices of an array)-2.559 F 2.559(.\()-.65 G .059(In scalar conte)-2.559 F(xt,)-.15 E(returns the number of k)128 208.8 Q -.15(ey)-.1 G 2.5(so).15 G 2.5(ri)-2.5 G(ndices.\))-2.5 E .408 (The k)128 226.8 R -.15(ey)-.1 G 2.908(so).15 G 2.908(fah)-2.908 G .408 (ash are returned in an apparently random order)-2.908 F 5.408(.T)-.55 G .409(he actual random order is subject to)-5.408 F .894 (change in future v)128 238.8 R .894(ersions of Perl, b)-.15 F .894 (ut it is guaranteed to be the same order as either the)-.2 F F2(values) 3.393 E F0(or)3.393 E F2(each)128 250.8 Q F0 .042 (function produces \(gi)2.542 F -.15(ve)-.25 G 2.542(nt).15 G .042 (hat the hash has not been modi\214ed\).)-2.542 F .043 (Since Perl 5.8.1 the ordering can)5.043 F 1.365(be dif)128 262.8 R 1.365(ferent e)-.25 F -.15(ve)-.25 G 3.865(nb).15 G 1.365(etween dif) -3.865 F 1.365(ferent runs of Perl for security reasons \(see `)-.25 F -.8(`A)-.74 G 1.364(lgorithmic Comple).8 F(xity)-.15 E(Attacks')128 274.8 Q 2.5('i)-.74 G 2.5(np)-2.5 G(erlsec\).)-2.5 E .933(As a side ef) 128 292.8 R .933(fect, calling)-.25 F/F3 10/Times-Italic@0 SF -.1(ke) 3.433 G(ys\(\))-.2 E F0 .933(resets the internal interator of the)3.433 F F1(HASH)3.434 E F0(or)3.434 E F1(ARRA)3.434 E(Y)-.945 E F0 .934 (\(see `)3.434 F(`each')-.74 E 3.434('\). In)-.74 F(particular)128 304.8 Q 2.5(,c)-.4 G(alling)-2.5 E F3 -.1(ke)2.5 G(ys\(\))-.2 E F0(in v)2.5 E (oid conte)-.2 E(xt resets the iterator with no other o)-.15 E -.15(ve) -.15 G(rhead.).15 E(Here is yet another w)128 322.8 Q (ay to print your en)-.1 E(vironment:)-.4 E F2(@keys = keys %ENV;)152 340.8 Q(@values = values %ENV;)152 352.8 Q(while \(@keys\) {)152 364.8 Q (print pop\(@keys\), \010=\010, pop\(@values\), "\\n";)176 376.8 Q(})152 388.8 Q F0(or ho)128 406.8 Q 2.5(wa)-.25 G(bout sorted by k)-2.5 E -.15 (ey)-.1 G(:).15 E F2(foreach $key \(sort\(keys %ENV\)\) {)152 424.8 Q (print $key, \010=\010, $ENV{$key}, "\\n";)176 436.8 Q(})152 448.8 Q F0 .604(The returned v)128 466.8 R .604(alues are copies of the original k) -.25 F -.15(ey)-.1 G 3.104(si).15 G 3.104(nt)-3.104 G .604 (he hash, so modifying them will not af)-3.104 F .603(fect the)-.25 F (original hash.)128 478.8 Q(Compare `)5 E(`v)-.74 E(alues')-.25 E('.) -.74 E 2.436 -.8(To s)128 496.8 T .836(ort a hash by v).8 F .836 (alue, you')-.25 F .836(ll need to use a)-.1 F F2(sort)3.336 E F0 3.336 (function. Here')3.336 F 3.337(sad)-.55 G .837 (escending numeric sort of a)-3.337 F(hash by its v)128 508.8 Q(alues:) -.25 E F2 (foreach $key \(sort { $hash{$b} <=> $hash{$a} } keys %hash\) {)152 526.8 Q(printf "%4d %s\\n", $hash{$key}, $key;)176 538.8 Q(})152 550.8 Q F0 1.036(Used as an lv)128 568.8 R(alue,)-.25 E F2(keys)3.536 E F0(allo) 3.536 E 1.036(ws you to increase the number of hash b)-.25 F(uck)-.2 E 1.036(ets allocated for the gi)-.1 F -.15(ve)-.25 G(n).15 E 3.554 (hash. This)128 580.8 R 1.054(can g)3.554 F 1.054 (ain you a measure of ef)-.05 F(\214cienc)-.25 E 3.554(yi)-.15 G 3.554 (fy)-3.554 G 1.054(ou kno)-3.554 F 3.554(wt)-.25 G 1.054 (he hash is going to get big.)-3.554 F 1.054(\(This is)6.054 F (similar to pre-e)128 592.8 Q(xtending an array by assigning a lar)-.15 E(ger number to $#array)-.18 E 2.5(.\) If)-.65 F(you say)2.5 E F2 (keys %hash = 200;)152 610.8 Q F0(then)128 628.8 Q F2(%hash)2.799 E F0 .299(will ha)2.799 F .599 -.15(ve a)-.2 H 2.799(tl).15 G .299 (east 200 b)-2.799 F(uck)-.2 E .299 (ets allocated for it\255\255256 of them, in f)-.1 F .299 (act, since it rounds up to)-.1 F 1.276(the ne)128 640.8 R 1.276(xt po) -.15 F 1.276(wer of tw)-.25 F 3.776(o. These)-.1 F -.2(bu)3.776 G(ck).2 E 1.277(ets will be retained e)-.1 F -.15(ve)-.25 G 3.777(ni).15 G 3.777 (fy)-3.777 G 1.277(ou do)-3.777 F F2 1.277(%hash = \(\))3.777 F F0 3.777 (,u)C(se)-3.777 E F2(undef)3.777 E(%hash)128 652.8 Q F0 .429(if you w) 2.929 F .429(ant to free the storage while)-.1 F F2(%hash)2.929 E F0 .429(is still in scope.)2.929 F -1.1(Yo)5.429 G 2.929(uc)1.1 G(an') -2.929 E 2.929(ts)-.18 G .429(hrink the number of)-2.929 F -.2(bu)128 664.8 S(ck).2 E 1.325(ets allocated for the hash using)-.1 F F2(keys) 3.825 E F0 1.325(in this w)3.825 F 1.325(ay \(b)-.1 F 1.325 (ut you needn')-.2 F 3.826(tw)-.18 G 1.326(orry about doing this by) -3.926 F(accident, as trying has no ef)128 676.8 Q(fect\).)-.25 E F2 (keys @array)2.5 E F0(in an lv)2.5 E(alue conte)-.25 E (xt is a syntax error)-.15 E(.)-.55 E .272(Starting with Perl 5.14,)128 694.8 R F2(keys)2.772 E F0 .272(can tak)2.772 F 2.772(eas)-.1 G(calar) -2.772 E F1(EXPR)2.772 E F0 2.771(,w)C .271 (hich must contain a reference to an unblessed)-2.771 F .842 (hash or array)128 706.8 R 5.843(.T)-.65 G .843(he ar)-5.843 F .843 (gument will be dereferenced automatically)-.18 F 5.843(.T)-.65 G .843 (his aspect of)-5.843 F F2(keys)3.343 E F0 .843(is considered)3.343 F (highly e)128 718.8 Q 2.5(xperimental. The)-.15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 34)162.62 F 0 Cg EP %%Page: 35 35 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (for \(keys $hashref\) { ... })152 84 Q (for \(keys $obj\255>get_arrayref\) { ... })152 96 Q F0(See also)128 114 Q F1(each)2.5 E F0(,)A F1(values)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(sort)2.5 E F0(.)A(kill)108 130.8 Q/F2 9/Times-Roman@0 SF(SIGN)2.5 E(AL)-.315 E F0 (,)A F2(LIST)2.5 E F0 .407(Sends a signal to a list of processes.)128 142.8 R .406 (Returns the number of processes successfully signaled \(which is)5.406 F(not necessarily the same as the number actually killed\).)128 154.8 Q F1($cnt = kill 1, $child1, $child2;)152 172.8 Q(kill 9, @goners;)152 184.8 Q F0(If)128 202.8 Q F2(SIGN)3.45 E(AL)-.315 E F0 .95 (is zero, no signal is sent to the process, b)3.45 F(ut)-.2 E F1(kill) 3.451 E F0 .951(checks whether it')3.451 F(s)-.55 E/F3 10/Times-Italic@0 SF(possible)3.451 E F0 .951(to send a)3.451 F .775 (signal to it \(that means, to be brief, that the process is o)128 214.8 R .774(wned by the same user)-.25 F 3.274(,o)-.4 G 3.274(rw)-3.274 G 3.274(ea)-3.274 G .774(re the super)-3.274 F(-)-.2 E 3.346(user\). This) 128 226.8 R .846(is useful to check that a child process is still ali) 3.346 F 1.147 -.15(ve \()-.25 H -2.15 -.25(ev e).15 H 3.347(ni).25 G 3.347(fo)-3.347 G .847(nly as a zombie\) and hasn')-3.347 F(t)-.18 E (changed its)128 238.8 Q F2(UID)2.5 E F0 5(.S)C (ee perlport for notes on the portability of this construct.)-5 E(Unlik) 128 256.8 Q 2.7(ei)-.1 G 2.7(nt)-2.7 G .2(he shell, if)-2.7 F F2(SIGN) 2.7 E(AL)-.315 E F0 .2(is ne)2.7 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 2.7(,i).15 G 2.699(tk)-2.7 G .199 (ills process groups instead of processes. That means you)-2.699 F (usually w)128 268.8 Q(ant to use positi)-.1 E .3 -.15(ve n)-.25 H (ot ne).15 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve s)-.25 H 2.5(ignals. Y) .15 F(ou may also use a signal name in quotes.)-1.1 E 1.073(The beha)128 286.8 R 1.073(vior of kill when a)-.2 F/F4 9/Times-Italic@0 SF(PR)3.573 E(OCESS)-.36 E F0 1.073(number is zero or ne)3.573 F -.05(ga)-.15 G(ti) .05 E 1.373 -.15(ve d)-.25 H 1.074(epends on the operating system.).15 F -.15(Fo)128 298.8 S 3.416(re).15 G .916(xample, on POSIX-conforming sys\ tems, zero will signal the current process group and \2551 will)-3.566 F (signal all processes.)128 310.8 Q(See `)128 328.8 Q(`Signals')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc for more details.)-2.5 E(last)108 345.6 Q F2(LABEL)2.5 E F0(last)108 357.6 Q(The)128 357.6 Q F1(last)2.588 E F0 .088(command is lik)2.588 F 2.588(et)-.1 G(he)-2.588 E F1(break) 2.588 E F0 .088(statement in C \(as used in loops\); it immediately e) 2.588 F .089(xits the loop)-.15 F 1.943(in question.)128 369.6 R 1.943 (If the)6.943 F F2(LABEL)4.443 E F0 1.943 (is omitted, the command refers to the innermost enclosing loop.)4.443 F (The)6.942 E F1(continue)128 381.6 Q F0(block, if an)2.5 E 1.3 -.65 (y, i)-.15 H 2.5(sn).65 G(ot e)-2.5 E -.15(xe)-.15 G(cuted:).15 E F1 (LINE: while \(\) {)152 399.6 Q(last LINE if /^$/;)176 411.6 Q 6 (#e)12 G(xit when done with header)-6 E(#...)176 423.6 Q(})152 435.6 Q (last)128 453.6 Q F0 .272(cannot be used to e)2.772 F .273 (xit a block that returns a v)-.15 F .273(alue such as)-.25 F F1 .273 (eval {})2.773 F F0(,)A F1 .273(sub {})2.773 F F0 2.773(,o)C(r)-2.773 E F1 .273(do {})2.773 F F0 2.773(,a)C(nd)-2.773 E(should not be used to e) 128 465.6 Q(xit a)-.15 E F3(gr)2.5 E(ep\(\))-.37 E F0(or)2.5 E F3 (map\(\))2.5 E F0(operation.)2.5 E .773 (Note that a block by itself is semantically identical to a loop that e) 128 483.6 R -.15(xe)-.15 G .773(cutes once.).15 F(Thus)5.772 E F1(last) 3.272 E F0 .772(can be)3.272 F(used to ef)128 495.6 Q(fect an early e) -.25 E(xit out of such a block.)-.15 E(See also `)128 513.6 Q (`continue')-.74 E 2.5('f)-.74 G(or an illustration of ho)-2.5 E(w)-.25 E F1(last)2.5 E F0(,)A F1(next)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(redo)2.5 E F0 -.1(wo)2.5 G(rk.).1 E(lc)108 530.4 Q F2(EXPR)2.5 E F0(lc)108 542.4 Q .922(Returns a lo)128 542.4 R .922(wercased v)-.25 F .922(ersion of)-.15 F F2(EXPR)3.422 E F0 5.922(.T)C .922 (his is the internal function implementing the)-5.922 F F1(\\L)3.423 E F0 .923(escape in)3.423 F(double-quoted strings.)128 554.4 Q(If)128 572.4 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A (What gets returned depends on se)128 590.4 Q -.15(ve)-.25 G(ral f).15 E (actors:)-.1 E(If)128 607.2 Q F1(use bytes)2.5 E F0(is in ef)2.5 E (fect:)-.25 E(On)148 619.2 Q F2(EBCDIC)2.5 E F0(platforms)2.5 E (The results are what the C language system call)168 631.2 Q F1 (tolower\(\))2.5 E F0(returns.)2.5 E(On)148 648 Q F2(ASCII)2.5 E F0 (platforms)2.5 E(The results follo)168 660 Q(w)-.25 E F2(ASCII)2.5 E F0 2.5(semantics. Only)2.5 F(characters)2.5 E F1(A\255Z)2.5 E F0 (change, to)2.5 E F1(a\255z)2.5 E F0(respecti)2.5 E -.15(ve)-.25 G(ly) .15 E(.)-.65 E(Otherwise, If)128 676.8 Q F2(EXPR)2.5 E F0(has the)2.5 E F2(UTF8)2.5 E F0(\215ag set)2.5 E .365 (If the current package has a subroutine named)148 688.8 R F1(ToLower) 2.865 E F0 2.865(,i)C 2.865(tw)-2.865 G .364 (ill be used to change the case \(See)-2.865 F -.74(``)148 700.8 S(User) .74 E .888(-De\214ned Case Mappings \(for serious hack)-.2 F .888 (ers only\)')-.1 F 3.388('i)-.74 G 3.388(np)-3.388 G 3.388 (erlunicode.\) Otherwise)-3.388 F(Unicode)3.388 E (semantics are used for the case change.)148 712.8 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 35)162.62 F 0 Cg EP %%Page: 36 36 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(Otherwise, if)128 84 Q/F1 10/Courier@0 SF(use locale)2.5 E F0(is in ef)2.5 E(fect)-.25 E (Respects current)148 96 Q/F2 9/Times-Roman@0 SF(LC_CTYPE)2.5 E F0 2.5 (locale. See)2.5 F(perllocale.)2.5 E(Otherwise, if)128 112.8 Q F1 (use feature \010unicode_strings\010)2.5 E F0(is in ef)2.5 E(fect:)-.25 E 2.176(Unicode semantics are used for the case change.)148 124.8 R(An) 7.175 E 4.675(ys)-.15 G 2.175(ubroutine named)-4.675 F F1(ToLower)4.675 E F0 2.175(will be)4.675 F(ignored.)148 136.8 Q(Otherwise:)128 153.6 Q (On)148 165.6 Q F2(EBCDIC)2.5 E F0(platforms)2.5 E (The results are what the C language system call)168 177.6 Q F1 (tolower\(\))2.5 E F0(returns.)2.5 E(On)148 194.4 Q F2(ASCII)2.5 E F0 (platforms)2.5 E F2(ASCII)168 206.4 Q F0 .961 (semantics are used for the case change.)3.461 F .962(The lo)5.962 F .962(wercase of an)-.25 F 3.462(yc)-.15 G .962(haracter outside the) -3.462 F F2(ASCII)168 218.4 Q F0(range is the character itself.)2.5 E (lc\214rst)108 235.2 Q F2(EXPR)2.5 E F0(lc\214rst)108 247.2 Q 3.461 (Returns the v)128 259.2 R 3.461(alue of)-.25 F F2(EXPR)5.961 E F0 3.46 (with the \214rst character lo)5.961 F 5.96(wercased. This)-.25 F 3.46 (is the internal function)5.96 F(implementing the)128 271.2 Q F1(\\l)2.5 E F0(escape in double-quoted strings.)2.5 E(If)128 289.2 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A(This function beha)128 307.2 Q -.15(ve)-.2 G 2.5(st).15 G(he same w)-2.5 E(ay under v)-.1 E (arious pragmata, such as in a locale, as `)-.25 E(`lc')-.74 E 2.5('d) -.74 G(oes.)-2.5 E(length)108 324 Q F2(EXPR)2.5 E F0(length)108 336 Q .071(Returns the length in)128 348 R/F3 10/Times-Italic@0 SF -.15(ch) 2.571 G(ar).15 E(acter)-.15 E(s)-.1 E F0 .071(of the v)2.571 F .071 (alue of)-.25 F F2(EXPR)2.571 E F0 5.071(.I)C(f)-5.071 E F2(EXPR)2.571 E F0 .071(is omitted, returns the length of)2.571 F F1($_)2.572 E F0 5.072 (.I)C(f)-5.072 E F2(EXPR)128 360 Q F0(is unde\214ned, returns)2.5 E F1 (undef)2.5 E F0(.)A .054(This function cannot be used on an entire arra\ y or hash to \214nd out ho)128 378 R 2.553(wm)-.25 G(an)-2.553 E 2.553 (ye)-.15 G .053(lements these ha)-2.553 F -.15(ve)-.2 G 5.053(.F).15 G (or)-5.203 E(that, use)128 390 Q F1(scalar @array)2.5 E F0(and)2.5 E F1 (scalar keys %hash)2.5 E F0 2.5(,r)C(especti)-2.5 E -.15(ve)-.25 G(ly) .15 E(.)-.65 E(Lik)128 408 Q 3.91(ea)-.1 G 1.41 (ll Perl character operations,)-3.91 F F3(length\(\))3.911 E F0 1.411 (normally deals in logical characters, not ph)3.911 F 1.411 (ysical bytes.)-.05 F -.15(Fo)128 420 S 14.615(rh).15 G 12.615 -.25 (ow m)-14.615 H(an).25 E 14.615(yb)-.15 G 12.115 (ytes a string encoded as)-14.615 F F2(UTF\2558)14.614 E F0 -.1(wo) 14.614 G 12.114(uld tak).1 F 14.614(eu)-.1 G 12.114(p, use)-14.614 F F1 (length\(Encode::encode_utf8\(EXPR\)\))128 432 Q F0(\(you')4.343 E 1.843 (ll ha)-.1 F 2.144 -.15(ve t)-.2 H(o).15 E F1 1.844(use Encode)4.344 F F0 4.344(\214rst\). See)4.344 F(Encode)4.344 E(and perlunicode.)128 444 Q(link)108 460.8 Q F2(OLDFILE)2.5 E F0(,NEWFILE)A(Creates a ne)128 472.8 Q 2.5<778c>-.25 G(lename link)-2.5 E(ed to the old \214lename.)-.1 E (Returns true for success, f)5 E(alse otherwise.)-.1 E(listen)108 489.6 Q F2(SOCKET)2.5 E F0(,Q)A(UEUESIZE)-.1 E .517 (Does the same thing that the)128 501.6 R F3(listen)3.017 E F0 .517 (\(2\) system call does.)1.666 F .517(Returns true if it succeeded, f) 5.517 F .517(alse otherwise.)-.1 F(See the e)128 513.6 Q(xample in `) -.15 E(`Sock)-.74 E(ets: Client/Serv)-.1 E(er Communication')-.15 E 2.5 ('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E(local)108 530.4 Q F2(EXPR)2.5 E F0 -1.1(Yo)128 542.4 S 3.204(ur)1.1 G .704(eally probably w)-3.204 F .704(ant to be using)-.1 F F1(my)3.205 E F0 .705(instead, because)3.205 F F1(local)3.205 E F0(isn')3.205 E 3.205(tw)-.18 G .705 (hat most people think of as)-3.205 F -.74(``)128 554.4 S(local').74 E 2.5('. See)-.74 F -.74(``)2.5 G(Pri).74 E -.25(va)-.25 G(te V).25 E (ariables via)-1.11 E F3(my\(\))2.5 E F0 1.48 -.74('' i)D 2.5(np).74 G (erlsub for details.)-2.5 E 3.043(Al)128 572.4 S .542 (ocal modi\214es the listed v)-3.043 F .542 (ariables to be local to the enclosing block, \214le, or e)-.25 F -.25 (va)-.25 G 3.042(l. If).25 F .542(more than one)3.042 F -.25(va)128 584.4 S .507(lue is listed, the list must be placed in parentheses.).25 F .507(See `)5.507 F(`T)-.74 E .507(emporary V)-.7 F .507(alues via) -1.11 F F3(local\(\))3.007 E F0 1.987 -.74('' i)D 3.007(np).74 G(erlsub) -3.007 E(for details, including issues with tied arrays and hashes.)128 596.4 Q(The)128 614.4 Q F1 2.624(delete local EXPR)5.124 F F0 2.623 (construct can also be used to localize the deletion of array/hash)5.124 F(elements to the current block.)128 626.4 Q(See `)5 E (`Localized deletion of elements of composite types')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlsub)-2.5 E(.)-.4 E(localtime)108 643.2 Q F2(EXPR)2.5 E F0(localtime)108 655.2 Q(Con)128 667.2 Q -.15(ve)-.4 G 1.127(rts a ti\ me as returned by the time function to a 9\255element list with the tim\ e analyzed for the).15 F(local time zone.)128 679.2 Q -.8(Ty)5 G (pically used as follo).8 E(ws:)-.25 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 36)162.62 F 0 Cg EP %%Page: 37 37 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF -6 12(#0 1 2)152 84 T 30(34)18 G 30(5678)-6 G (\($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst\) =)152 96 Q (localtime\(time\);)416 108 Q F0 .071(All list elements are numeric and\ come straight out of the C `struct tm'.)128 126 R F1($sec)5.07 E F0(,)A F1($min)2.57 E F0 2.57(,a)C(nd)-2.57 E F1($hour)2.57 E F0(are)2.57 E (the seconds, minutes, and hours of the speci\214ed time.)128 138 Q F1 ($mday)128 156 Q F0 .708(is the day of the month and)3.208 F F1($mon) 3.208 E F0 .708(the month in the range)3.208 F F1(0..11)3.209 E F0 3.209 (,w)C .709(ith 0 indicating January)-3.209 F(and 11 indicating December) 128 168 Q 5(.T)-.55 G(his mak)-5 E (es it easy to get a month name from a list:)-.1 E F1 (my @abbr = qw\( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec \);)152 186 Q(print "$abbr[$mon] $mday";)152 198 Q 6(#$)152 210 S (mon=9, $mday=18 gives "Oct 18")-6 E($year)128 228 Q F0 .606 (is the number of years since 1900,)3.106 F/F2 10/Times-Bold@0 SF(not) 3.106 E F0 .606(just the last tw)3.106 F 3.106(od)-.1 G .606 (igits of the year)-3.106 F 5.606(.T)-.55 G .606(hat is,)-5.606 F F1 ($year)3.106 E F0(is)3.106 E F1(123)128 240 Q F0(in year 2023.)2.5 E (The proper w)5 E(ay to get a 4\255digit year is simply:)-.1 E F1 ($year += 1900;)152 258 Q F0 (Otherwise you create non\255Y2K\255compliant programs)128 276 Q 1.666 <8a61>1.666 G(nd you w)-1.666 E(ouldn')-.1 E 2.5(tw)-.18 G (ant to do that, w)-2.6 E(ould you?)-.1 E 1.6 -.8(To g)128 294 T (et the last tw).8 E 2.5(od)-.1 G(igits of the year \(e.g., `)-2.5 E (`01')-.74 E 2.5('i)-.74 G 2.5(n2)-2.5 G(001\) do:)-2.5 E F1 ($year = sprintf\("%02d", $year % 100\);)152 312 Q($wday)128 330 Q F0 .63(is the day of the week, with 0 indicating Sunday and 3 indicating W) 3.13 F(ednesday)-.8 E(.)-.65 E F1($yday)5.63 E F0 .63(is the)3.13 F (day of the year)128 342 Q 2.5(,i)-.4 G 2.5(nt)-2.5 G(he range)-2.5 E F1 (0..364)2.5 E F0(\(or)2.5 E F1(0..365)2.5 E F0(in leap years.\))2.5 E F1 ($isdst)128 360 Q F0 (is true if the speci\214ed time occurs during Daylight Sa)2.5 E(ving T) -.2 E(ime, f)-.35 E(alse otherwise.)-.1 E(If)128 378 Q/F3 9 /Times-Roman@0 SF(EXPR)2.5 E F0(is omitted,)2.5 E F1(localtime\(\))2.5 E F0(uses the current time \(as returned by)2.5 E/F4 10/Times-Italic@0 SF (time)2.5 E F0(\(3\)\).)1.666 E(In scalar conte)128 396 Q(xt,)-.15 E F1 (localtime\(\))2.5 E F0(returns the)2.5 E F4(ctime)2.5 E F0(\(3\) v) 1.666 E(alue:)-.25 E F1($now_string = localtime;)152 414 Q 6(#e)12 G (.g., "Thu Oct 13 04:54:34 1994")-6 E F0 .791(This scalar v)128 432 R .791(alue is)-.25 F F2(not)3.291 E F0 .791(locale-dependent b)3.291 F .791(ut is a Perl b)-.2 F .791(uiltin. F)-.2 F(or)-.15 E F3(GMT)3.291 E F0 .79(instead of local time use the)3.29 F -.74(``)128 444 S(gmtime') .74 E 3.142('b)-.74 G .642(uiltin. See also the)-3.342 F F1(Time::Local) 3.142 E F0 .643(module \(for con)3.142 F -.15(ve)-.4 G .643 (rting seconds, minutes, hours, and).15 F .358(such back to the inte)128 456 R .358(ger v)-.15 F .358(alue returned by)-.25 F F4(time\(\))2.858 E F0 .358(\), and the)B F3(POSIX)2.858 E F0(module')2.858 E(s)-.55 E F4 (strftime)2.857 E F0 .357(\(3\) and)1.666 F F4(mktime)2.857 E F0(\(3\)) 1.666 E(functions.)128 468 Q 2.588 -.8(To g)128 486 T .988(et some).8 F .988(what similar b)-.25 F .989 (ut locale-dependent date strings, set up your locale en)-.2 F .989 (vironment v)-.4 F(ariables)-.25 E (appropriately \(please see perllocale\) and try for e)128 498 Q (xample:)-.15 E F1(use POSIX qw\(strftime\);)152 516 Q ($now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;)152 528 Q 6 (#o)152 540 S 6(rf)-6 G(or GMT formatted appropriately for your locale:) -6 E($now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime;)152 552 Q F0 .688(Note that the)128 570 R F1(%a)3.188 E F0(and)3.188 E F1(%b)3.188 E F0 3.188(,t)C .688 (he short forms of the day of the week and the month of the year)-3.188 F 3.187(,m)-.4 G .687(ay not)-3.187 F (necessarily be three characters wide.)128 582 Q(See `)128 600 Q (`localtime')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlport for portability concerns.)-2.5 E .515(The T)128 618 R .515 (ime::gmtime and T)-.35 F .515(ime::localtime modules pro)-.35 F .515 (vide a con)-.15 F -.15(ve)-.4 G .516 (nient, by-name access mechanism to).15 F(the)128 630 Q F4(gmtime\(\)) 2.5 E F0(and)2.5 E F4(localtime\(\))2.5 E F0(functions, respecti)2.5 E -.15(ve)-.25 G(ly).15 E(.)-.65 E -.15(Fo)128 648 S 2.5(rac).15 G (omprehensi)-2.5 E .3 -.15(ve d)-.25 H (ate and time representation look at the DateT).15 E(ime module on)-.35 E F3(CP)2.5 E(AN)-.828 E F0(.)A(lock)108 664.8 Q F3(THING)2.5 E F0 1.079 (This function places an advisory lock on a shared v)128 676.8 R 1.078 (ariable or referenced object contained in)-.25 F/F5 9/Times-Italic@0 SF (THING)3.578 E F0(until the lock goes out of scope.)128 688.8 Q F4(loc) 128 706.8 Q(k\(\))-.2 E F0 .983(is a `)3.483 F .983(`weak k)-.74 F -.15 (ey)-.1 G -.1(wo).15 G(rd').1 E 3.483(':t)-.74 G .983 (his means that if you')-3.483 F 1.283 -.15(ve d)-.5 H .984 (e\214ned a function by this name \(before an).15 F(y)-.15 E .537 (calls to it\), that function will be called instead.)128 718.8 R .537 (If you are not under)5.537 F F1 .536(use threads::shared)3.037 F F0 (this)3.036 E(does nothing.)128 730.8 Q(See threads::shared.)5 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 37)162.62 F 0 Cg EP %%Page: 38 38 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(log)108 84 Q/F1 9 /Times-Roman@0 SF(EXPR)2.5 E F0(log)108 96 Q .374 (Returns the natural log)128 96 R .374(arithm \(base)-.05 F/F2 10 /Times-Italic@0 SF(e)2.874 E F0 2.874(\)o)C(f)-2.874 E F1(EXPR)2.874 E F0 5.374(.I)C(f)-5.374 E F1(EXPR)2.874 E F0 .374 (is omitted, returns the log of)2.874 F/F3 10/Courier@0 SF($_)2.875 E F0 5.375(.T)C 2.875(og)-6.175 G .375(et the)-2.875 F .618(log of another b\ ase, use basic algebra: The base-N log of a number is equal to the natu\ ral log of that)128 108 R(number di)128 120 Q (vided by the natural log of N.)-.25 E -.15(Fo)5 G 2.5(re).15 G(xample:) -2.65 E F3(sub log10 {)152 138 Q(my $n = shift;)176 150 Q (return log\($n\)/log\(10\);)176 162 Q(})152 174 Q F0(See also `)128 192 Q(`e)-.74 E(xp')-.15 E 2.5('f)-.74 G(or the in)-2.5 E -.15(ve)-.4 G (rse operation.).15 E(lstat)108 208.8 Q F1(EXPR)2.5 E F0(lstat)108 220.8 Q 1.806(Does the same thing as the)128 232.8 R F3(stat)4.306 E F0 1.806 (function \(including setting the special)4.306 F F3(_)4.306 E F0 1.807 (\214lehandle\) b)4.307 F 1.807(ut stats a)-.2 F .576 (symbolic link instead of the \214le the symbolic link points to.)128 244.8 R .576(If symbolic links are unimplemented on)5.576 F 3.76 (your system, a normal)128 256.8 R F3(stat)6.26 E F0 3.76(is done.)6.26 F -.15(Fo)8.76 G 6.26(rm).15 G 3.76 (uch more detailed information, please see the)-6.26 F (documentation for)128 268.8 Q F3(stat)2.5 E F0(.)A(If)128 286.8 Q F1 (EXPR)2.5 E F0(is omitted, stats)2.5 E F3($_)2.5 E F0(.)A(m//)108 303.6 Q(The match operator)128 303.6 Q 5(.S)-.55 G(ee `)-5 E(`Re)-.74 E(ge) -.15 E(xp Quote-Lik)-.15 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E(map)108 320.4 Q F1 .25(BLOCK LIST)2.5 F F0 (map)108 332.4 Q F1(EXPR)2.5 E F0(,LIST)A(Ev)128 344.4 Q 1.6 (aluates the)-.25 F F1(BLOCK)4.1 E F0(or)4.1 E F1(EXPR)4.1 E F0 1.6 (for each element of)4.1 F F1(LIST)4.1 E F0 1.6(\(locally setting)4.1 F F3($_)4.1 E F0 1.599(to each element\) and)4.099 F 1.036 (returns the list v)128 356.4 R 1.037 (alue composed of the results of each such e)-.25 F -.25(va)-.25 G 3.537 (luation. In).25 F 1.037(scalar conte)3.537 F 1.037(xt, returns the)-.15 F .473(total number of elements so generated.)128 368.4 R(Ev)5.473 E (aluates)-.25 E F1(BLOCK)2.973 E F0(or)2.973 E F1(EXPR)2.973 E F0 .473 (in list conte)2.973 F .472(xt, so each element of)-.15 F F1(LIST)128 380.4 Q F0(may produce zero, one, or more elements in the returned v)2.5 E(alue.)-.25 E F3(@chars = map\(chr, @numbers\);)152 398.4 Q F0 (translates a list of numbers to the corresponding characters.)128 416.4 Q F3(my @squares = map { $_ * $_ } @numbers;)152 434.4 Q F0 (translates a list of numbers to their squared v)128 452.4 Q(alues.)-.25 E F3(my @squares = map { $_ > 5 ? \($_ * $_\) : \(\) } @numbers;)152 470.4 Q F0(sho)128 488.4 Q 1.338 (ws that number of returned elements can dif)-.25 F 1.339 (fer from the number of input elements. T)-.25 F 3.839(oo)-.8 G 1.339 (mit an)-3.839 F(element, return an empty list \(\).)128 500.4 Q (This could also be achie)5 E -.15(ve)-.25 G 2.5(db).15 G 2.5(yw)-2.5 G (riting)-2.5 E F3 (my @squares = map { $_ * $_ } grep { $_ > 5 } @numbers;)152 518.4 Q F0 (which mak)128 536.4 Q(es the intention more clear)-.1 E(.)-.55 E .785 (Map al)128 554.4 R -.1(wa)-.1 G .784(ys returns a list, which can be a\ ssigned to a hash such that the elements become k).1 F -.15(ey)-.1 G(/v) .15 E(alue)-.25 E(pairs. See perldata for more details.)128 566.4 Q F3 (%hash = map { get_a_key_for\($_\) => $_ } @array;)152 584.4 Q F0 (is just a funn)128 602.4 Q 2.5(yw)-.15 G(ay to write)-2.6 E F3 (%hash = \(\);)152 620.4 Q(foreach \(@array\) {)152 632.4 Q ($hash{get_a_key_for\($_\)} = $_;)176 644.4 Q(})152 656.4 Q F0 .475 (Note that)128 674.4 R F3($_)2.975 E F0 .475(is an alias to the list v) 2.975 F .475(alue, so it can be used to modify the elements of the)-.25 F F1(LIST)2.975 E F0 5.476(.W)C(hile)-5.476 E 1.617(this is useful and \ supported, it can cause bizarre results if the elements of)128 686.4 R F1(LIST)4.117 E F0 1.617(are not v)4.117 F(ariables.)-.25 E .515 (Using a re)128 698.4 R(gular)-.15 E F3(foreach)3.015 E F0 .515 (loop for this purpose w)3.015 F .515(ould be clearer in most cases.)-.1 F .516(See also `)5.516 F(`grep')-.74 E 3.016('f)-.74 G(or)-3.016 E (an array composed of those items of the original list for which the)128 710.4 Q F1(BLOCK)2.5 E F0(or)2.5 E F1(EXPR)2.5 E F0 -.25(eva)2.5 G (luates to true.).25 E(If)128 728.4 Q F3($_)2.882 E F0 .382(is le)2.882 F .382(xical in the scope where the)-.15 F F3(map)2.882 E F0 .381 (appears \(because it has been declared with)2.882 F F3 .381(my $_)2.881 F F0 .381(\), then,)B(perl v5.14.2)72 768 Q 198.17(2011-10-01 38)162.62 F 0 Cg EP %%Page: 39 39 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .138 (in addition to being locally aliased to the list elements,)128 84 R/F1 10/Courier@0 SF($_)2.638 E F0 -.1(ke)2.638 G .138(eps being le).1 F .139 (xical inside the block; that is,)-.15 F(it can')128 96 Q 2.5(tb)-.18 G 2.5(es)-2.5 G(een from the outside, a)-2.5 E -.2(vo)-.2 G(iding an).2 E 2.5(yp)-.15 G(otential side-ef)-2.5 E(fects.)-.25 E F1({)128 114 Q F0 .018(starts both hash references and blocks, so)2.518 F F1 .018 (map { ...)2.518 F F0 .018(could be either the start of map)2.518 F/F2 9 /Times-Roman@0 SF .267(BLOCK LIST)2.517 F F0 .466(or map)128 126 R F2 (EXPR)2.966 E F0(,)A F2(LIST)2.966 E F0 2.967(.B)C .467 (ecause Perl doesn')-2.967 F 2.967(tl)-.18 G .467 (ook ahead for the closing)-2.967 F F1(})2.967 E F0 .467(it has to tak) 2.967 F 2.967(eag)-.1 G .467(uess at which)-2.967 F(it')128 138 Q 2.727 (sd)-.55 G .227(ealing with based on what it \214nds just after the) -2.727 F F1({)2.727 E F0 2.727(.U)C .227(sually it gets it right, b) -2.727 F .226(ut if it doesn')-.2 F 2.726(ti)-.18 G 2.726(tw)-2.726 G (on')-2.826 E(t)-.18 E .752 (realize something is wrong until it gets to the)128 150 R F1(})3.252 E F0 .752(and encounters the missing \(or une)3.252 F .752 (xpected\) comma.)-.15 F .488 (The syntax error will be reported close to the)128 162 R F1(})2.987 E F0 2.987(,b)C .487(ut you')-3.187 F .487 (ll need to change something near the)-.1 F F1({)2.987 E F0(such)2.987 E (as using a unary)128 174 Q F1(+)2.5 E F0(to gi)2.5 E .3 -.15(ve P)-.25 H(erl some help:).15 E F1(%hash = map {)152 192 Q("\\L$_" => 1)12 E 6 (}@)12 G 6(array #)-6 F(perl guesses EXPR.)6 E(wrong)12 E (%hash = map { +"\\L$_" => 1)152 204 Q 6(}@)12 G 6(array #)-6 F (perl guesses BLOCK. right)6 E(%hash = map { \("\\L$_" => 1\) } @array) 152 216 Q 6(#t)12 G(his also works)-6 E(%hash = map {)152 228 Q (lc\($_\) => 1)12 E 6(}@)12 G 6(array #)-6 F(as does this.)6 E (%hash = map +\( lc\($_\) => 1 \), @array)152 240 Q 6(#t)12 G (his is EXPR and works!)-6 E(%hash = map)152 264 Q 6(\(l)12 G (c\($_\), 1 \),)-6 E 6(@array #)18 F(evaluates to \(1, @array\))6 E F0 (or to force an anon hash constructor use)128 282 Q F1(+{)2.5 E F0(:)A F1 (@hashes = map +{ lc\($_\) => 1 }, @array # EXPR, so needs comma at end) 146 300 Q F0(to get a list of anon)128 318 Q (ymous hashes each with only one entry apiece.)-.15 E(mkdir)108 334.8 Q F2(FILEN)2.5 E(AME)-.315 E F0(,MASK)A(mkdir)108 346.8 Q F2(FILEN)2.5 E (AME)-.315 E F0(mkdir)108 358.8 Q 1.048 (Creates the directory speci\214ed by)128 370.8 R F2(FILEN)3.548 E(AME) -.315 E F0 3.548(,w)C 1.048(ith permissions speci\214ed by)-3.548 F F2 (MASK)3.549 E F0 1.049(\(as modi\214ed by)3.549 F F1(umask)128 382.8 Q F0 2.572(\). If)B .072 (it succeeds it returns true; otherwise it returns f)2.572 F .072 (alse and sets)-.1 F F1($!)2.571 E F0(\(errno\).)2.571 E F2(MASK)5.071 E F0(def)2.571 E .071(aults to)-.1 F(0777 if omitted, and)128 394.8 Q F2 (FILEN)2.5 E(AME)-.315 E F0(def)2.5 E(aults to)-.1 E F1($_)2.5 E F0 (if omitted.)2.5 E .652 (In general, it is better to create directories with a permissi)128 412.8 R -.15(ve)-.25 G F2(MASK)3.302 E F0 .652 (and let the user modify that with)3.152 F(their)128 424.8 Q F1(umask) 3.15 E F0 .65(than it is to supply a restricti)3.15 F -.15(ve)-.25 G F2 (MASK)3.299 E F0 .649(and gi)3.149 F .949 -.15(ve t)-.25 H .649 (he user no w).15 F .649(ay to be more permissi)-.1 F -.15(ve)-.25 G(.) .15 E 2.224(The e)128 436.8 R 2.224 (xceptions to this rule are when the \214le or directory should be k) -.15 F 2.224(ept pri)-.1 F -.25(va)-.25 G 2.225(te \(mail \214les, for) .25 F 2.5(instance\). The)128 448.8 R/F3 10/Times-Italic@0 SF(perlfunc) 2.5 E F0(\(1\) entry on)1.666 E F1(umask)2.5 E F0 (discusses the choice of)2.5 E F2(MASK)2.5 E F0(in more detail.)2.5 E 2.056(Note that according to the)128 466.8 R F2(POSIX)4.556 E F0 2.056 (1003.1\2551996 the)4.556 F F2(FILEN)4.556 E(AME)-.315 E F0 2.055 (may ha)4.556 F 2.355 -.15(ve a)-.2 H 2.355 -.15(ny n).15 H 2.055 (umber of trailing).15 F 4.669(slashes. Some)128 478.8 R 2.169(operatin\ g and \214lesystems do not get this right, so Perl automatically remo) 4.669 F -.15(ve)-.15 G 4.67(sa).15 G(ll)-4.67 E(trailing slashes to k) 128 490.8 Q(eep e)-.1 E -.15(ve)-.25 G(ryone happ).15 E -.65(y.)-.1 G 1.6 -.8(To r)128 508.8 T(ecursi).8 E -.15(ve)-.25 G (ly create a directory structure, look at the).15 E F1(mkpath)2.5 E F0 (function of the File::P)2.5 E(ath module.)-.15 E(msgctl)108 525.6 Q F2 (ID)2.5 E F0(,CMD,ARG)A(Calls the System V)128 537.6 Q F2(IPC)2.5 E F0 (function)2.5 E F3(msgctl)2.5 E F0 2.5(\(2\). Y)1.666 F(ou')-1.1 E (ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1 (use IPC::SysV;)152 555.6 Q F0 .739 (\214rst to get the correct constant de\214nitions.)128 573.6 R(If)5.739 E F2(CMD)3.239 E F0(is)3.239 E F1(IPC_STAT)3.239 E F0 3.239(,t)C(hen) -3.239 E F2(ARG)3.239 E F0 .738(must be a v)3.239 F .738(ariable that) -.25 F .934(will hold the returned)128 585.6 R F1(msqid_ds)3.434 E F0 3.434(structure. Returns)3.434 F(lik)3.434 E(e)-.1 E F1(ioctl)3.434 E F0 3.434(:t)C .934(he unde\214ned v)-3.434 F .935(alue for error)-.25 F(,) -.4 E F1("0)3.435 E .751(but true")128 597.6 R F0 .751 (for zero, or the actual return v)3.251 F .75(alue otherwise.)-.25 F .75 (See also `)5.75 F(`SysV)-.74 E F2(IPC)3.25 E F0 2.23 -.74('' i)D 3.25 (np).74 G .75(erlipc and the)-3.25 F(documentation for)128 609.6 Q F1 (IPC::SysV)2.5 E F0(and)2.5 E F1(IPC::Semaphore)2.5 E F0(.)A(msgget)108 626.4 Q F2(KEY)2.5 E F0(,FLA)A(GS)-.4 E .671(Calls the System V)128 638.4 R F2(IPC)3.171 E F0(function)3.171 E F3(msg)3.171 E -.1(ge)-.1 G (t).1 E F0 3.171(\(2\). Returns)1.666 F .671(the message queue id, or) 3.171 F F1(undef)3.172 E F0 .672(on error)3.172 F 5.672(.S)-.55 G(ee) -5.672 E(also `)128 650.4 Q(`SysV)-.74 E F2(IPC)2.5 E F0 1.48 -.74('' i) D 2.5(np).74 G(erlipc and the documentation for)-2.5 E F1(IPC::SysV)2.5 E F0(and)2.5 E F1(IPC::Msg)2.5 E F0(.)A(msgrcv)108 667.2 Q F2(ID)2.5 E F0(,V)A(AR,SIZE,TYPE,FLA)-1.35 E(GS)-.4 E 1.062(Calls the System V)128 679.2 R F2(IPC)3.562 E F0 1.062(function msgrcv to recei)3.562 F 1.362 -.15(ve a m)-.25 H 1.062(essage from message queue).15 F F2(ID)3.562 E F0 1.061(into v)3.562 F(ariable)-.25 E F2 -1.215(VA)128 691.2 S(R)1.215 E F0 .4(with a maximum message size of)2.899 F F2(SIZE)2.9 E F0 5.4(.N)C .4(ote that when a message is recei)-5.4 F -.15(ve)-.25 G .4 (d, the message type).15 F .76(as a nati)128 703.2 R 1.06 -.15(ve l)-.25 H .76(ong inte).15 F .759(ger will be the \214rst thing in)-.15 F F2 -1.215(VA)3.259 G(R)1.215 E F0 3.259(,f)C(ollo)-3.259 E .759 (wed by the actual message.)-.25 F .759(This packing)5.759 F .903 (may be opened with)128 715.2 R F1 .903(unpack\("l! a*"\))3.403 F F0 5.903(.T)C .904(aints the v)-6.703 F 3.404(ariable. Returns)-.25 F .904 (true if successful, f)3.404 F .904(alse on)-.1 F(error)128 727.2 Q 11.526(.S)-.55 G 6.526(ee also `)-11.526 F(`SysV)-.74 E F2(IPC)9.026 E F0 8.006 -.74('' i)D 9.026(np).74 G 6.525 (erlipc and the documentation for)-9.026 F F1(IPC::SysV)9.025 E F0(and) 9.025 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 39)162.62 F 0 Cg EP %%Page: 40 40 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (IPC::SysV::Msg)128 84 Q F0(.)A(msgsnd)108 100.8 Q/F2 9/Times-Roman@0 SF (ID)2.5 E F0(,MSG,FLA)A(GS)-.4 E 1.099(Calls the System V)128 112.8 R F2 (IPC)3.599 E F0 1.099(function msgsnd to send the message)3.599 F F2 (MSG)3.599 E F0 1.099(to the message queue)3.599 F F2(ID)3.6 E F0(.)A F2 (MSG)6.1 E F0 .128(must be)128 124.8 R .128(gin with the nati)-.15 F .428 -.15(ve l)-.25 H .128(ong inte).15 F .128 (ger message type, be follo)-.15 F .127 (wed by the length of the actual message,)-.25 F 1.259 (and then \214nally the message itself.)128 136.8 R 1.259 (This kind of packing can be achie)6.259 F -.15(ve)-.25 G 3.76(dw).15 G (ith)-3.76 E F1 1.26(pack\("l! a*",)3.76 F 1.597($type, $message\))128 148.8 R F0 6.597(.R)C 1.597(eturns true if successful, f)-6.597 F 1.597 (alse on error)-.1 F 6.597(.S)-.55 G 1.597(ee also the)-6.597 F F1 (IPC::SysV)4.097 E F0(and)4.096 E F1(IPC::SysV::Msg)128 160.8 Q F0 (documentation.)2.5 E(my)108 177.6 Q F2(EXPR)2.5 E F0(my)108 189.6 Q F2 .25(TYPE EXPR)2.5 F F0(my)108 201.6 Q F2(EXPR)2.5 E F0(:)2.5 E F2 -.999 (AT)2.5 G(TRS).999 E F0(my)108 213.6 Q F2 .25(TYPE EXPR)2.5 F F0(:)2.5 E F2 -.999(AT)2.5 G(TRS).999 E F0(A)128 225.6 Q F1(my)2.766 E F0 .266 (declares the listed v)2.766 F .267(ariables to be local \(le)-.25 F .267(xically\) to the enclosing block, \214le, or)-.15 F F1(eval)2.767 E F0 5.267(.I)C 2.767(fm)-5.267 G(ore)-2.767 E(than one v)128 237.6 Q (alue is listed, the list must be placed in parentheses.)-.25 E .572 (The e)128 255.6 R .572(xact semantics and interf)-.15 F .572(ace of)-.1 F F2(TYPE)3.072 E F0(and)3.072 E F2 -.999(AT)3.072 G(TRS).999 E F0 .572 (are still e)3.072 F -.2(vo)-.25 G(lving.).2 E F2(TYPE)5.571 E F0 .571 (is currently bound to)3.071 F 2.312(the use of the)128 267.6 R F1 (fields)4.812 E F0 2.312(pragma, and attrib)4.812 F 2.312 (utes are handled using the)-.2 F F1(attributes)4.812 E F0 2.313 (pragma, or)4.813 F .774(starting from Perl 5.8.0 also via the)128 279.6 R F1(Attribute::Handlers)3.273 E F0 3.273(module. See)3.273 F -.74(``) 3.273 G(Pri).74 E -.25(va)-.25 G .773(te V).25 F .773(ariables via)-1.11 F/F3 10/Times-Italic@0 SF(my\(\))128 291.6 Q F0 1.48 -.74('' i)D 2.5(np) .74 G(erlsub for details, and \214elds, attrib)-2.5 E(utes, and Attrib) -.2 E(ute::Handlers.)-.2 E(ne)108 308.4 Q(xt)-.15 E F2(LABEL)2.5 E F0 (ne)108 320.4 Q(xt)-.15 E(The)128 332.4 Q F1(next)2.5 E F0 (command is lik)2.5 E 2.5(et)-.1 G(he)-2.5 E F1(continue)2.5 E F0 (statement in C; it starts the ne)2.5 E(xt iteration of the loop:)-.15 E F1(LINE: while \(\) {)152 350.4 Q(next LINE if /^#/;)176 362.4 Q 6(#d)12 G(iscard comments)-6 E(#...)176 374.4 Q(})152 386.4 Q F0 1.285 (Note that if there were a)128 404.4 R F1(continue)3.785 E F0 1.285 (block on the abo)3.785 F -.15(ve)-.15 G 3.785(,i).15 G 3.785(tw)-3.785 G 1.286(ould get e)-3.885 F -.15(xe)-.15 G 1.286(cuted e).15 F -.15(ve) -.25 G 3.786(no).15 G 3.786(nd)-3.786 G(iscarded)-3.786 E 2.5(lines. If) 128 416.4 R F2(LABEL)2.5 E F0 (is omitted, the command refers to the innermost enclosing loop.)2.5 E F1(next)128 434.4 Q F0 .662(cannot be used to e)3.162 F .662 (xit a block which returns a v)-.15 F .661(alue such as)-.25 F F1 .661 (eval {})3.161 F F0(,)A F1 .661(sub {})3.161 F F0 3.161(,o)C(r)-3.161 E F1 .661(do {})3.161 F F0(,)A(and should not be used to e)128 446.4 Q (xit a)-.15 E F3(gr)2.5 E(ep\(\))-.37 E F0(or)2.5 E F3(map\(\))2.5 E F0 (operation.)2.5 E .379 (Note that a block by itself is semantically identical to a loop that e) 128 464.4 R -.15(xe)-.15 G .379(cutes once.).15 F(Thus)5.379 E F1(next) 2.879 E F0 .379(will e)2.879 F(xit)-.15 E(such a block early)128 476.4 Q (.)-.65 E(See also `)128 494.4 Q(`continue')-.74 E 2.5('f)-.74 G (or an illustration of ho)-2.5 E(w)-.25 E F1(last)2.5 E F0(,)A F1(next) 2.5 E F0 2.5(,a)C(nd)-2.5 E F1(redo)2.5 E F0 -.1(wo)2.5 G(rk.).1 E(no) 108 511.2 Q F2 .25(MODULE VERSION LIST)2.5 F F0(no)108 523.2 Q F2 .25 (MODULE VERSION)2.5 F F0(no)108 535.2 Q F2 .25(MODULE LIST)2.5 F F0(no) 108 547.2 Q F2(MODULE)2.5 E F0(no)108 559.2 Q F2(VERSION)2.5 E F0 (See the)128 571.2 Q F1(use)2.5 E F0(function, of which)2.5 E F1(no)2.5 E F0(is the opposite.)2.5 E(oct)108 588 Q F2(EXPR)2.5 E F0(oct)108 600 Q (Interprets)128 600 Q F2(EXPR)3.154 E F0 .654 (as an octal string and returns the corresponding v)3.154 F 3.154 (alue. \(If)-.25 F F2(EXPR)3.154 E F0 .653(happens to start of)3.154 F (f)-.25 E(with)128 612 Q F1(0x)3.396 E F0 3.396(,i)C .896 (nterprets it as a he)-3.396 F 3.397(xs)-.15 G 3.397(tring. If)-3.397 F F2(EXPR)3.397 E F0 .897(starts of)3.397 F 3.397(fw)-.25 G(ith)-3.397 E F1(0b)3.397 E F0 3.397(,i)C 3.397(ti)-3.397 G 3.397(si)-3.397 G .897 (nterpreted as a binary string.)-3.397 F 1.105 (Leading whitespace is ignored in all three cases.\))128 624 R 1.105 (The follo)6.105 F 1.105(wing will handle decimal, binary)-.25 F 3.605 (,o)-.65 G(ctal,)-3.605 E(and he)128 636 Q 2.5(xi)-.15 G 2.5(ns)-2.5 G (tandard Perl notation:)-2.5 E F1($val = oct\($val\) if $val =~ /^0/;) 152 654 Q F0(If)128 672 Q F2(EXPR)4.345 E F0 1.846(is omitted, uses) 4.345 F F1($_)4.346 E F0 9.346(.T)C 4.346(og)-10.146 G 4.346(ot)-4.346 G 1.846(he other w)-4.346 F 1.846(ay \(produce a number in octal\), use) -.1 F F3(sprintf\(\))4.346 E F0(or)4.346 E F3(printf\(\))128 684 Q F0(:) A F1($dec_perms = \(stat\("filename"\)\)[2] & 07777;)152 702 Q ($oct_perm_str = sprintf "%o", $perms;)152 714 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 40)162.62 F 0 Cg EP %%Page: 41 41 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(The)128 84 Q/F1 10 /Times-Italic@0 SF(oct\(\))3.96 E F0 1.46 (function is commonly used when a string such as)3.96 F/F2 10/Courier@0 SF(644)3.959 E F0 1.459(needs to be con)3.959 F -.15(ve)-.4 G 1.459 (rted into a \214le).15 F 2.913(mode, for e)128 96 R 5.413 (xample. Although)-.15 F 2.913(Perl automatically con)5.413 F -.15(ve) -.4 G 2.914(rts strings into numbers as needed, this).15 F (automatic con)128 108 Q -.15(ve)-.4 G(rsion assumes base 10.).15 E .596 (Leading white space is ignored without w)128 126 R .596 (arning, as too are an)-.1 F 3.095(yt)-.15 G .595 (railing non-digits, such as a decimal)-3.095 F(point \()128 138 Q F2 (oct)A F0(only handles non-ne)2.5 E -.05(ga)-.15 G(ti).05 E .3 -.15 (ve i)-.25 H(nte).15 E(gers, not ne)-.15 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve i)-.25 H(nte).15 E(gers or \215oating point\).)-.15 E(open)108 154.8 Q/F3 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(,EXPR)A(open)108 166.8 Q F3(FILEHANDLE)2.5 E F0(,MODE,EXPR)A(open)108 178.8 Q F3(FILEHANDLE)2.5 E F0(,MODE,EXPR,LIST)A(open)108 190.8 Q F3(FILEHANDLE)2.5 E F0 (,MODE,REFERENCE)A(open)108 202.8 Q F3(FILEHANDLE)2.5 E F0 (Opens the \214le whose \214lename is gi)128 214.8 Q -.15(ve)-.25 G 2.5 (nb).15 G(y)-2.5 E F3(EXPR)2.5 E F0 2.5(,a)C(nd associates it with)-2.5 E F3(FILEHANDLE)2.5 E F0(.)A(Simple e)128 232.8 Q (xamples to open a \214le for reading:)-.15 E F2 (open\(my $fh, "<", "input.txt"\))152 250.8 Q (or die "cannot open < input.txt: $!";)176 262.8 Q F0(and for writing:) 128 280.8 Q F2(open\(my $fh, ">", "output.txt"\))152 298.8 Q (or die "cannot open > output.txt: $!";)176 310.8 Q F0 1.108 (\(The follo)128 328.8 R 1.108(wing is a comprehensi)-.25 F 1.408 -.15 (ve r)-.25 H 1.108(eference to).15 F F1(open\(\))3.609 E F0 3.609(:f)C 1.109(or a gentler introduction you may consider)-3.609 F (perlopentut.\))128 340.8 Q(If)128 358.8 Q F3(FILEHANDLE)5.015 E F0 2.514(is an unde\214ned scalar v)5.014 F 2.514 (ariable \(or array or hash element\), a ne)-.25 F 5.014<778c>-.25 G 2.514(lehandle is)-5.014 F(auto)128 370.8 Q(vi)-.15 E 2.676 (vi\214ed, meaning that the v)-.25 F 2.676 (ariable is assigned a reference to a ne)-.25 F 2.677 (wly allocated anon)-.25 F(ymous)-.15 E 4.727(\214lehandle. Otherwise) 128 382.8 R(if)4.727 E F3(FILEHANDLE)4.727 E F0 2.227(is an e)4.727 F 2.227(xpression, its v)-.15 F 2.226(alue is the real \214lehandle.)-.25 F 2.226(\(This is)7.226 F(considered a symbolic reference, so)128 394.8 Q F2(use strict "refs")2.5 E F0(should)2.5 E F1(not)2.5 E F0(be in ef) 2.5 E(fect.\))-.25 E(If)128 412.8 Q F3(EXPR)4.759 E F0 2.259 (is omitted, the global \(package\) scalar v)4.759 F 2.259 (ariable of the same name as the)-.25 F F3(FILEHANDLE)4.76 E F0 1.737 (contains the \214lename.)128 424.8 R 1.737(\(Note that le)6.737 F 1.737 (xical v)-.15 F -.834(ariables \212 those)-.25 F 1.736(declared with) 4.236 F F2(my)4.236 E F0(or)4.236 E F2(state)4.236 E F0 1.736 (\255\255will not)B -.1(wo)128 436.8 S(rk for this purpose; so if you') .1 E(re using)-.5 E F2(my)2.5 E F0(or)2.5 E F2(state)2.5 E F0 2.5(,s)C (pecify)-2.5 E F3(EXPR)2.5 E F0(in your call to open.\))2.5 E .336 (If three \(or more\) ar)128 454.8 R .336(guments are speci\214ed, the \ open mode \(including optional encoding\) in the second)-.18 F(ar)128 466.8 Q .834(gument are distinct from the \214lename in the third.)-.18 F(If)5.833 E F3(MODE)3.333 E F0(is)3.333 E F2(<)3.333 E F0 .833 (or nothing, the \214le is opened for)3.333 F 6.055(input. If)128 478.8 R F3(MODE)6.055 E F0(is)6.055 E F2(>)6.055 E F0 6.055(,t)C 3.555 (he \214le is opened for output, with e)-6.055 F 3.556 (xisting \214les \214rst being truncated)-.15 F(\(`)128 490.8 Q (`clobbered')-.74 E .679('\) and none)-.74 F .679(xisting \214les ne) -.15 F .679(wly created.)-.25 F(If)5.679 E F3(MODE)3.179 E F0(is)3.179 E F2(>>)3.179 E F0 3.179(,t)C .679(he \214le is opened for appending,) -3.179 F(ag)128 502.8 Q(ain being created if necessary)-.05 E(.)-.65 E -1.1(Yo)128 520.8 S 2.95(uc)1.1 G .45(an put a)-2.95 F F2(+)2.95 E F0 .451(in front of the)2.951 F F2(>)2.951 E F0(or)2.951 E F2(<)2.951 E F0 .451(to indicate that you w)2.951 F .451 (ant both read and write access to the \214le;)-.1 F(thus)128 532.8 Q F2 (+<)3.021 E F0 .521(is almost al)3.021 F -.1(wa)-.1 G .521 (ys preferred for read/write updates).1 F 1.666<8a74>1.666 G(he)-1.666 E F2(+>)3.02 E F0 .52(mode w)3.02 F .52(ould clobber the \214le \214rst.) -.1 F -1.1(Yo)128 544.8 S 4.138(uc)1.1 G 1.638 (ant usually use either read-write mode for updating te)-4.138 F 1.639 (xt\214les, since the)-.15 F 4.139(yh)-.15 G -2.25 -.2(av e)-4.139 H -.25(va)4.339 G(riable-length).25 E 3.611(records. See)128 556.8 R(the) 3.611 E/F4 10/Times-Bold@0 SF3.611 E F0 1.111 (switch in perlrun for a better approach.)3.611 F 1.11 (The \214le is created with permissions of)6.11 F F2(0666)128 568.8 Q F0 (modi\214ed by the process')2.5 E(s)-.55 E F2(umask)2.5 E F0 -.25(va)2.5 G(lue.).25 E(These v)128 586.8 Q(arious pre\214x)-.25 E (es correspond to the)-.15 E F1(fopen)2.5 E F0(\(3\) modes of)1.666 E F2 (r)2.5 E F0(,)A F2(r+)2.5 E F0(,)A F2(w)2.5 E F0(,)A F2(w+)2.5 E F0(,)A F2(a)2.5 E F0 2.5(,a)C(nd)-2.5 E F2(a+)2.5 E F0(.)A .003 (In the one\255 and tw)128 604.8 R(o-ar)-.1 E .003(gument forms of the \ call, the mode and \214lename should be concatenated \(in that)-.18 F .232(order\), preferably separated by white space.)128 616.8 R -1.1(Yo) 5.231 G 2.731(uc)1.1 G -.834(an \212 b)-2.731 F .231(ut shouldn')-.2 F 1.666(t\212o)-.18 G .231(mit the mode in these forms)-1.666 F .011 (when that mode is)128 628.8 R F2(<)2.511 E F0 5.011(.I)C 2.511(ti) -5.011 G 2.511(sa)-2.511 G -.1(lwa)-2.511 G .012(ys safe to use the tw) .1 F(o-ar)-.1 E .012(gument form of)-.18 F F2(open)2.512 E F0 .012 (if the \214lename ar)2.512 F(gument)-.18 E(is a kno)128 640.8 Q (wn literal.)-.25 E -.15(Fo)128 658.8 S 2.639(rt).15 G .139 (hree or more ar)-2.639 F .139(guments if)-.18 F F3(MODE)2.639 E F0(is) 2.639 E F2<7cad>2.639 E F0 2.639(,t)C .138 (he \214lename is interpreted as a command to which output)-2.639 F .102 (is to be piped, and if)128 670.8 R F3(MODE)2.602 E F0(is)2.602 E F2 2.602 E F0 2.602(,t)C .102 (he \214lename is interpreted as a command that pipes output to us.) -2.602 F(In)5.103 E 1.786(the tw)128 682.8 R(o-ar)-.1 E 1.786 (gument \(and one-ar)-.18 F 1.785 (gument\) form, one should replace dash \()-.18 F F2A F0 4.285(\)w)C 1.785(ith the command.)-4.285 F(See)6.785 E -.74(``)128 694.8 S(Using) .74 E F1(open\(\))3.972 E F0(for)3.972 E F3(IPC)3.972 E F0 2.952 -.74 ('' i)D 3.972(np).74 G 1.472(erlipc for more e)-3.972 F 1.472 (xamples of this.)-.15 F(\(Y)6.472 E 1.472(ou are not allo)-1.1 F 1.472 (wed to)-.25 F F2(open)3.972 E F0 1.472(to a)3.972 F 4.344 (command that pipes both in)128 706.8 R F1(and)6.843 E F0 4.343(out, b) 6.843 F 4.343(ut see IPC::Open2, IPC::Open3, and `)-.2 F(`Bidirectional) -.74 E(Communication with Another Process')128 718.8 Q 2.5('i)-.74 G 2.5 (np)-2.5 G(erlipc for alternati)-2.5 E -.15(ve)-.25 G(s.\)).15 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 41)162.62 F 0 Cg EP %%Page: 42 42 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .734 (In the form of pipe opens taking three or more ar)128 84 R .734 (guments, if)-.18 F/F1 9/Times-Roman@0 SF(LIST)3.234 E F0 .734 (is speci\214ed \(e)3.234 F .735(xtra ar)-.15 F .735(guments after)-.18 F .718(the command name\) then)128 96 R F1(LIST)3.217 E F0 .717 (becomes ar)3.217 F .717(guments to the command in)-.18 F -.2(vo)-.4 G -.1(ke).2 G 3.217(di).1 G 3.217(ft)-3.217 G .717(he platform supports) -3.217 F 3.093(it. The)128 108 R .593(meaning of)3.093 F/F2 10/Courier@0 SF(open)3.093 E F0 .593(with more than three ar)3.093 F .594 (guments for non-pipe modes is not yet de\214ned, b)-.18 F(ut)-.2 E -.15 (ex)128 120 S(perimental `).15 E(`layers')-.74 E 2.5('m)-.74 G(ay gi) -2.5 E .3 -.15(ve ex)-.25 H(tra).15 E F1(LIST)2.5 E F0(ar)2.5 E (guments meaning.)-.18 E .625(In the tw)128 138 R(o-ar)-.1 E .625 (gument \(and one-ar)-.18 F .624(gument\) form, opening)-.18 F F2<3cad> 3.124 E F0(or)3.124 E F23.124 E F0(opens)3.124 E F1(STDIN)3.124 E F0 .624(and opening)3.124 F F2<3ead>3.124 E F0(opens)3.124 E F1(STDOUT)128 150 Q F0(.)A -1.1(Yo)128 168 S 3.223(um)1.1 G .723 (ay \(and usually should\) use the three-ar)-3.223 F .724 (gument form of open to specify I/O layers \(sometimes)-.18 F .485 (referred to as `)128 180 R(`disciplines')-.74 E .485 ('\) to apply to the handle that af)-.74 F .485(fect ho)-.25 F 2.985(wt) -.25 G .484(he input and output are processed)-2.985 F (\(see open and PerlIO for more details\). F)128 192 Q(or e)-.15 E (xample:)-.15 E F2(open\(my $fh, "<:encoding\(UTF\2558\)", "filename"\)) 140 210 Q(|| die "can\010t open UTF\2558 encoded filename: $!";)152 222 Q F0 .752(opens the UTF8\255encoded \214le containing Unicode character\ s; see perluniintro. Note that if layers are)128 240 R .473 (speci\214ed in the three-ar)128 252 R .473(gument form, then def)-.18 F .473(ault layers stored in ${^OPEN} \(see perlv)-.1 F .472 (ar; usually set)-.25 F(by the)128 264 Q/F3 10/Times-Bold@0 SF(open)2.5 E F0(pragma or the switch)2.5 E F3(\255CioD)2.5 E F0 2.5(\)a)C (re ignored.)-2.5 E 1.327 (Open returns nonzero on success, the unde\214ned v)128 282 R 1.327 (alue otherwise.)-.25 F 1.327(If the)6.327 F F2(open)3.828 E F0(in)3.828 E -.2(vo)-.4 G(lv).2 E 1.328(ed a pipe, the)-.15 F(return v)128 294 Q (alue happens to be the pid of the subprocess.)-.25 E 1.679(If you')128 312 R 1.678(re running Perl on a system that distinguishes between te) -.5 F 1.678(xt \214les and binary \214les, then you)-.15 F .566 (should check out `)128 324 R(`binmode')-.74 E 3.066('f)-.74 G .566 (or tips for dealing with this.)-3.066 F .566(The k)5.566 F .866 -.15 (ey d)-.1 H .566(istinction between systems that).15 F(need)128 336 Q F2 (binmode)2.735 E F0 .235(and those that don')2.735 F 2.735(ti)-.18 G 2.735(st)-2.735 G .235(heir te)-2.735 F .235(xt \214le formats.)-.15 F .235(Systems lik)5.235 F 2.735(eU)-.1 G .235(nix, Mac)-2.735 F F1(OS) 2.735 E F0 2.735(,a)C .234(nd Plan 9,)-2.735 F .477(that end lines with\ a single character and encode that character in C as)128 348 R F2 ("\\n")2.977 E F0 .477(do not need)2.977 F F2(binmode)2.977 E F0(.)A (The rest need it.)128 360 Q .762(When opening a \214le, it')128 378 R 3.261(ss)-.55 G .761(eldom a good idea to continue if the request f) -3.261 F .761(ailed, so)-.1 F F2(open)3.261 E F0 .761(is frequently) 3.261 F .021(used with)128 390 R F2(die)2.521 E F0 5.021(.E)C -.15(ve) -5.021 G 2.521(ni).15 G(f)-2.521 E F2(die)2.521 E F0 -.1(wo)2.521 G(n') .1 E 2.521(td)-.18 G 2.521(ow)-2.521 G .021(hat you w)-2.521 F .022 (ant \(say)-.1 F 2.522(,i)-.65 G 2.522(na)-2.522 G F1(CGI)A F0 .022 (script, where you w)2.522 F .022(ant to format a)-.1 F 1.74 (suitable error message \(b)128 402 R 1.74 (ut there are modules that can help with that problem\)\) al)-.2 F -.1 (wa)-.1 G 1.74(ys check the).1 F(return v)128 414 Q (alue from opening a \214le.)-.25 E 2.07(As a special case the three-ar) 128 432 R 2.071(gument form with a read/write mode and the third ar)-.18 F 2.071(gument being)-.18 F F2(undef)128 444 Q F0(:)A F2 (open\(my $tmp, "+>", undef\) or die ...)152 462 Q F0 .123 (opens a \214lehandle to an anon)128 480 R .123(ymous temporary \214le.) -.15 F .123(Also using)5.123 F F2(+<)2.623 E F0 -.1(wo)2.623 G .123 (rks for symmetry).1 F 2.623(,b)-.65 G .123(ut you really)-2.823 F 2.14 (should consider writing something to the temporary \214le \214rst.)128 492 R -1.1(Yo)7.14 G 4.64(uw)1.1 G 2.14(ill need to)-4.64 F/F4 10 /Times-Italic@0 SF(seek\(\))4.64 E F0 2.14(to do the)4.64 F(reading.)128 504 Q .147(Since v5.8.0, Perl has b)128 522 R .147 (uilt using PerlIO by def)-.2 F 2.647(ault. Unless)-.1 F(you')2.647 E .447 -.15(ve c)-.5 H .147(hanged this \(such as b).15 F .146 (uilding Perl)-.2 F(with)128 534 Q F2(Configure \255Uuseperlio)2.5 E F0 (\), you can open \214lehandles directly to Perl scalars via:)A F2 (open\($fh, ">", \\$variable\) || ..)152 552 Q F0 1.6 -.8(To \()128 570 T(re\)open).8 E F2(STDOUT)2.5 E F0(or)2.5 E F2(STDERR)2.5 E F0 (as an in-memory \214le, close it \214rst:)2.5 E F2(close STDOUT;)152 588 Q(open\(STDOUT, ">", \\$variable\))152 600 Q (or die "Can\010t open STDOUT: $!";)176 612 Q F0(General e)128 630 Q (xamples:)-.15 E F2($ARTICLE = 100;)152 648 Q (open\(ARTICLE\) or die "Can\010t find article $ARTICLE: $!\\n";)152 660 Q(while \(
\) {...)152 672 Q (open\(LOG, ">>/usr/spool/news/twitlog"\);)152 696 Q 6(#\()12 G (log is reserved\))-6 E 6(#i)152 708 S 6(ft)-6 G (he open fails, output is discarded)-6 E F0(perl v5.14.2)72 768 Q 198.17 (2011-10-01 42)162.62 F 0 Cg EP %%Page: 43 43 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (open\(my $dbase, "+<", "dbase.mine"\))152 84 Q 6(#o)36 G (pen for update)-6 E (or die "Can\010t open \010dbase.mine\010 for update: $!";)176 96 Q (open\(my $dbase, "+Tmp$$"\))152 228 Q 6(#$)72 G 6($i)-6 G 6(so)-6 G (ur process id)-6 E(or die "Can\010t start sort: $!";)176 240 Q 6(#i)152 264 S(n\255memory files)-6 E(open\(MEMORY, ">", \\$var\))152 276 Q (or die "Can\010t open memory file: $!";)176 288 Q (print MEMORY "foo!\\n";)152 300 Q 6(#o)114 G(utput will appear in $var) -6 E 6(#p)152 324 S (rocess argument list of files along with any includes)-6 E (foreach $file \(@ARGV\) {)152 348 Q(process\($file, "fh00"\);)176 360 Q (})152 372 Q(sub process {)152 396 Q(my\($filename, $input\) = @_;)176 408 Q 18($input++; #)176 420 R(this is a string increment)6 E (unless \(open\($input, "<", $filename\)\) {)176 432 Q (print STDERR "Can\010t open $filename: $!\\n";)200 444 Q(return;)200 456 Q(})176 468 Q(local $_;)176 492 Q(while \(<$input>\) {)176 504 Q 6 (#n)24 G(ote use of indirection)-6 E(if \(/^#include "\(.*\)"/\) {)200 516 Q(process\($1, $input\);)224 528 Q(next;)224 540 Q(})200 552 Q 54 (#... #)200 564 R(whatever)6 E(})176 576 Q(})152 588 Q F0 (See perliol for detailed info on PerlIO.)128 606 Q -1.1(Yo)128 624 S 2.543(um)1.1 G .043(ay also, in the Bourne shell tradition, specify an) -2.543 F/F2 9/Times-Roman@0 SF(EXPR)2.544 E F0(be)2.544 E .044 (ginning with)-.15 F F1(>&)2.544 E F0 2.544(,i)C 2.544(nw)-2.544 G .044 (hich case the rest)-2.544 F .774(of the string is interpreted as the n\ ame of a \214lehandle \(or \214le descriptor)128 636 R 3.273(,i)-.4 G 3.273(fn)-3.273 G .773(umeric\) to be duped \(as)-3.273 F F1(dup\(2\)) 128 648 Q F0 4.098(\)a)C 1.598(nd opened.)-4.098 F -1.1(Yo)6.598 G 4.098 (um)1.1 G 1.598(ay use)-4.098 F F1(&)4.098 E F0(after)4.098 E F1(>)4.098 E F0(,)A F1(>>)4.098 E F0(,)A F1(<)4.098 E F0(,)A F1(+>)4.098 E F0(,)A F1(+>>)4.098 E F0 4.099(,a)C(nd)-4.099 E F1(+<)4.099 E F0 6.599(.T)C 1.599(he mode you specify)-6.599 F .283 (should match the mode of the original \214lehandle.)128 660 R .282 (\(Duping a \214lehandle does not tak)5.283 F 2.782(ei)-.1 G .282 (nto account an)-2.782 F(y)-.15 E -.15(ex)128 672 S 2.189 (isting contents of).15 F F2(IO)4.689 E F0 -.2(bu)4.689 G -.25(ff).2 G 2.19(ers.\) If you use the three-ar).25 F 2.19 (gument form, then you can pass either a)-.18 F(number)128 684 Q 2.5(,t) -.4 G(he name of a \214lehandle, or the normal `)-2.5 E (`reference to a glob')-.74 E('.)-.74 E(Here is a script that sa)128 702 Q -.15(ve)-.2 G(s, redirects, and restores).15 E F1(STDOUT)2.5 E F0(and) 2.5 E F1(STDERR)2.5 E F0(using v)2.5 E(arious methods:)-.25 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 43)162.62 F 0 Cg EP %%Page: 44 44 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (#!/usr/bin/perl)152 84 Q(open\(my $oldout, ">&STDOUT"\))152 96 Q (or die "Can\010t dup STDOUT: $!";)30 E 24(open\(OLDERR, ">&",)152 108 R (\\*STDERR\) or die "Can\010t dup STDERR: $!";)6 E(open\(STDOUT, \010>\ \010, "foo.out"\) or die "Can\010t redirect STDOUT: $!";)152 132 Q (open\(STDERR, ">&STDOUT"\))152 144 Q(or die "Can\010t dup STDOUT: $!";) 30 E(select STDERR; $| = 1;)152 168 Q 6(#m)12 G(ake unbuffered)-6 E (select STDOUT; $| = 1;)152 180 Q 6(#m)12 G(ake unbuffered)-6 E (print STDOUT "stdout 1\\n";)152 204 Q 6(#t)12 G(his works for)-6 E (print STDERR "stderr 1\\n";)152 216 Q 6(#s)12 G(ubprocesses too)-6 E (open\(STDOUT, ">&", $oldout\) or die "Can\010t dup \\$oldout: $!";)152 240 Q(open\(STDERR, ">&OLDERR"\))152 252 Q (or die "Can\010t dup OLDERR: $!";)24 E(print STDOUT "stdout 2\\n";)152 276 Q(print STDERR "stderr 2\\n";)152 288 Q F0 1.67(If you specify)128 306 R F1(\010<&=X\010)4.17 E F0 4.17(,w)C(here)-4.17 E F1(X)4.17 E F0 1.67 (is a \214le descriptor number or a \214lehandle, then Perl will do an) 4.17 F(equi)128 318 Q -.25(va)-.25 G .38(lent of C').25 F(s)-.55 E F1 (fdopen)2.88 E F0 .38(of that \214le descriptor \(and not call)2.88 F F1 (dup\(2\))2.88 E F0 .38(\); this is more parsimonious of)B (\214le descriptors.)128 330 Q -.15(Fo)5 G 2.5(re).15 G(xample:)-2.65 E F1 6(#o)152 348 S(pen for input, reusing the fileno of $fd)-6 E (open\(FILEHANDLE, "<&=$fd"\))152 360 Q F0(or)128 378 Q F1 (open\(FILEHANDLE, "<&=", $fd\))152 396 Q F0(or)128 414 Q F1 6(#o)152 432 S(pen for append, using the fileno of OLDFH)-6 E (open\(FH, ">>&=", OLDFH\))152 444 Q F0(or)128 462 Q F1 (open\(FH, ">>&=OLDFH"\))152 480 Q F0 2.034(Being parsimonious on \214l\ ehandles is also useful \(besides being parsimonious\) for e)128 498 R 2.034(xample when)-.15 F 1.832 (something is dependent on \214le descriptors, lik)128 510 R 4.333(ef) -.1 G 1.833(or e)-4.333 F 1.833(xample locking using)-.15 F/F2 10 /Times-Italic@0 SF(\215oc)4.333 E(k\(\))-.2 E F0 6.833(.I)C 4.333(fy) -6.833 G 1.833(ou do just)-4.333 F F1 1.679(open\(A, ">>&B"\))128 522 R F0 4.179(,t)C 1.679(he \214lehandle A will not ha)-4.179 F 1.979 -.15 (ve t)-.2 H 1.678(he same \214le descriptor as B, and therefore).15 F .362(\215ock\(A\) will not \215ock\(B\) nor vice v)128 534 R 2.862 (ersa. But)-.15 F(with)2.862 E F1 .362(open\(A, ">>&=B"\))2.862 F F0 2.862(,t)C .363(he \214lehandles will share)-2.862 F (the same underlying system \214le descriptor)128 546 Q(.)-.55 E .388(N\ ote that under Perls older than 5.8.0, Perl uses the standard C library\ ')128 564 R(s')-.55 E F2(fdopen\(\))2.888 E F0 .388(to implement the) 2.888 F F1(=)2.888 E F0(functionality)128 576 Q 6.776(.O)-.65 G 4.276 (nm)-6.776 G(an)-4.276 E 4.276(yU)-.15 G 1.776(nix systems,)-4.276 F F2 (fdopen\(\))4.276 E F0 -.1(fa)4.276 G 1.776 (ils when \214le descriptors e).1 F 1.777(xceed a certain v)-.15 F (alue,)-.25 E(typically 255.)128 588 Q -.15(Fo)5 G 2.5(rP).15 G (erls 5.8.0 and later)-2.5 E 2.5(,P)-.4 G (erlIO is \(most often\) the def)-2.5 E(ault.)-.1 E -1.1(Yo)128 606 S 4.416(uc)1.1 G 1.916(an see whether your Perl w)-4.416 F 1.915(as b)-.1 F 1.915(uilt with PerlIO by running)-.2 F F1 1.915(perl \255V)4.415 F F0 1.915(and looking for the)4.415 F F1(useperlio=)128 618 Q F0 2.5 (line. If)2.5 F F1(useperlio)2.5 E F0(is)2.5 E F1(define)2.5 E F0 2.5 (,y)C(ou ha)-2.5 E .3 -.15(ve P)-.2 H(erlIO; otherwise you don').15 E (t.)-.18 E .293(If you open a pipe on the command)128 636 R F12.793 E F0 .294(\(that is, specify either)2.793 F F1<7cad>2.794 E F0(or)2.794 E F12.794 E F0 .294(with the one\255 or tw)2.794 F(o-ar)-.1 E (gument)-.18 E .373(forms of)128 648 R F1(open)2.873 E F0 .373 (\), an implicit)B F1(fork)2.873 E F0 .373(is done, so)2.873 F F1(open) 2.873 E F0 .373(returns twice: in the parent process it returns the) 2.873 F .735(pid of the child process, and in the child process it retu\ rns \(a de\214ned\))128 660 R F1(0)3.236 E F0 5.736(.U)C(se)-5.736 E F1 (defined\($pid\))3.236 E F0(or)3.236 E F1(//)128 672 Q F0 (to determine whether the open w)2.5 E(as successful.)-.1 E -.15(Fo)128 690 S 2.5(re).15 G(xample, use either)-2.65 E F1 ($child_pid = open\(FROM_KID, "|\255"\))152 708 Q (// die "can\010t fork: $!";)18 E F0(or)128 726 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 44)162.62 F 0 Cg EP %%Page: 45 45 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($child_pid)138 84 Q F0 2.5(=o)2.5 G(pen\()-2.5 E/F2 9/Times-Roman@0 SF -.162(TO)C(_KID).162 E F0 7.5(,`)C(`|\255')-8.24 E 8.952('\) //)-.74 F (die `)2.5 E(`can')-.74 E 2.5(tf)-.18 G(ork: $!')-2.5 E(';)-.74 E(follo) 128 102 Q(wed by)-.25 E F1(if \($child_pid\) {)152 120 Q 6(#a)176 132 S 6(mt)-6 G(he parent:)-6 E 6(#e)176 144 S (ither write TO_KID or else read FROM_KID)-6 E(...)176 156 Q (wait $child_pid;)176 168 Q 6(}e)152 180 S(lse {)-6 E 6(#a)176 192 S 6 (mt)-6 G(he child; use STDIN/STDOUT normally)-6 E(...)176 204 Q(exit;) 176 216 Q(})152 228 Q F0 2.729(The \214lehandle beha)128 246 R -.15(ve) -.2 G 5.229(sn).15 G 2.729(ormally for the parent, b)-5.229 F 2.728 (ut I/O to that \214lehandle is piped from/to the)-.2 F F2(STDOUT/STDIN) 128 258 Q F0 .681(of the child process.)3.181 F .681 (In the child process, the \214lehandle isn')5.681 F 3.181(to)-.18 G -.834(pened \212 I/O)-3.181 F(happens)3.182 E .376(from/to the ne)128 270 R(w)-.25 E F2(STDOUT/STDIN)2.876 E F0 5.376(.T)C .376 (ypically this is used lik)-6.176 F 2.875(et)-.1 G .375 (he normal piped open when you w)-2.875 F .375(ant to)-.1 F -.15(exe)128 282 S .08(rcise more control o).15 F -.15(ve)-.15 G 2.58(rj).15 G .08 (ust ho)-2.58 F 2.58(wt)-.25 G .08(he pipe command gets e)-2.58 F -.15 (xe)-.15 G .08(cuted, such as when running setuid and).15 F(you don')128 294 Q 2.5(tw)-.18 G(ant to ha)-2.6 E .3 -.15(ve t)-.2 H 2.5(os).15 G (can shell commands for metacharacters.)-2.5 E(The follo)128 312 Q (wing blocks are more or less equi)-.25 E -.25(va)-.25 G(lent:).25 E F1 (open\(FOO, "|tr \010[a\255z]\010 \010[A\255Z]\010"\);)152 330 Q (open\(FOO, "|\255", "tr \010[a\255z]\010 \010[A\255Z]\010"\);)152 342 Q (open\(FOO, "|\255"\) || exec \010tr\010, \010[a\255z]\010, \010[A\255Z\ ]\010;)152 354 Q (open\(FOO, "|\255", "tr", \010[a\255z]\010, \010[A\255Z]\010\);)152 366 Q(open\(FOO, "cat \255n \010$file\010|"\);)152 390 Q (open\(FOO, "\255|", "cat \255n \010$file\010"\);)152 402 Q (open\(FOO, "\255|"\) || exec "cat", "\255n", $file;)152 414 Q (open\(FOO, "\255|", "cat", "\255n", $file\);)152 426 Q F0 .739 (The last tw)128 444 R 3.239(oe)-.1 G .739(xamples in each block sho) -3.389 F 3.239(wt)-.25 G .738(he pipe as `)-3.239 F .738(`list form') -.74 F .738(', which is not yet supported on all)-.74 F 3.145 (platforms. A)128 456 R .645 (good rule of thumb is that if your platform has a real)3.145 F F1 (fork\(\))3.145 E F0 .646(\(in other w)3.146 F .646(ords, if your)-.1 F .617(platform is Unix, including Linux and MacOS X\), you can use the l\ ist form.)128 468 R -1.1(Yo)5.617 G 3.117(uw)1.1 G .617(ould w)-3.217 F .617(ant to use)-.1 F .979 (the list form of the pipe so you can pass literal ar)128 480 R .979 (guments to the command without risk of the shell)-.18 F 1.682 (interpreting an)128 492 R 4.182(ys)-.15 G 1.682 (hell metacharacters in them.)-4.182 F(Ho)6.682 E(we)-.25 E -.15(ve)-.25 G 2.481 -.4(r, t).15 H 1.681(his also bars you from opening pipes to).4 F(commands that intentionally contain shell metacharacters, such as:)128 504 Q F1(open\(FOO, "|cat \255n | expand \2554 | lpr"\))152 522 Q (// die "Can\010t open pipeline to lpr: $!";)176 534 Q F0(See `)128 552 Q(`Safe Pipe Opens')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlipc for more e)-2.5 E(xamples of this.)-.15 E(Be)128 570 Q .683(gin\ ning with v5.6.0, Perl will attempt to \215ush all \214les opened for o\ utput before an)-.15 F 3.184(yo)-.15 G .684(peration that)-3.184 F .615 (may do a fork, b)128 582 R .614 (ut this may not be supported on some platforms \(see perlport\).)-.2 F 2.214 -.8(To b)5.614 H 3.114(es).8 G .614(afe, you may)-3.114 F .657 (need to set)128 594 R F1($|)3.157 E F0(\($A)3.157 E(UT)-.55 E .657 (OFLUSH in English\) or call the)-.18 F F1(autoflush\(\))3.157 E F0 .657 (method of)3.157 F F1(IO::Handle)3.158 E F0(on)3.158 E(an)128 606 Q 2.5 (yo)-.15 G(pen handles.)-2.5 E 1.179 (On systems that support a close-on-e)128 624 R -.15(xe)-.15 G 3.679 <638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.679 F 1.178(wly opened \214le)-.25 F (descriptor as determined by the v)128 636 Q(alue of)-.25 E F1($^F)2.5 E F0 5(.S)C(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E (ar)-.25 E(.)-.55 E .625(Closing an)128 654 R 3.125(yp)-.15 G .625 (iped \214lehandle causes the parent process to w)-3.125 F .626 (ait for the child to \214nish, then returns the)-.1 F(status v)128 666 Q(alue in)-.25 E F1($?)2.5 E F0(and)2.5 E F1(${^CHILD_ERROR_NATIVE})2.5 E F0(.)A 1.526(The \214lename passed to the one\255 and tw)128 684 R (o-ar)-.1 E 1.526(gument forms of)-.18 F/F3 10/Times-Italic@0 SF (open\(\))4.026 E F0 1.526(will ha)4.026 F 1.826 -.15(ve l)-.2 H 1.526 (eading and trailing).15 F 2.512 (whitespace deleted and normal redirection characters honored.)128 696 R 2.512(This property)7.512 F 5.012(,k)-.65 G(no)-5.012 E 2.512(wn as `) -.25 F(`magic)-.74 E(open')128 708 Q .883 (', can often be used to good ef)-.74 F 3.383(fect. A)-.25 F .883 (user could specify a \214lename of)3.383 F F3 -1.11(``)3.383 G -.1(rs) 1.11 G 3.383(hc).1 G .883(at \214le |')-3.383 F(')-1.11 E F0 3.383(,o)C 3.383(ry)-3.383 G(ou)-3.383 E (could change certain \214lenames as needed:)128 720 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 45)162.62 F 0 Cg EP %%Page: 46 46 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($filename =~ s/\(.*\\.gz\)\\s*$/gzip \255dc < $1|/;)152 84 Q (open\(FH, $filename\) or die "Can\010t open $filename: $!";)152 96 Q F0 (Use the three-ar)128 114 Q (gument form to open a \214le with arbitrary weird characters in it,) -.18 E F1(open\(FOO, "<", $file\))152 132 Q (|| die "can\010t open < $file: $!";)176 144 Q F0(otherwise it')128 162 Q 2.5(sn)-.55 G(ecessary to protect an)-2.5 E 2.5(yl)-.15 G (eading and trailing whitespace:)-2.5 E F1($file =~ s#^\(\\s\)#./$1#;) 152 180 Q(open\(FOO, "< $file\\0"\))152 192 Q(|| die "open failed: $!";) 176 204 Q F0 1.597(\(this may not w)128 222 R 1.597 (ork on some bizarre \214lesystems\).)-.1 F 1.597 (One should conscientiously choose between the)6.597 F/F2 10 /Times-Italic@0 SF(ma)128 234 Q(gic)-.1 E F0(and)2.5 E F2(thr)2.5 E (ee-ar)-.37 E(gument)-.37 E F0(form of)2.5 E F2(open\(\))2.5 E F0(:)A F1 (open\(IN, $ARGV[0]\) || die "can\010t open $ARGV[0]: $!";)152 252 Q F0 .255(will allo)128 270 R 2.755(wt)-.25 G .255(he user to specify an ar) -2.755 F .255(gument of the form)-.18 F F1 .255("rsh cat file |")2.755 F F0 2.755(,b)C .255(ut will not w)-2.955 F .255(ork on a)-.1 F (\214lename that happens to ha)128 282 Q .3 -.15(ve a t)-.2 H (railing space, while).15 E F1(open\(IN, "<", $ARGV[0]\))152 300 Q (|| die "can\010t open < $ARGV[0]: $!";)176 312 Q F0(will ha)128 330 Q .3 -.15(ve ex)-.2 H(actly the opposite restrictions.).15 E 1.181 (If you w)128 348 R 1.181(ant a `)-.1 F(`real')-.74 E 3.681('C)-.74 G F1 (open)A F0(\(see)3.681 E F1(open\(2\))3.681 E F0 1.181 (on your system\), then you should use the)3.681 F F1(sysopen)3.682 E F0 1.78(function, which in)128 360 R -.2(vo)-.4 G(lv).2 E 1.78 (es no such magic \(b)-.15 F 1.779(ut may use subtly dif)-.2 F 1.779 (ferent \214lemodes than Perl)-.25 F F2(open\(\))4.279 E F0(,)A .143 (which is mapped to C)128 372 R F2(fopen\(\))2.644 E F0 2.644(\). This)B .144(is another w)2.644 F .144 (ay to protect your \214lenames from interpretation.)-.1 F -.15(Fo)5.144 G(r).15 E -.15(ex)128 384 S(ample:).15 E F1(use IO::Handle;)152 402 Q (sysopen\(HANDLE, $path, O_RDWR|O_CREAT|O_EXCL\))152 414 Q (or die "sysopen $path: $!";)176 426 Q ($oldfh = select\(HANDLE\); $| = 1; select\($oldfh\);)152 438 Q (print HANDLE "stuff $$\\n";)152 450 Q(seek\(HANDLE, 0, 0\);)152 462 Q (print "File contains: ", ;)152 474 Q F0 .628 (Using the constructor from the)128 492 R F1(IO::Handle)3.127 E F0 .627 (package \(or one of its subclasses, such as)3.127 F F1(IO::File)3.127 E F0(or)128 504 Q F1(IO::Socket)3.039 E F0 .539(\), you can generate anon) B .539(ymous \214lehandles that ha)-.15 F .839 -.15(ve t)-.2 H .54 (he scope of the v).15 F .54(ariables used)-.25 F .123 (to hold them, then automatically \(b)128 516 R .123 (ut silently\) close once their reference counts become zero, typically) -.2 F(at scope e)128 528 Q(xit:)-.15 E F1(use IO::File;)152 546 Q(#...) 152 558 Q(sub read_myfile_munged {)152 570 Q(my $ALL = shift;)176 582 Q 6(#o)176 594 S 6(rj)-6 G(ust leave it undef to autoviv)-6 E (my $handle = IO::File\255>new;)176 606 Q (open\($handle, "<", "myfile"\) or die "myfile: $!";)176 618 Q ($first = <$handle>)176 630 Q(or return \(\);)200 642 Q 6(#A)30 G (utomatically closed here.)-6 E(mung\($first\) or die "mung failed";)176 654 Q 6(#O)12 G 6(rh)-6 G(ere.)-6 E (return \(first, <$handle>\) if $ALL;)176 666 Q 6(#O)12 G 6(rh)-6 G (ere.)-6 E(return $first;)176 678 Q 6(#O)132 G 6(rh)-6 G(ere.)-6 E(})152 690 Q/F3 9/Times-Bold@0 SF -1.08(WA)128 708 S(RNING:)1.08 E F0 2.002 (The pre)4.502 F 2.002(vious e)-.25 F 2.003(xample has a b)-.15 F 2.003 (ug because the automatic close that happens when the)-.2 F 1.037 (refcount on)128 720 R F1(handle)3.537 E F0 1.037 (does not properly detect and report f)3.537 F(ailures.)-.1 E F2(Always) 6.036 E F0 1.036(close the handle yourself)3.536 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 46)162.62 F 0 Cg EP %%Page: 47 47 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (and inspect the return v)128 84 Q(alue.)-.25 E/F1 10/Courier@0 SF (close\($handle\))152 102 Q(|| warn "close failed: $!";)176 114 Q F0 (See `)128 132 Q(`seek')-.74 E 2.5('f)-.74 G (or some details about mixing reading and writing.)-2.5 E(opendir)108 148.8 Q/F2 9/Times-Roman@0 SF(DIRHANDLE)2.5 E F0(,EXPR)A 1.301 (Opens a directory named)128 160.8 R F2(EXPR)3.801 E F0 1.301 (for processing by)3.801 F F1(readdir)3.802 E F0(,)A F1(telldir)3.802 E F0(,)A F1(seekdir)3.802 E F0(,)A F1(rewinddir)3.802 E F0(,)A(and)128 172.8 Q F1(closedir)3.158 E F0 5.658(.R)C .658 (eturns true if successful.)-5.658 F F2(DIRHANDLE)5.657 E F0 .657 (may be an e)3.157 F .657(xpression whose v)-.15 F .657(alue can be)-.25 F .602(used as an indirect dirhandle, usually the real dirhandle name.) 128 184.8 R(If)5.602 E F2(DIRHANDLE)3.102 E F0 .603 (is an unde\214ned scalar)3.102 F -.25(va)128 196.8 S .102 (riable \(or array or hash element\), the v).25 F .102 (ariable is assigned a reference to a ne)-.25 F 2.601(wa)-.25 G(non) -2.601 E .101(ymous dirhandle;)-.15 F(that is, it')128 208.8 Q 2.5(sa) -.55 G(uto)-2.5 E(vi)-.15 E 2.5(vi\214ed. DIRHANDLEs)-.25 F(ha)2.5 E .3 -.15(ve t)-.2 H(heir o).15 E(wn namespace separate from FILEHANDLEs.) -.25 E(See the e)128 226.8 Q(xample at)-.15 E F1(readdir)2.5 E F0(.)A (ord)108 243.6 Q F2(EXPR)2.5 E F0(ord)108 255.6 Q .666 (Returns the numeric \(the nati)128 255.6 R .966 -.15(ve 8)-.25 H .666 (\255bit encoding, lik).15 F(e)-.1 E F2(ASCII)3.166 E F0(or)3.166 E F2 (EBCDIC)3.166 E F0 3.166(,o)C 3.166(rU)-3.166 G .666(nicode\) v)-3.166 F .667(alue of the \214rst)-.25 F 2.137(character of)128 267.6 R F2(EXPR) 4.637 E F0 7.137(.I)C(f)-7.137 E F2(EXPR)4.637 E F0 2.136 (is an empty string, returns 0.)4.637 F(If)7.136 E F2(EXPR)4.636 E F0 2.136(is omitted, uses)4.636 F F1($_)4.636 E F0 7.136(.\()C(Note)-7.136 E/F3 10/Times-Italic@0 SF -.15(ch)128 279.6 S(ar).15 E(acter)-.15 E F0 2.5(,n)C(ot byte.\))-2.5 E -.15(Fo)128 297.6 S 2.5(rt).15 G(he re)-2.5 E -.15(ve)-.25 G(rse, see `).15 E(`chr')-.74 E 2.5('. See)-.74 F (perlunicode for more about Unicode.)2.5 E(our)108 314.4 Q F2(EXPR)2.5 E F0(our)108 326.4 Q F2 .25(TYPE EXPR)2.5 F F0(our)108 338.4 Q F2(EXPR)2.5 E F0(:)2.5 E F2 -.999(AT)2.5 G(TRS).999 E F0(our)108 350.4 Q F2 .25 (TYPE EXPR)2.5 F F0(:)2.5 E F2 -.999(AT)2.5 G(TRS).999 E F1(our)128 362.4 Q F0 1.903(associates a simple name with a package v)4.403 F 1.903 (ariable in the current package for use within the)-.25 F .209 (current scope.)128 374.4 R(When)5.209 E F1 .209 (use strict \010vars\010)2.709 F F0 .209(is in ef)2.709 F(fect,)-.25 E F1(our)2.709 E F0 .208(lets you use declared global v)2.709 F(ariables) -.25 E .428(without qualifying them with package names, within the le) 128 386.4 R .428(xical scope of the)-.15 F F1(our)2.928 E F0 2.928 (declaration. In)2.928 F(this)2.928 E -.1(wa)128 398.4 S(y).1 E F1(our) 2.5 E F0(dif)2.5 E(fers from)-.25 E F1(use vars)2.5 E F0 2.5(,w)C (hich is package-scoped.)-2.5 E(Unlik)128 416.4 Q(e)-.1 E F1(my)3.482 E F0(or)3.482 E F1(state)3.482 E F0 3.482(,w)C .981 (hich allocates storage for a v)-3.482 F .981 (ariable and associates a simple name with that)-.25 F .585 (storage for use within the current scope,)128 428.4 R F1(our)3.086 E F0 .586(associates a simple name with a package \(read: global\))3.086 F -.25(va)128 440.4 S .548 (riable in the current package, for use within the current le).25 F .548 (xical scope.)-.15 F .548(In other w)5.548 F(ords,)-.1 E F1(our)3.048 E F0 .548(has the)3.048 F(same scoping rules as)128 452.4 Q F1(my)2.5 E F0 (or)2.5 E F1(state)2.5 E F0 2.5(,b)C(ut does not necessarily create a v) -2.7 E(ariable.)-.25 E(If more than one v)128 470.4 Q (alue is listed, the list must be placed in parentheses.)-.25 E F1 (our $foo;)152 488.4 Q(our\($bar, $baz\);)152 500.4 Q F0(An)128 518.4 Q F1(our)3.065 E F0 .565(declaration declares a global v)3.065 F .566 (ariable that will be visible across its entire le)-.25 F .566 (xical scope, e)-.15 F -.15(ve)-.25 G(n).15 E .286 (across package boundaries.)128 530.4 R .286(The package in which the v) 5.286 F .285(ariable is entered is determined at the point of)-.25 F (the declaration, not at the point of use.)128 542.4 Q (This means the follo)5 E(wing beha)-.25 E(vior holds:)-.2 E F1 (package Foo;)152 560.4 Q(our $bar;)152 572.4 Q 6(#d)36 G (eclares $Foo::bar for rest of lexical scope)-6 E($bar = 20;)152 584.4 Q (package Bar;)152 608.4 Q(print $bar;)152 620.4 Q 6(#p)24 G (rints 20, as it refers to $Foo::bar)-6 E F0(Multiple)128 638.4 Q F1 (our)3.67 E F0 1.17(declarations with the same name in the same le)3.67 F 1.171(xical scope are allo)-.15 F 1.171(wed if the)-.25 F 3.671(ya) -.15 G 1.171(re in)-3.671 F(dif)128 650.4 Q 1.317(ferent packages.)-.25 F 1.317(If the)6.317 F 3.817(yh)-.15 G 1.316 (appen to be in the same package, Perl will emit w)-3.817 F 1.316 (arnings if you ha)-.1 F -.15(ve)-.2 G(ask)128 662.4 Q .908 (ed for them, just lik)-.1 F 3.408(em)-.1 G(ultiple)-3.408 E F1(my)3.408 E F0 3.408(declarations. Unlik)3.408 F 3.408(eas)-.1 G(econd)-3.408 E F1 (my)3.408 E F0 .908(declaration, which will bind)3.408 F 1.306 (the name to a fresh v)128 674.4 R 1.306(ariable, a second)-.25 F F1 (our)3.806 E F0 1.306 (declaration in the same package, in the same scope, is)3.806 F (merely redundant.)128 686.4 Q(perl v5.14.2)72 768 Q 198.17 (2011-10-01 47)162.62 F 0 Cg EP %%Page: 48 48 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use warnings;)152 84 Q(package Foo;)152 96 Q(our $bar;)152 108 Q 6(#d) 36 G(eclares $Foo::bar for rest of lexical scope)-6 E($bar = 20;)152 120 Q(package Bar;)152 144 Q (our $bar = 30; # declares $Bar::bar for rest of lexical scope)152 156 Q (print $bar;)152 168 Q 6(#p)24 G(rints 30)-6 E(our $bar;)152 192 Q 6(#e) 36 G(mits warning but has no other effect)-6 E(print $bar;)152 204 Q 6 (#s)24 G(till prints 30)-6 E F0(An)128 222 Q F1(our)2.5 E F0 (declaration may also ha)2.5 E .3 -.15(ve a l)-.2 H(ist of attrib).15 E (utes associated with it.)-.2 E .571(The e)128 240 R .571 (xact semantics and interf)-.15 F .571(ace of)-.1 F/F2 9/Times-Roman@0 SF(TYPE)3.071 E F0(and)3.072 E F2 -.999(AT)3.072 G(TRS).999 E F0 .572 (are still e)3.072 F -.2(vo)-.25 G(lving.).2 E F2(TYPE)5.572 E F0 .572 (is currently bound to)3.072 F 1.043(the use of)128 252 R F1(fields) 3.542 E F0 1.042(pragma, and attrib)3.542 F 1.042 (utes are handled using the)-.2 F F1(attributes)3.542 E F0 1.042 (pragma, or starting)3.542 F .366(from Perl 5.8.0 also via the)128 264 R F1(Attribute::Handlers)2.866 E F0 2.866(module. See)2.866 F -.74(``) 2.866 G(Pri).74 E -.25(va)-.25 G .366(te V).25 F .366(ariables via)-1.11 F/F3 10/Times-Italic@0 SF(my\(\))2.867 E F0 1.847 -.74('' i)D(n).74 E (perlsub for details, and \214elds, attrib)128 276 Q(utes, and Attrib) -.2 E(ute::Handlers.)-.2 E(pack)108 292.8 Q F2(TEMPLA)2.5 E(TE)-.999 E F0(,LIST)A -.8(Ta)128 304.8 S -.1(ke).8 G 3.996(sa).1 G F2(LIST)A F0 1.496(of v)3.996 F 1.496(alues and con)-.25 F -.15(ve)-.4 G 1.496 (rts it into a string using the rules gi).15 F -.15(ve)-.25 G 3.995(nb) .15 G 3.995(yt)-3.995 G(he)-3.995 E F2(TEMPLA)3.995 E(TE)-.999 E F0 6.495(.T)C(he)-6.495 E .035 (resulting string is the concatenation of the con)128 316.8 R -.15(ve) -.4 G .036(rted v).15 F 2.536(alues. T)-.25 F(ypically)-.8 E 2.536(,e) -.65 G .036(ach con)-2.536 F -.15(ve)-.4 G .036(rted v).15 F .036 (alue looks lik)-.25 F(e)-.1 E .105(its machine-le)128 328.8 R -.15(ve) -.25 G 2.605(lr).15 G 2.605(epresentation. F)-2.605 F .105(or e)-.15 F .104(xample, on 32\255bit machines an inte)-.15 F .104 (ger may be represented by a)-.15 F(sequence of 4 bytes, which)128 340.8 Q(will in Perl be presented as a string that')5 E 2.5(s4c)-.55 G (haracters long.)-2.5 E (See perlpacktut for an introduction to this function.)128 358.8 Q(The) 128 376.8 Q F2(TEMPLA)2.5 E(TE)-.999 E F0 (is a sequence of characters that gi)2.5 E .3 -.15(ve t)-.25 H (he order and type of v).15 E(alues, as follo)-.25 E(ws:)-.25 E F1 12 (aA)152 394.8 S(string with arbitrary binary data, will be null padded.) -6 E 12(AA)152 406.8 S(text \(ASCII\) string, will be space padded.)-6 E 12(ZA)152 418.8 S (null\255terminated \(ASCIZ\) string, will be null padded.)-6 E 12(bA) 152 442.8 S (bit string \(ascending bit order inside each byte, like vec\(\)\).)-6 E 12(BA)152 454.8 S(bit string \(descending bit order inside each byte\).) -6 E 12(hA)152 466.8 S(hex string \(low nybble first\).)-6 E 12(HA)152 478.8 S(hex string \(high nybble first\).)-6 E 12(cA)152 502.8 S (signed char \(8\255bit\) value.)-6 E 12(CA)152 514.8 S 6(nu)-12 G (nsigned char \(octet\) value.)-6 E 12(WA)152 526.8 S 6(nu)-12 G (nsigned char value \(can be greater than 255\).)-6 E 12(sA)152 550.8 S (signed short \(16\255bit\) value.)-6 E 12(SA)152 562.8 S 6(nu)-12 G (nsigned short value.)-6 E 12(lA)152 586.8 S (signed long \(32\255bit\) value.)-6 E 12(LA)152 598.8 S 6(nu)-12 G (nsigned long value.)-6 E 12(qA)152 622.8 S (signed quad \(64\255bit\) value.)-6 E 12(QA)152 634.8 S 6(nu)-12 G (nsigned quad value.)-6 E (\(Quads are available only if your system supports 64\255bit)164 646.8 Q(integer values _and_ if Perl has been compiled to support those.)170 658.8 Q(Raises an exception otherwise.\))194 670.8 Q 12(iA)152 694.8 S (signed integer value.)-6 E 12(IA)152 706.8 S(unsigned integer value.)-6 E(\(This \010integer\010 is _at_least_ 32 bits wide.)164 718.8 Q (Its exact)12 E (size depends on what a local C compiler calls \010int\010.\))194 730.8 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 48)162.62 F 0 Cg EP %%Page: 49 49 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 12(nA)152 96 S 6(nu)-12 G (nsigned short \(16\255bit\) in "network" \(big\255endian\) order.)-6 E 12(NA)152 108 S 6(nu)-12 G (nsigned long \(32\255bit\) in "network" \(big\255endian\) order.)-6 E 12(vA)152 120 S 6(nu)-12 G (nsigned short \(16\255bit\) in "VAX" \(little\255endian\) order.)-6 E 12(VA)152 132 S 6(nu)-12 G (nsigned long \(32\255bit\) in "VAX" \(little\255endian\) order.)-6 E 18 (jA)152 156 S(Perl internal signed integer value \(IV\).)-12 E 18(JA)152 168 S(Perl internal unsigned integer value \(UV\).)-12 E 12(fA)152 192 S (single\255precision float in native format.)-6 E 12(dA)152 204 S (double\255precision float in native format.)-6 E 12(FA)152 228 S (Perl internal floating\255point value \(NV\) in native format)-6 E 12 (DA)152 240 S(float of long\255double precision in native format.)-6 E (\(Long doubles are available only if your system supports long)164 252 Q(double values _and_ if Perl has been compiled to support those.)170 264 Q(Raises an exception otherwise.\))194 276 Q 12(pA)152 300 S (pointer to a null\255terminated string.)-6 E 12(PA)152 312 S (pointer to a structure \(fixed\255length string\).)-6 E 12(uA)152 336 S (uuencoded string.)-6 E 12(UA)152 348 S(Unicode character number.)-6 E (Encodes to a character in character mode)12 E (and UTF\2558 \(or UTF\255EBCDIC in EBCDIC platforms\) in byte mode.)176 360 Q 12(wA)152 384 S (BER compressed integer \(not an ASN.1 BER, see perlpacktut for)-6 E 6 (details\). Its)170 396 R (bytes represent an unsigned integer in base 128,)6 E (most significant digit first, with as few digits as possible.)170 408 Q (Bit)12 E(eight \(the high bit\) is set on each byte except the last.) 170 420 Q 12(xA)152 444 S (null byte \(a.k.a ASCII NUL, "\\000", chr\(0\)\))-6 E 12(XB)152 456 S (ack up a byte.)-12 E 12(@N)152 468 S (ull\255fill or truncate to absolute position, counted from the)-12 E (start of the innermost \(\)\255group.)170 480 Q 12(.N)152 492 S (ull\255fill or truncate to absolute position specified by the value.) -12 E 12(\(S)152 504 S(tart of a \(\)\255group.)-12 E F0 1.777 (One or more modi\214ers belo)128 522 R 4.277(wm)-.25 G 1.777 (ay optionally follo)-4.277 F 4.277(wc)-.25 G 1.777 (ertain letters in the)-4.277 F/F2 9/Times-Roman@0 SF(TEMPLA)4.278 E(TE) -.999 E F0 1.778(\(the second)4.278 F (column lists letters for which the modi\214er is v)128 534 Q(alid\):) -.25 E F1 18(!s)152 552 S 24(SlLiI Forces)-18 F (native \(short, long, int\) sizes instead)6 E (of fixed \(16\255/32\255bit\) sizes.)242 564 Q 48(xX Make)176 588 R 6 (xa)6 G(nd X act as alignment commands.)-6 E 36(nNvV Treat)176 612 R (integers as signed instead of unsigned.)6 E 48(@. Specify)176 636 R (position as byte offset in the internal)6 E (representation of the packed string. Efficient but)242 648 Q (dangerous.)242 660 Q 18(>s)152 684 S 12(SiIlLqQ Force)-18 F (big\255endian byte\255order on the type.)6 E 12(jJfFdDpP \(The)176 696 R("big end" touches the construct.\))6 E 18()5.14 E F0(and)5.14 E F1(<)5.14 E F0 2.64 (modi\214ers can also be used on)5.14 F F1(\(\))5.14 E F0 2.64 (groups to force a particular byte-order on all)5.14 F (components in that group, including all its subgroups.)128 114 Q (The follo)128 132 Q(wing rules apply:)-.25 E<83>128 148.8 Q 1.792 (Each letter may optionally be follo)148 148.8 R 1.792 (wed by a number indicating the repeat count.)-.25 F 4.293(An)6.793 G (umeric)-4.293 E 1.79(repeat count may optionally be enclosed in brack) 148 160.8 R 1.79(ets, as in)-.1 F F1 1.79(pack\("C[80]", @arr\))4.29 F F0 6.79(.T)C(he)-6.79 E .493(repeat count gobbles that man)148 172.8 R 2.994(yv)-.15 G .494(alues from the)-3.244 F/F2 9/Times-Roman@0 SF(LIST) 2.994 E F0 .494(when used with all format types other than)2.994 F F1(a) 148 184.8 Q F0(,)A F1(A)2.838 E F0(,)A F1(Z)2.838 E F0(,)A F1(b)2.838 E F0(,)A F1(B)2.838 E F0(,)A F1(h)2.838 E F0(,)A F1(H)2.838 E F0(,)A F1(@) 2.838 E F0(,)A F1(.)2.838 E F0(,)A F1(x)2.838 E F0(,)A F1(X)2.838 E F0 2.838(,a)C(nd)-2.838 E F1(P)2.838 E F0 2.838(,w)C .338 (here it means something else, dscribed belo)-2.838 F 4.138 -.65(w. S) -.25 H(upplying).65 E(a)148 196.8 Q F1(*)3.4 E F0 .9 (for the repeat count instead of a number means to use ho)3.4 F(we)-.25 E -.15(ve)-.25 G 3.401(rm).15 G(an)-3.401 E 3.401(yi)-.15 G .901 (tems are left, e)-3.401 F(xcept)-.15 E(for:)148 208.8 Q<83>148 225.6 Q F1(@)168 225.6 Q F0(,)A F1(x)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(X)2.5 E F0 2.5(,w)C(here it is equi)-2.5 E -.25(va)-.25 G(lent to).25 E F1(0)2.5 E F0(.)A<83>148 242.4 Q(<.>, where it means relati)168 242.4 Q .3 -.15 (ve t)-.25 H 2.5(ot).15 G(he start of the string.)-2.5 E<83>148 259.2 Q F1(u)168 259.2 Q F0 2.5(,w)C(here it is equi)-2.5 E -.25(va)-.25 G (lent to 1 \(or 45, which here is equi).25 E -.25(va)-.25 G(lent\).).25 E 1.388(One can replace a numeric repeat count with a template letter e\ nclosed in brack)148 277.2 R 1.387(ets to use the)-.1 F(pack)148 289.2 Q (ed byte length of the brack)-.1 E(eted template for the repeat count.) -.1 E -.15(Fo)148 307.2 S 3.008(re).15 G .508(xample, the template) -3.158 F F1(x[L])3.009 E F0 .509(skips as man)3.009 F 3.009(yb)-.15 G .509(ytes as in a pack)-3.009 F .509(ed long, and the template)-.1 F F1 ("$t)3.009 E .598(X[$t] $t")148 319.2 R F0 .598(unpacks twice whate) 3.098 F -.15(ve)-.25 G(r).15 E F1($t)3.098 E F0 .597(\(when v)3.098 F (ariable-e)-.25 E .597(xpanded\) unpacks.)-.15 F .597 (If the template in)5.597 F(brack)148 331.2 Q .34 (ets contains alignment commands \(such as)-.1 F F1(x![d])2.84 E F0 .34 (\), its pack)B .34(ed length is calculated as if the)-.1 F (start of the template had the maximal possible alignment.)148 343.2 Q 1.889(When used with)148 361.2 R F1(Z)4.389 E F0 4.389(,a)C F1(*)A F0 1.889 (as the repeat count is guaranteed to add a trailing null byte, so the) 4.389 F(resulting string is al)148 373.2 Q -.1(wa)-.1 G (ys one byte longer than the byte length of the item itself.).1 E (When used with)148 391.2 Q F1(@)2.5 E F0 2.5(,t)C (he repeat count represents an of)-2.5 E (fset from the start of the innermost)-.25 E F1(\(\))2.5 E F0(group.)2.5 E .622(When used with)148 409.2 R F1(.)3.122 E F0 3.122(,t)C .623 (he repeat count determines the starting position to calculate the v) -3.122 F .623(alue of)-.25 F(fset)-.25 E(as follo)148 421.2 Q(ws:)-.25 E <83>148 438 Q(If the repeat count is)168 438 Q F1(0)2.5 E F0 2.5(,i)C (t')-2.5 E 2.5(sr)-.55 G(elati)-2.5 E .3 -.15(ve t)-.25 H 2.5(ot).15 G (he current position.)-2.5 E<83>148 454.8 Q(If the repeat count is)168 454.8 Q F1(*)2.5 E F0 2.5(,t)C(he of)-2.5 E(fset is relati)-.25 E .3 -.15(ve t)-.25 H 2.5(ot).15 G(he start of the pack)-2.5 E(ed string.)-.1 E<83>148 471.6 Q .019(And if it')168 471.6 R 2.519(sa)-.55 G 2.519(ni) -2.519 G(nte)-2.519 E(ger)-.15 E/F3 10/Times-Italic@0 SF(n)2.519 E F0 2.519(,t)C .019(he of)-2.519 F .019(fset is relati)-.25 F .319 -.15 (ve t)-.25 H 2.519(ot).15 G .018(he start of the)-2.519 F F3(n)2.518 E F0 .018(th innermost)B F1 6.018(\(\))2.518 G F0 .018(group, or to)-3.5 F (the start of the string if)168 483.6 Q F3(n)2.5 E F0 (is bigger then the group le)2.5 E -.15(ve)-.25 G(l.).15 E .075 (The repeat count for)148 501.6 R F1(u)2.575 E F0 .075(is interpreted a\ s the maximal number of bytes to encode per line of output,)2.575 F(wit\ h 0, 1 and 2 replaced by 45. The repeat count should not be more than 6\ 5.)148 513.6 Q<83>128 530.4 Q(The)148 530.4 Q F1(a)2.863 E F0(,)A F1(A) 2.863 E F0 2.863(,a)C(nd)-2.863 E F1(Z)2.863 E F0 .363 (types gobble just one v)2.863 F .363(alue, b)-.25 F .363 (ut pack it as a string of length count, padding with)-.2 F 2.027 (nulls or spaces as needed.)148 542.4 R 2.027(When unpacking,)7.027 F F1 (A)4.527 E F0 2.027(strips trailing whitespace and nulls,)4.527 F F1(Z) 4.528 E F0(strips)4.528 E -2.15 -.25(ev e)148 554.4 T (rything after the \214rst null, and).25 E F1(a)2.5 E F0 (returns data with no stripping at all.)2.5 E .997(If the v)148 572.4 R .997(alue to pack is too long, the result is truncated.)-.25 F .996 (If it')5.996 F 3.496(st)-.55 G .996(oo long and an e)-3.496 F .996 (xplicit count is)-.15 F(pro)148 584.4 Q(vided,)-.15 E F1(Z)4.509 E F0 2.009(packs only)4.509 F F1($count\2551)4.509 E F0 2.009(bytes, follo) 4.509 F 2.009(wed by a null byte.)-.25 F(Thus)7.01 E F1(Z)4.51 E F0(al) 4.51 E -.1(wa)-.1 G 2.01(ys packs a).1 F(trailing null, e)148 596.4 Q (xcept when the count is 0.)-.15 E<83>128 613.2 Q(Lik)148 613.2 Q -.25 (ew)-.1 G 2.309(ise, the).25 F F1(b)4.809 E F0(and)4.808 E F1(B)4.808 E F0 2.308(formats pack a string that')4.808 F 4.808(st)-.55 G 2.308 (hat man)-4.808 F 4.808(yb)-.15 G 2.308(its long.)-4.808 F 2.308 (Each such format)7.308 F(generates 1 bit of the result.)148 625.2 Q (These are typically follo)5 E(wed by a repeat count lik)-.25 E(e)-.1 E F1(B8)2.5 E F0(or)2.5 E F1(B64)2.5 E F0(.)A .96(Each result bit is base\ d on the least-signi\214cant bit of the corresponding input character) 148 643.2 R 3.46(,i)-.4 G .96(.e., on)-3.46 F F1(ord\($char\)%2)148 655.2 Q F0 5.44(.I)C 2.94(np)-5.44 G(articular)-2.94 E 2.94(,c)-.4 G (haracters)-2.94 E F1("0")2.94 E F0(and)2.94 E F1("1")2.94 E F0 .44 (generate bits 0 and 1, as do characters)2.94 F F1("\\000")148 667.2 Q F0(and)2.5 E F1("\\001")2.5 E F0(.)A 1.918(Starting from the be)148 685.2 R 1.919 (ginning of the input string, each 8\255tuple of characters is con)-.15 F -.15(ve)-.4 G 1.919(rted to 1).15 F 2.382(character of output.)148 697.2 R -.4(Wi)7.382 G 2.382(th format).4 F F1(b)4.882 E F0 4.882(,t)C 2.381(he \214rst character of the 8\255tuple determines the least-) -4.882 F(signi\214cant bit of a character; with format)148 709.2 Q F1(B) 2.5 E F0 2.5(,i)C 2.5(td)-2.5 G (etermines the most-signi\214cant bit of a character)-2.5 E(.)-.55 E .097(If the length of the input string is not e)148 727.2 R -.15(ve)-.25 G .097(nly di).15 F .098(visible by 8, the remainder is pack)-.25 F .098 (ed as if the input)-.1 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 50) 162.62 F 0 Cg EP %%Page: 51 51 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.079 (string were padded by null characters at the end.)148 84 R 1.078 (Similarly during unpacking, `)6.078 F(`e)-.74 E(xtra')-.15 E 3.578('b) -.74 G 1.078(its are)-3.578 F(ignored.)148 96 Q(If the input string is \ longer than needed, remaining characters are ignored.)148 114 Q(A)148 132 Q/F1 10/Courier@0 SF(*)2.606 E F0 .106 (for the repeat count uses all characters of the input \214eld.)2.606 F .106(On unpacking, bits are con)5.106 F -.15(ve)-.4 G .107(rted to).15 F 2.5(as)148 144 S(tring of)-2.5 E F1(0)2.5 E F0 2.5(sa)C(nd)-2.5 E F1(1) 2.5 E F0(s.)A<83>128 160.8 Q(The)148 160.8 Q F1(h)2.604 E F0(and)2.604 E F1(H)2.604 E F0 .103(formats pack a string that man)2.604 F 2.603(yn) -.15 G .103(ybbles \(4\255bit groups, representable as he)-2.753 F (xadecimal)-.15 E(digits,)148 172.8 Q F1 -3.5("0".."9" "a".."f")2.5 F F0 2.5(\)l)C(ong.)-2.5 E -.15(Fo)148 190.8 S 4.065(re).15 G 1.565 (ach such format,)-4.065 F/F2 10/Times-Italic@0 SF(pac)4.065 E(k\(\))-.2 E F0 1.565(generates 4 bits of result.)4.065 F -.4(Wi)6.566 G 1.566 (th non-alphabetical characters, the).4 F .129(result is based on the 4\ least-signi\214cant bits of the input character)148 202.8 R 2.629(,i) -.4 G .129(.e., on)-2.629 F F1(ord\($char\)%16)2.629 E F0 5.129(.I)C(n) -5.129 E(particular)148 214.8 Q 2.697(,c)-.4 G(haracters)-2.697 E F1 ("0")2.697 E F0(and)2.697 E F1("1")2.697 E F0 .197(generate n)2.697 F .197(ybbles 0 and 1, as do bytes)-.15 F F1("\\000")2.698 E F0(and)2.698 E F1("\\001")2.698 E F0(.)A -.15(Fo)148 226.8 S 3.145(rc).15 G (haracters)-3.145 E F1("a".."f")3.145 E F0(and)3.145 E F1("A".."F")3.145 E F0 3.145(,t)C .645(he result is compatible with the usual he)-3.145 F (xadecimal)-.15 E 1.252(digits, so that)148 238.8 R F1("a")3.752 E F0 (and)3.752 E F1("A")3.752 E F0 1.252(both generate the n)3.752 F(ybble) -.15 E F1(0xA==10)3.752 E F0 6.252(.U)C 1.252 (se only these speci\214c he)-6.252 F(x)-.15 E (characters with this format.)148 250.8 Q 1.072(Starting from the be)148 268.8 R 1.072(ginning of the template to)-.15 F F2(pac)3.572 E(k\(\))-.2 E F0 3.572(,e)C 1.072(ach pair of characters is con)-3.572 F -.15(ve)-.4 G 1.071(rted to 1).15 F .482(character of output.)148 280.8 R -.4(Wi) 5.483 G .483(th format).4 F F1(h)2.983 E F0 2.983(,t)C .483 (he \214rst character of the pair determines the least-signi\214cant) -2.983 F -.15(ny)148 292.8 S(bble of the output character; with format) .15 E F1(H)2.5 E F0 2.5(,i)C 2.5(td)-2.5 G (etermines the most-signi\214cant n)-2.5 E(ybble.)-.15 E .359 (If the length of the input string is not e)148 310.8 R -.15(ve)-.25 G .359(n, it beha).15 F -.15(ve)-.2 G 2.859(sa).15 G 2.859(si)-2.859 G 2.859(fp)-2.859 G .359(added by a null character at the end.)-2.859 F (Similarly)148 322.8 Q 2.5(,`)-.65 G(`e)-3.24 E(xtra')-.15 E 2.5('n)-.74 G(ybbles are ignored during unpacking.)-2.65 E (If the input string is longer than needed, e)148 340.8 Q (xtra characters are ignored.)-.15 E(A)148 358.8 Q F1(*)2.528 E F0 .028 (for the repeat count uses all characters of the input \214eld.)2.528 F -.15(Fo)5.028 G(r).15 E F2(unpac)2.529 E(k\(\))-.2 E F0 2.529(,n)C .029 (ybbles are con)-2.679 F -.15(ve)-.4 G(rted).15 E(to a string of he)148 370.8 Q(xadecimal digits.)-.15 E<83>128 387.6 Q(The)148 387.6 Q F1(p) 3.441 E F0 .941(format packs a pointer to a null-terminated string.) 3.441 F -1.1(Yo)5.941 G 3.44(ua)1.1 G .94 (re responsible for ensuring that)-3.44 F .057 (the string is not a temporary v)148 399.6 R .058 (alue, as that could potentially get deallocated before you got around) -.25 F .077(to using the pack)148 411.6 R .077(ed result.)-.1 F(The) 5.077 E F1(P)2.577 E F0 .076 (format packs a pointer to a structure of the size indicated by the) 2.576 F 3.154(length. A)148 423.6 R .654 (null pointer is created if the corresponding v)3.154 F .654(alue for) -.25 F F1(p)3.154 E F0(or)3.154 E F1(P)3.154 E F0(is)3.154 E F1(undef) 3.154 E F0 3.155(;s)C .655(imilarly with)-3.155 F F2(unpac)148 435.6 Q (k\(\))-.2 E F0 2.5(,w)C(here a null pointer unpacks into)-2.5 E F1 (undef)2.5 E F0(.)A .123(If your system has a strange pointer size)148 453.6 R 1.666<8a6d>1.666 G .123 (eaning a pointer is neither as big as an int nor as big)-1.666 F .506 (as a long)148 465.6 R 1.666<8a69>1.666 G 3.007(tm)-1.666 G .507(ay not\ be possible to pack or unpack pointers in big\255 or little-endian byt\ e order)-3.007 F(.)-.55 E(Attempting to do so raises an e)148 477.6 Q (xception.)-.15 E<83>128 494.4 Q(The)148 494.4 Q F1(/)2.764 E F0 .264 (template character allo)2.764 F .264 (ws packing and unpacking of a sequence of items where the pack)-.25 F (ed)-.1 E .745(structure contains a pack)148 506.4 R .745 (ed item count follo)-.1 F .745(wed by the pack)-.25 F .745 (ed items themselv)-.1 F 3.245(es. This)-.15 F .745(is useful)3.245 F .405(when the structure you')148 518.4 R .404(re unpacking has encoded \ the sizes or repeat counts for some of its \214elds)-.5 F (within the structure itself as separate \214elds.)148 530.4 Q -.15(Fo) 148 548.4 S(r).15 E F1(pack)3.759 E F0 3.759(,y)C 1.259(ou write)-3.759 F F2(length-item)3.759 E F1(/)A F2(sequence-item)A F0 3.759(,a)C 1.259 (nd the)-3.759 F F2(length-item)3.759 E F0 1.259(describes ho)3.759 F 3.759(wt)-.25 G 1.26(he length)-3.759 F -.25(va)148 560.4 S .298 (lue is pack).25 F .298(ed. F)-.1 F .298(ormats lik)-.15 F .298 (ely to be of most use are inte)-.1 F(ger)-.15 E .297(-packing ones lik) -.2 F(e)-.1 E F1(n)2.797 E F0 .297(for Ja)2.797 F .797 -.25(va s)-.2 H (trings,).25 E F1(w)148 572.4 Q F0(for)2.5 E/F3 9/Times-Roman@0 SF(ASN) 2.5 E F0(.1 or)A F3(SNMP)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(N)2.5 E F0 (for Sun)2.5 E F3(XDR)2.5 E F0(.)A -.15(Fo)148 590.4 S(r).15 E F1(pack) 3.417 E F0(,)A F2(sequence-item)3.417 E F0 .917(may ha)3.417 F 1.217 -.15(ve a r)-.2 H .918 (epeat count, in which case the minimum of that and the).15 F .012 (number of a)148 602.4 R -.25(va)-.2 G .011 (ilable items is used as the ar).25 F .011(gument for)-.18 F F2 (length-item)2.511 E F0 2.511(.I)C 2.511(fi)-2.511 G 2.511(th)-2.511 G .011(as no repeat count or uses)-2.511 F 2.5(a')148 614.4 S (*', the number of a)-2.5 E -.25(va)-.2 G(ilable items is used.).25 E -.15(Fo)148 632.4 S(r).15 E F1(unpack)5.679 E F0 5.679(,a)C 5.679(ni) -5.679 G 3.179(nternal stack of inte)-5.679 F 3.179(ger ar)-.15 F 3.179 (guments unpack)-.18 F 3.179(ed so f)-.1 F 3.18(ar is used. Y)-.1 F 3.18 (ou write)-1.1 F F1(/)148 644.4 Q F2(sequence-item)A F0 .681 (and the repeat count is obtained by popping of)3.181 F 3.181(ft)-.25 G .68(he last element from the stack.)-3.181 F(The)148 656.4 Q F2 (sequence-item)2.5 E F0(must not ha)2.5 E .3 -.15(ve a r)-.2 H (epeat count.).15 E(If)148 674.4 Q F2(sequence-item)3.108 E F0 .608 (refers to a string type \()3.108 F F1("A")A F0(,)A F1("a")3.108 E F0 3.108(,o)C(r)-3.108 E F1("Z")3.108 E F0 .608(\), the)B F2(length-item) 3.108 E F0 .609(is the string length,)3.108 F .257 (not the number of strings.)148 686.4 R -.4(Wi)5.257 G .257(th an e).4 F .257(xplicit repeat count for pack, the pack)-.15 F .257 (ed string is adjusted to)-.1 F(that length.)148 698.4 Q -.15(Fo)5 G 2.5 (re).15 G(xample:)-2.65 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 51) 162.62 F 0 Cg EP %%Page: 52 52 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (unpack\("W/a", "\\004Gurusamy"\))172 84 Q(gives \("Guru"\))66 E (unpack\("a3/A A*", "007 Bond)172 96 Q 6(J")12 G 42(\)g)-6 G (ives \(" Bond", "J"\))-42 E(unpack\("a3 x2 /A A*", "007: Bond, J."\)) 172 108 Q(gives \("Bond, J", "."\))12 E (pack\("n/a* w/a","hello,","world"\))172 132 Q (gives "\\000\\006hello,\\005world")42 E (pack\("a/W2", ord\("a"\) .. ord\("z"\)\))172 144 Q(gives "2ab")36 E F0 (The)148 162 Q/F2 10/Times-Italic@0 SF(length-item)2.5 E F0 (is not returned e)2.5 E(xplicitly from)-.15 E F1(unpack)2.5 E F0(.)A .509(Supplying a count to the)148 180 R F2(length-item)3.009 E F0 .509 (format letter is only useful with)3.009 F F1(A)3.01 E F0(,)A F1(a)3.01 E F0 3.01(,o)C(r)-3.01 E F1(Z)3.01 E F0 5.51(.P)C .51(acking with a) -5.66 F F2(length-item)148 192 Q F0(of)3.214 E F1(a)3.214 E F0(or)3.214 E F1(Z)3.214 E F0 .714(may introduce)3.214 F F1("\\000")3.214 E F0 .714 (characters, which Perl does not re)3.214 F -.05(ga)-.15 G .713 (rd as le).05 F -.05(ga)-.15 G 3.213(li).05 G(n)-3.213 E (numeric strings.)148 204 Q<83>128 220.8 Q 1.319(The inte)148 220.8 R 1.319(ger types)-.15 F F1(s)3.819 E F0(,)A F1(S)3.819 E F0(,)A F1(l) 3.819 E F0 3.819(,a)C(nd)-3.819 E F1(L)3.819 E F0 1.319(may be follo) 3.819 F 1.32(wed by a)-.25 F F1(!)3.82 E F0 1.32 (modi\214er to specify nati)3.82 F 1.62 -.15(ve s)-.25 H 1.32(horts or) .15 F 2.613(longs. As)148 232.8 R(sho)2.613 E .113(wn in the e)-.25 F .113(xample abo)-.15 F -.15(ve)-.15 G 2.612(,ab).15 G(are)-2.612 E F1(l) 2.612 E F0 .112(means e)2.612 F .112(xactly 32 bits, although the nati) -.15 F -.15(ve)-.25 G F1(long)2.762 E F0 .303 (as seen by the local C compiler may be lar)148 244.8 R(ger)-.18 E 5.303 (.T)-.55 G .303(his is mainly an issue on 64\255bit platforms.)-5.303 F -1.1(Yo)5.303 G(u)1.1 E(can see whether using)148 256.8 Q F1(!)2.5 E F0 (mak)2.5 E(es an)-.1 E 2.5(yd)-.15 G(if)-2.5 E(ference this w)-.25 E (ay:)-.1 E F1(printf "format s is %d, s! is %d\\n",)172 274.8 Q (length pack\("s"\), length pack\("s!"\);)196 286.8 Q (printf "format l is %d, l! is %d\\n",)172 310.8 Q (length pack\("l"\), length pack\("l!"\);)196 322.8 Q(i!)148 340.8 Q F0 (and)2.5 E F1(I!)2.5 E F0(are also allo)2.5 E(wed, b)-.25 E (ut only for completeness' sak)-.2 E(e: the)-.1 E 2.5(ya)-.15 G (re identical to)-2.5 E F1(i)2.5 E F0(and)2.5 E F1(I)2.5 E F0(.)A .242 (The actual sizes \(in bytes\) of nati)148 358.8 R .542 -.15(ve s)-.25 H .242(horts, ints, longs, and long longs on the platform where Perl).15 F -.1(wa)148 370.8 S 2.5(sb).1 G(uilt are also a)-2.7 E -.25(va)-.2 G (ilable from the command line:).25 E F1 6($p)172 388.8 S (erl \255V:{short,int,long{,long}}size)-6 E(shortsize=\0102\010;)172 400.8 Q(intsize=\0104\010;)172 412.8 Q(longsize=\0104\010;)172 424.8 Q (longlongsize=\0108\010;)172 436.8 Q F0(or programmatically via the)148 454.8 Q F1(Config)2.5 E F0(module:)2.5 E F1(use Config;)190 472.8 Q (print $Config{shortsize},)190 484.8 Q("\\n";)24 E (print $Config{intsize},)190 496.8 Q("\\n";)36 E (print $Config{longsize},)190 508.8 Q("\\n";)30 E (print $Config{longlongsize}, "\\n";)190 520.8 Q($Config{longlongsize}) 148 538.8 Q F0(is unde\214ned on systems without long long support.)2.5 E<83>128 555.6 Q .118(The inte)148 555.6 R .118(ger formats)-.15 F F1(s) 2.618 E F0(,)A F1(S)2.618 E F0(,)A F1(i)2.618 E F0(,)A F1(I)2.618 E F0 (,)A F1(l)2.618 E F0(,)A F1(L)2.618 E F0(,)A F1(j)2.618 E F0 2.618(,a)C (nd)-2.618 E F1(J)2.618 E F0 .119 (are inherently non-portable between processors and)2.618 F 1.384 (operating systems because the)148 567.6 R 3.884(yo)-.15 G(be)-3.884 E 3.883(yn)-.15 G(ati)-3.883 E 1.683 -.15(ve b)-.25 H 1.383 (yteorder and endianness.).15 F -.15(Fo)6.383 G 3.883(re).15 G 1.383 (xample, a 4\255byte)-4.033 F(inte)148 579.6 Q .18 (ger 0x12345678 \(305419896 decimal\) w)-.15 F .181 (ould be ordered nati)-.1 F -.15(ve)-.25 G .181 (ly \(arranged in and handled by).15 F(the)148 591.6 Q/F3 9 /Times-Roman@0 SF(CPU)2.5 E F0(re)2.5 E(gisters\) into bytes as)-.15 E F1(0x12 0x34 0x56 0x78)172 609.6 Q 6(#b)12 G(ig\255endian)-6 E (0x78 0x56 0x34 0x12)172 621.6 Q 6(#l)12 G(ittle\255endian)-6 E F0 (Basically)148 639.6 Q 5.311(,I)-.65 G 2.811(ntel and)-5.311 F F3 -1.215 (VA)5.311 G(X)1.215 E F0 2.811(CPUs are little-endian, while e)5.311 F -.15(ve)-.25 G 2.811(rybody else, including Motorola).15 F(m68k/88k,)148 651.6 Q F3(PPC)3.241 E F0 3.241(,S)C(parc,)-3.241 E F3 .991(HP P)3.241 F (A)-.828 E F0 3.241(,P)C -.25(ow)-3.241 G(er).25 E 3.241(,a)-.4 G .741 (nd Cray)-3.241 F 3.241(,a)-.65 G .741(re big-endian.)-3.241 F .741 (Alpha and)5.741 F F3(MIPS)3.241 E F0 .742(can be either:)3.241 F 1.559 (Digital/Compaq uses \(well, used\) them in little-endian mode, b)148 663.6 R 1.559(ut SGI/Cray uses them in big-)-.2 F(endian mode.)148 675.6 Q .238(The names)148 693.6 R F2(big-endian)2.738 E F0(and)2.738 E F2 (little-endian)2.738 E F0 .239(are comic references to the e)2.738 F .239(gg-eating habits of the little-)-.15 F 2.357(endian Lilliputians a\ nd the big-endian Blefuscudians from the classic Jonathan Swift satire,) 148 705.6 R F2(Gulliver')148 717.6 Q 3.944(sT)-.4 G -.15(ra)-4.494 G (vels).15 E F0 6.444(.T)C 1.444 (his entered computer lingo via the paper `)-6.444 F 1.444(`On Holy W) -.74 F 1.444(ars and a Plea for)-.8 F(Peace')148 729.6 Q 2.5('b)-.74 G 2.5(yD)-2.5 G(ann)-2.5 E 2.5(yC)-.15 G(ohen,)-2.5 E F3 .25(USC/ISI IEN) 2.5 F F0(137, April 1, 1980.)2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 52)162.62 F 0 Cg EP %%Page: 53 53 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (Some systems may ha)148 84 Q .3 -.15(ve e)-.2 H -.15(ve)-.1 G 2.5(nw) .15 G(eirder byte orders such as)-2.5 E/F1 10/Courier@0 SF (0x56 0x78 0x12 0x34)166 102 Q(0x34 0x12 0x78 0x56)166 114 Q F0 -1.1(Yo) 148 132 S 2.5(uc)1.1 G (an determine your system endianness with this incantation:)-2.5 E F1 (printf\("%#02x ", $_\) for unpack\("W*", pack L=>0x12345678\);)166 150 Q F0(The byteorder on the platform where Perl w)148 168 Q(as b)-.1 E (uilt is also a)-.2 E -.25(va)-.2 G(ilable via Con\214g:).25 E F1 (use Config;)172 186 Q(print "$Config{byteorder}\\n";)172 198 Q F0 (or from the command line:)148 216 Q F1 6($p)172 234 S (erl \255V:byteorder)-6 E F0(Byteorders)148 252 Q F1("1234")3.56 E F0 (and)3.56 E F1("12345678")3.56 E F0 1.06(are little-endian;)3.56 F F1 ("4321")3.56 E F0(and)3.56 E F1("87654321")3.56 E F0 1.06(are big-)3.56 F(endian.)148 264 Q -.15(Fo)148 282 S 4.316(rp).15 G 1.816(ortably pack) -4.316 F 1.816(ed inte)-.1 F 1.817(gers, either use the formats)-.15 F F1(n)4.317 E F0(,)A F1(N)4.317 E F0(,)A F1(v)4.317 E F0 4.317(,a)C(nd) -4.317 E F1(V)4.317 E F0 1.817(or else use the)4.317 F F1(>)4.317 E F0 (and)4.317 E F1(<)4.317 E F0(modi\214ers described immediately belo)148 294 Q 3.8 -.65(w. S)-.25 H(ee also perlport.).65 E<83>128 310.8 Q .882 (Starting with Perl 5.9.2, inte)148 310.8 R .882 (ger and \215oating-point formats, along with the)-.15 F F1(p)3.382 E F0 (and)3.382 E F1(P)3.382 E F0 .882(formats and)3.382 F F1(\(\))148 322.8 Q F0 .625(groups, may all be follo)3.125 F .625(wed by the)-.25 F F1(>) 3.126 E F0(or)3.126 E F1(<)3.126 E F0 .626 (endianness modi\214ers to respecti)3.126 F -.15(ve)-.25 G .626 (ly enforce big\255).15 F .519(or little-endian byte-order)148 334.8 R 5.519(.T)-.55 G .519(hese modi\214ers are especially useful gi)-5.519 F -.15(ve)-.25 G 3.019(nh).15 G -.25(ow)-3.019 G F1(n)3.269 E F0(,)A F1(N) 3.018 E F0(,)A F1(v)3.018 E F0 3.018(,a)C(nd)-3.018 E F1(V)3.018 E F0 (don')3.018 E(t)-.18 E(co)148 346.8 Q -.15(ve)-.15 G 2.5(rs).15 G (igned inte)-2.5 E(gers, 64\255bit inte)-.15 E (gers, or \215oating-point v)-.15 E(alues.)-.25 E (Here are some concerns to k)148 364.8 Q (eep in mind when using an endianness modi\214er:)-.1 E<83>148 381.6 Q .157(Exchanging signed inte)168 381.6 R .157(gers between dif)-.15 F .157(ferent platforms w)-.25 F .158(orks only when all platforms store) -.1 F 3.111(them in the same format.)168 393.6 R 3.111 (Most platforms store signed inte)8.111 F 3.111(gers in tw)-.15 F(o')-.1 E(s-complement)-.55 E(notation, so usually this is not an issue.)168 405.6 Q<83>148 422.4 Q(The)168 422.4 Q F1(>)3.922 E F0(or)3.922 E F1(<) 3.922 E F0 1.422(modi\214ers can only be used on \215oating-point forma\ ts on big\255 or little-endian)3.922 F 2.5(machines. Otherwise,)168 434.4 R(attempting to use them raises an e)2.5 E(xception.)-.15 E<83>148 451.2 Q -.15(Fo)168 451.2 S .359 (rcing big\255 or little-endian byte-order on \215oating-point v).15 F .358(alues for data e)-.25 F .358(xchange can w)-.15 F(ork)-.1 E .312 (only if all platforms use the same binary representation such as)168 463.2 R/F2 9/Times-Roman@0 SF(IEEE)2.812 E F0 2.812 (\215oating-point. Ev)2.812 F .312(en if)-.15 F .505 (all platforms are using)168 475.2 R F2(IEEE)3.005 E F0 3.005(,t)C .505 (here may still be subtle dif)-3.005 F 3.005(ferences. Being)-.25 F .505 (able to use)3.005 F F1(>)3.005 E F0(or)3.005 E F1(<)3.005 E F0 1.072 (on \215oating-point v)168 487.2 R 1.073(alues can be useful, b)-.25 F 1.073(ut also dangerous if you don')-.2 F 3.573(tk)-.18 G(no)-3.573 E 3.573(we)-.25 G 1.073(xactly what)-3.723 F(you')168 499.2 Q(re doing.) -.5 E(It is not a general w)5 E(ay to portably store \215oating-point v) -.1 E(alues.)-.25 E<83>148 516 Q .909(When using)168 516 R F1(>)3.409 E F0(or)3.409 E F1(<)3.409 E F0 .909(on a)3.409 F F1(\(\))3.409 E F0 .909 (group, this af)3.409 F .909 (fects all types inside the group that accept byte-)-.25 F .878 (order modi\214ers, including all subgroups.)168 528 R .879 (It is silently ignored for all other types.)5.878 F -1.1(Yo)5.879 G 3.379(ua)1.1 G(re)-3.379 E .505(not allo)168 540 R .505(wed to o)-.25 F -.15(ve)-.15 G .505(rride the byte-order within a group that already ha\ s a byte-order modi\214er).15 F(suf)168 552 Q(\214x.)-.25 E<83>128 568.8 Q .632(Real numbers \(\215oats and doubles\) are in nati)148 568.8 R .932 -.15(ve m)-.25 H .632(achine format only).15 F 5.632(.D)-.65 G .632 (ue to the multiplicity of)-5.632 F .845 (\215oating-point formats and the lack of a standard `)148 580.8 R (`netw)-.74 E(ork')-.1 E 3.344('r)-.74 G .844 (epresentation for them, no f)-3.344 F(acility)-.1 E 2.453 (for interchange has been made.)148 592.8 R 2.453(This means that pack) 7.453 F 2.453(ed \215oating-point data written on one)-.1 F .182 (machine may not be readable on another)148 604.8 R 2.682(,e)-.4 G -.15 (ve)-2.932 G 2.682(ni).15 G 2.682(fb)-2.682 G .182(oth use)-2.682 F F2 (IEEE)2.682 E F0 .181(\215oating-point arithmetic \(because)2.682 F (the endianness of the memory representation is not part of the)148 616.8 Q F2(IEEE)2.5 E F0 2.5(spec\). See)2.5 F(also perlport.)2.5 E .692 (If you kno)148 634.8 R(w)-.25 E/F3 10/Times-Italic@0 SF -.2(ex)3.192 G (actly).2 E F0 .692(what you')3.192 F .692(re doing, you can use the)-.5 F F1(>)3.192 E F0(or)3.192 E F1(<)3.192 E F0 .692 (modi\214ers to force big\255 or little-)3.192 F (endian byte-order on \215oating-point v)148 646.8 Q(alues.)-.25 E .565 (Because Perl uses doubles \(or long doubles, if con\214gured\) interna\ lly for all numeric calculation,)148 664.8 R(con)148 676.8 Q -.15(ve)-.4 G .468(rting from double into \215oat and thence to double ag).15 F .468 (ain loses precision, so)-.05 F F1(unpack\("f",)2.968 E (pack\("f", $foo\))148 688.8 Q F0 2.5(\)w)C(ill not in general equal) -2.5 E F1($foo)2.5 E F0(.)A<83>128 705.6 Q -.15(Pa)148 705.6 S .028 (ck and unpack can operate in tw).15 F 2.528(om)-.1 G .028 (odes: character mode \()-2.528 F F1(C0)A F0 .028(mode\) where the pack) 2.528 F .028(ed string is)-.1 F .564(processed per character)148 717.6 R 3.064(,a)-.4 G(nd)-3.064 E F2(UTF\2558)3.064 E F0 .564(mode \()3.064 F F1(U0)A F0 .564(mode\) where the pack)3.064 F .565 (ed string is processed in its)-.1 F .368(UTF\2558\255encoded Unicode f\ orm on a byte-by-byte basis. Character mode is the def)148 729.6 R .367 (ault unless the)-.1 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 53)162.62 F 0 Cg EP %%Page: 54 54 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .237 (format string starts with)148 84 R/F1 10/Courier@0 SF(U)2.737 E F0 2.737(.Y)C .237(ou can al)-3.837 F -.1(wa)-.1 G .238 (ys switch mode mid-format with an e).1 F(xplicit)-.15 E F1(C0)2.738 E F0(or)2.738 E F1(U0)2.738 E F0(in)2.738 E .813(the format.)148 96 R .813 (This mode remains in ef)5.813 F .812(fect until the ne)-.25 F .812 (xt mode change, or until the end of the)-.15 F F1(\(\))3.312 E F0 (group it \(directly\) applies to.)148 108 Q(Using)148 126 Q F1(C0)3.086 E F0 .586(to get Unicode characters while using)3.086 F F1(U0)3.087 E F0 .587(to get)3.087 F/F2 10/Times-Italic@0 SF(non)3.087 E F0 .587 (\255Unicode bytes is not necessarily)B(ob)148 138 Q 5(vious. Probably) -.15 F(only the \214rst of these is what you w)2.5 E(ant:)-.1 E F1 6($p) 172 156 S(erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \ \255CS \255ne \010printf "%v04X\\n", $_ for unpack\("C0A*", $_\)\010)184 168 Q(03B1.03C9)172 180 Q 6($p)172 192 S (erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \255CS \ \255ne \010printf "%v02X\\n", $_ for unpack\("U0A*", $_\)\010)184 204 Q (CE.B1.CF.89)172 216 Q 6($p)172 228 S (erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \255C0 \ \255ne \010printf "%v02X\\n", $_ for unpack\("C0A*", $_\)\010)184 240 Q (CE.B1.CF.89)172 252 Q 6($p)172 264 S (erl \255CS \255E \010say "\\x{3B1}\\x{3C9}"\010 |)-6 E(perl \255C0 \ \255ne \010printf "%v02X\\n", $_ for unpack\("U0A*", $_\)\010)184 276 Q (C3.8E.C2.B1.C3.8F.C2.89)172 288 Q F0 .941(Those e)148 306 R .941 (xamples also illustrate that you should not try to use)-.15 F F1(pack) 3.44 E F0(/)A F1(unpack)A F0 .94(as a substitute for)3.44 F (the Encode module.)148 318 Q<83>128 334.8 Q -1.1(Yo)148 334.8 S 3.245 (um)1.1 G .745(ust yourself do an)-3.245 F 3.246(ya)-.15 G .746 (lignment or padding by inserting, for e)-3.246 F .746(xample, enough) -.15 F F1("x")3.246 E F0 .746(es while)B 4.138(packing. There)148 346.8 R 1.638(is no w)4.138 F 1.638(ay for)-.1 F F2(pac)4.138 E(k\(\))-.2 E F0 (and)4.138 E F2(unpac)4.138 E(k\(\))-.2 E F0 1.637(to kno)4.137 F 4.137 (ww)-.25 G 1.637(here characters are going to or)-4.137 F (coming from, so the)148 358.8 Q 2.5(yh)-.15 G (andle their output and input as \215at sequences of characters.)-2.5 E <83>128 375.6 Q(A)148 375.6 Q F1(\(\))4.011 E F0 1.511 (group is a sub-TEMPLA)4.011 F 1.511(TE enclosed in parentheses.)-1.11 F 4.011(Ag)6.511 G 1.512(roup may tak)-4.011 F 4.012(ear)-.1 G 1.512 (epeat count)-4.012 F .904(either as post\214x, or for)148 387.6 R F2 (unpac)3.404 E(k\(\))-.2 E F0 3.404(,a)C .904(lso via the)-3.404 F F1(/) 3.404 E F0 .904(template character)3.404 F 5.904(.W)-.55 G .903 (ithin each repetition of a)-6.304 F(group, positioning with)148 399.6 Q F1(@)2.5 E F0(starts o)2.5 E -.15(ve)-.15 G 2.5(ra).15 G 2.5(t0)-2.5 G 2.5(.T)-2.5 G(herefore, the result of)-2.5 E F1 (pack\("@1A\(\(@2A\)@3A\)", qw[X Y Z]\))172 417.6 Q F0(is the string)148 435.6 Q F1("\\0X\\0\\0YZ")2.5 E F0(.)A<83>128 452.4 Q F1(x)148 452.4 Q F0(and)3.202 E F1(X)3.202 E F0 .702(accept the)3.202 F F1(!)3.202 E F0 .702(modi\214er to act as alignment commands: the)3.202 F 3.202(yj)-.15 G .702(ump forw)-3.202 F .703(ard or back to the)-.1 F .537 (closest position aligned at a multiple of)148 464.4 R F1(count)3.037 E F0 .537(characters. F)3.037 F .537(or e)-.15 F .536(xample, to)-.15 F F2 (pac)3.036 E(k\(\))-.2 E F0(or)3.036 E F2(unpac)3.036 E(k\(\))-.2 E F0 (a)3.036 E 2.5(Cs)148 476.4 S(tructure lik)-2.5 E(e)-.1 E F1(struct {) 172 494.4 Q 12(char c;)196 506.4 R(/* one signed, 8\255bit character */) 24 E(double d;)196 518.4 Q 12(char cc[2];)196 530.4 R(})172 542.4 Q F0 1.63(one may need to use the template)148 560.4 R F1 7.63(cx)4.13 G 1.63 (![d] d c[2])-7.63 F F0 6.63(.T)C 1.63(his assumes that doubles must be) -6.63 F(aligned to the size of double.)148 572.4 Q -.15(Fo)148 590.4 S 2.5(ra).15 G(lignment commands, a)-2.5 E F1(count)2.5 E F0(of 0 is equi) 2.5 E -.25(va)-.25 G(lent to a).25 E F1(count)2.5 E F0 (of 1; both are no-ops.)2.5 E<83>128 607.2 Q F1(n)148 607.2 Q F0(,)A F1 (N)2.975 E F0(,)A F1(v)2.975 E F0(and)2.975 E F1(V)2.975 E F0 .475 (accept the)2.975 F F1(!)2.975 E F0 .474 (modi\214er to represent signed 16\255/32\255bit inte)2.975 F .474 (gers in big\255/little\255endian)-.15 F(order)148 619.2 Q 7.892(.T)-.55 G 2.892(his is portable only when all platforms sharing pack)-7.892 F 2.892(ed data use the same binary)-.1 F 3.274 (representation for signed inte)148 631.2 R 3.274(gers; for e)-.15 F 3.274(xample, when all platforms use tw)-.15 F(o')-.1 E(s-complement) -.55 E(representation.)148 643.2 Q<83>128 660 Q .732 (Comments can be embedded in a)148 660 R/F3 9/Times-Roman@0 SF(TEMPLA) 3.232 E(TE)-.999 E F0(using)3.232 E F1(#)3.233 E F0 .733 (through the end of line.)3.233 F .733(White space can)5.733 F .937 (separate pack codes from each other)148 672 R 3.437(,b)-.4 G .937 (ut modi\214ers and repeat counts must follo)-3.637 F 3.436(wi)-.25 G (mmediately)-3.436 E(.)-.65 E .743(Breaking comple)148 684 R 3.243(xt) -.15 G .743(emplates into indi)-3.243 F .743 (vidual line-by-line components, suitably annotated, can do)-.25 F 3.222 (as much to impro)148 696 R 3.522 -.15(ve l)-.15 H -.15(eg).15 G 3.222 (ibility and maintainability of pack/unpack formats as).15 F F1(/x)5.721 E F0 3.221(can for)5.721 F(complicated pattern matches.)148 708 Q (perl v5.14.2)72 768 Q 198.17(2011-10-01 54)162.62 F 0 Cg EP %%Page: 55 55 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E<83>128 84 Q(If)148 84 Q/F1 9/Times-Roman@0 SF(TEMPLA)5.073 E(TE)-.999 E F0 2.573 (requires more ar)5.073 F 2.573(guments than)-.18 F/F2 10/Times-Italic@0 SF(pac)5.073 E(k\(\))-.2 E F0 2.574(is gi)5.073 F -.15(ve)-.25 G(n,).15 E F2(pac)5.074 E(k\(\))-.2 E F0 2.574(assumes additional)5.074 F/F3 10 /Courier@0 SF("")5.074 E F0(ar)148 96 Q 2.5(guments. If)-.18 F F1 (TEMPLA)2.5 E(TE)-.999 E F0(requires fe)2.5 E(wer ar)-.25 E (guments than gi)-.18 E -.15(ve)-.25 G(n, e).15 E(xtra ar)-.15 E (guments are ignored.)-.18 E(Examples:)128 114 Q F3 ($foo = pack\("WWWW",65,66,67,68\);)152 132 Q 6(#f)152 144 S (oo eq "ABCD")-6 E($foo = pack\("W4",65,66,67,68\);)152 156 Q 6(#s)152 168 S(ame thing)-6 E($foo = pack\("W4",0x24b6,0x24b7,0x24b8,0x24b9\);) 152 180 Q 6(#s)152 192 S(ame thing with Unicode circled letters.)-6 E ($foo = pack\("U4",0x24b6,0x24b7,0x24b8,0x24b9\);)152 204 Q 6(#s)152 216 S(ame thing with Unicode circled letters. You don\010t get the UTF\2558) -6 E 6(#b)152 228 S (ytes because the U at the start of the format caused a switch to)-6 E 6 (#U)152 240 S (0\255mode, so the UTF\2558 bytes get joined into characters)-6 E ($foo = pack\("C0U4",0x24b6,0x24b7,0x24b8,0x24b9\);)152 252 Q 6(#f)152 264 S (oo eq "\\xe2\\x92\\xb6\\xe2\\x92\\xb7\\xe2\\x92\\xb8\\xe2\\x92\\xb9")-6 E 6(#T)152 276 S (his is the UTF\2558 encoding of the string in the previous example)-6 E ($foo = pack\("ccxxcc",65,66,67,68\);)152 300 Q 6(#f)152 312 S (oo eq "AB\\0\\0CD")-6 E 6(#N)152 336 S (OTE: The examples above featuring "W" and "c" are true)-6 E 6(#o)152 348 S(nly on ASCII and ASCII\255derived systems such as ISO Latin 1)-6 E 6(#a)152 360 S(nd UTF\2558.)-6 E (On EBCDIC systems, the first example would be)12 E 36(#$)152 372 S (foo = pack\("WWWW",193,194,195,196\);)-36 E($foo = pack\("s2",1,2\);) 152 396 Q 6(#")152 408 S(\\001\\000\\002\\000" on little\255endian)-6 E 6(#")152 420 S(\\000\\001\\000\\002" on big\255endian)-6 E ($foo = pack\("a4","abcd","x","y","z"\);)152 444 Q 6(#")152 456 S(abcd") -6 E($foo = pack\("aaaa","abcd","x","y","z"\);)152 480 Q 6(#")152 492 S (axyz")-6 E($foo = pack\("a14","abcdefg"\);)152 516 Q 6(#")152 528 S (abcdefg\\0\\0\\0\\0\\0\\0\\0")-6 E($foo = pack\("i9pl", gmtime\);)152 552 Q 6(#ar)152 564 S(eal struct tm \(on my system anyway\))-6 E ($utmp_template = "Z8 Z8 Z16 L";)152 588 Q ($utmp = pack\($utmp_template, @utmp1\);)152 600 Q 6(#as)152 612 S (truct utmp \(BSDish\))-6 E(@utmp2 = unpack\($utmp_template, $utmp\);) 152 636 Q 6(#")152 648 S(@utmp1" eq "@utmp2")-6 E(sub bintodec {)152 672 Q(unpack\("N", pack\("B32", substr\("0" x 32 . shift, \25532\)\)\);)176 684 Q(})152 696 Q($foo = pack\(\010sx2l\010, 12, 34\);)152 720 Q F0 (perl v5.14.2)72 768 Q 198.17(2011-10-01 55)162.62 F 0 Cg EP %%Page: 56 56 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#s)152 84 S(hort 12, two zero bytes padding, long 34)-6 E ($bar = pack\(\010s@4l\010, 12, 34\);)152 96 Q 6(#s)152 108 S (hort 12, zero fill to position 4, long 34)-6 E 6(#$)152 120 S (foo eq $bar)-6 E($baz = pack\(\010s.l\010, 12, 4, 34\);)152 132 Q 6(#s) 152 144 S(hort 12, zero fill to position 4, long 34)-6 E ($foo = pack\(\010nN\010, 42, 4711\);)152 168 Q 6(#p)152 180 S (ack big\255endian 16\255 and 32\255bit unsigned integers)-6 E ($foo = pack\(\010S>L>\010, 42, 4711\);)152 192 Q 6(#e)152 204 S (xactly the same)-6 E($foo = pack\(\010s.15 G 2.538(ag on \214les, that \215ag is set on all ne)-5.037 F 2.538(wly opened \214le)-.25 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 56)162.62 F 0 Cg EP %%Page: 57 57 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .409 (descriptors whose)128 84 R/F1 10/Courier@0 SF(fileno)2.909 E F0 2.909 (sa)C(re)-2.909 E/F2 10/Times-Italic@0 SF(higher)2.909 E F0 .409 (than the current v)2.909 F .409(alue of $^F \(by def)-.25 F .408 (ault 2 for)-.1 F F1(STDERR)2.908 E F0 2.908(\). See)B -.74(``)128 96 S ($^F').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E (pop)108 112.8 Q/F3 9/Times-Roman@0 SF(ARRA)2.5 E(Y)-.945 E F0(pop)108 124.8 Q F3(EXPR)2.5 E F0(pop)108 136.8 Q(Pops and returns the last v)128 136.8 Q(alue of the array)-.25 E 2.5(,s)-.65 G (hortening the array by one element.)-2.5 E 1.186 (Returns the unde\214ned v)128 154.8 R 1.186(alue if the array is empty) -.25 F 3.686(,a)-.65 G 1.187 (lthough this may also happen at other times.)-3.686 F(If)6.187 E F3 (ARRA)128 166.8 Q(Y)-.945 E F0 .765(is omitted, pops the)3.265 F F1 (@ARGV)3.265 E F0 .765(array in the main program, b)3.265 F .765(ut the) -.2 F F1(@_)3.265 E F0 .765(array in subroutines, just)3.265 F(lik)128 178.8 Q(e)-.1 E F1(shift)2.5 E F0(.)A 1.31(Starting with Perl 5.14,)128 196.8 R F1(pop)3.81 E F0 1.31(can tak)3.81 F 3.81(eas)-.1 G(calar)-3.81 E F3(EXPR)3.81 E F0 3.81(,w)C 1.311 (hich must hold a reference to an unblessed)-3.81 F(array)128 208.8 Q 6.647(.T)-.65 G 1.647(he ar)-6.647 F 1.646 (gument will be dereferenced automatically)-.18 F 6.646(.T)-.65 G 1.646 (his aspect of)-6.646 F F1(pop)4.146 E F0 1.646(is considered highly) 4.146 F -.15(ex)128 220.8 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(pos)108 237.6 Q F3(SCALAR)2.5 E F0(pos)108 249.6 Q .315 (Returns the of)128 249.6 R .315(fset of where the last)-.25 F F1(m//g) 2.816 E F0 .316(search left of)2.816 F 2.816(ff)-.25 G .316(or the v) -2.816 F .316(ariable in question \()-.25 F F1($_)A F0 .316 (is used when)2.816 F 1.555(the v)128 261.6 R 1.554 (ariable is not speci\214ed\). Note that 0 is a v)-.25 F 1.554 (alid match of)-.25 F(fset.)-.25 E F1(undef)4.054 E F0 1.554 (indicates that the search)4.054 F .709 (position is reset \(usually due to match f)128 273.6 R .709(ailure, b) -.1 F .71(ut can also be because no match has yet been run on)-.2 F (the scalar\).)128 285.6 Q F1(pos)128 303.6 Q F0 .683 (directly accesses the location used by the re)3.183 F(ge)-.15 E .683 (xp engine to store the of)-.15 F .683(fset, so assigning to)-.25 F F1 (pos)3.182 E F0 .726(will change that of)128 315.6 R .726 (fset, and so will also in\215uence the)-.25 F F1(\\G)3.226 E F0 .726 (zero-width assertion in re)3.226 F .726(gular e)-.15 F(xpressions.)-.15 E .788(Both of these ef)128 327.6 R .788(fects tak)-.25 F 3.287(ep)-.1 G .787(lace for the ne)-3.287 F .787(xt match, so you can')-.15 F 3.287 (ta)-.18 G -.25(ff)-3.287 G .787(ect the position with).25 F F1(pos) 3.287 E F0(during)3.287 E(the current match, such as in)128 339.6 Q F1 (\(?{pos\(\) = 5}\))2.5 E F0(or)2.5 E F1(s//pos\(\) = 5/e)2.5 E F0(.)A (Setting)128 357.6 Q F1(pos)5.392 E F0 2.892(also resets the)5.392 F F2 (matc)5.392 E 2.892(hed with zer)-.15 F(o-length)-.45 E F0 2.893 (\215ag, described under `)5.393 F 2.893(`Repeated P)-.74 F(atterns)-.15 E(Matching a Zero-length Substring')128 369.6 Q 2.5('i)-.74 G 2.5(np) -2.5 G(erlre.)-2.5 E 1.019(Because a f)128 387.6 R(ailed)-.1 E F1(m//gc) 3.518 E F0 1.018(match doesn')3.518 F 3.518(tr)-.18 G 1.018(eset the of) -3.518 F 1.018(fset, the return from)-.25 F F1(pos)3.518 E F0 -.1(wo) 3.518 G(n').1 E 3.518(tc)-.18 G 1.018(hange either in)-3.518 F (this case.)128 399.6 Q(See perlre and perlop.)5 E(print)108 416.4 Q F3 .25(FILEHANDLE LIST)2.5 F F0(print)108 428.4 Q F3(FILEHANDLE)2.5 E F0 (print)108 440.4 Q F3(LIST)2.5 E F0(print)108 452.4 Q .747 (Prints a string or a list of strings.)128 464.4 R .747 (Returns true if successful.)5.747 F F3(FILEHANDLE)5.747 E F0 .747 (may be a scalar v)3.247 F(ariable)-.25 E 1.85(containing the name of o\ r a reference to the \214lehandle, thus introducing one le)128 476.4 R -.15(ve)-.25 G 4.35(lo).15 G 4.35(fi)-4.35 G(ndirection.)-4.35 E(\()128 488.4 Q F3(NO)A(TE:)-.36 E F0(If)3.959 E F3(FILEHANDLE)3.959 E F0 1.459 (is a v)3.959 F 1.459(ariable and the ne)-.25 F 1.459(xt tok)-.15 F 1.459(en is a term, it may be misinterpreted as an)-.1 F 2.3 (operator unless you interpose a)128 500.4 R F1(+)4.8 E F0 2.3 (or put parentheses around the ar)4.8 F 2.3(guments.\) If)-.18 F F3 (FILEHANDLE)4.8 E F0(is)4.8 E .949 (omitted, prints to the last selected \(see `)128 512.4 R(`select')-.74 E .949('\) output handle.)-.74 F(If)5.949 E F3(LIST)3.449 E F0 .949 (is omitted, prints)3.449 F F1($_)3.449 E F0 .949(to the)3.449 F .22 (currently selected output handle.)128 524.4 R 1.82 -.8(To u)5.22 H(se) .8 E F3(FILEHANDLE)2.72 E F0 .219(alone to print the content of)2.72 F F1($_)2.719 E F0 .219(to it, you must)2.719 F 2.165 (use a real \214lehandle lik)128 536.4 R(e)-.1 E F1(FH)4.665 E F0 4.665 (,n)C 2.165(ot an indirect one lik)-4.665 F(e)-.1 E F1($fh)4.666 E F0 7.166(.T)C 4.666(os)-7.966 G 2.166(et the def)-4.666 F 2.166 (ault output handle to)-.1 F(something other than)128 548.4 Q F3(STDOUT) 2.5 E F0 2.5(,u)C(se the select operation.)-2.5 E .079(The current v)128 566.4 R .079(alue of)-.25 F F1($,)2.579 E F0 .079(\(if an)2.579 F .079 (y\) is printed between each)-.15 F F3(LIST)2.579 E F0 2.578(item. The) 2.578 F .078(current v)2.578 F .078(alue of)-.25 F F1($\\)2.578 E F0 .078(\(if an)2.578 F .078(y\) is)-.15 F 1.423(printed after the entire) 128 578.4 R F3(LIST)3.923 E F0 1.424(has been printed.)3.923 F 1.424 (Because print tak)6.424 F 1.424(es a)-.1 F F3(LIST)3.924 E F0 3.924(,a) C -.15(ny)-3.924 G 1.424(thing in the).15 F F3(LIST)3.924 E F0(is)3.924 E -.25(eva)128 590.4 S .486(luated in list conte).25 F .486 (xt, including an)-.15 F 2.985(ys)-.15 G .485 (ubroutines whose return lists you pass to)-2.985 F F1(print)2.985 E F0 5.485(.B)C 2.985(ec)-5.485 G(areful)-2.985 E 2.275(not to follo)128 602.4 R 4.775(wt)-.25 G 2.275(he print k)-4.775 F -.15(ey)-.1 G -.1(wo) .15 G 2.275(rd with a left parenthesis unless you w).1 F 2.276 (ant the corresponding right)-.1 F .293(parenthesis to terminate the ar) 128 614.4 R .292(guments to the print; put parentheses around all ar) -.18 F .292(guments \(or interpose)-.18 F(a)128 626.4 Q F1(+)2.5 E F0 2.5(,b)C(ut that doesn')-2.7 E 2.5(tl)-.18 G(ook as good\).)-2.5 E .191 (If you')128 644.4 R .191 (re storing handles in an array or hash, or in general whene)-.5 F -.15 (ve)-.25 G 2.691(ry).15 G(ou')-2.691 E .191(re using an)-.5 F 2.692(ye) -.15 G .192(xpression more)-2.842 F(comple)128 656.4 Q 2.532(xt)-.15 G .032(han a bare)-2.532 F -.1(wo)-.25 G .031 (rd handle or a plain, unsubscripted scalar v).1 F .031 (ariable to retrie)-.25 F .331 -.15(ve i)-.25 H .031(t, you will ha).15 F .331 -.15(ve t)-.2 H(o).15 E(use a block returning the \214lehandle v) 128 668.4 Q(alue instead, in which case the)-.25 E F3(LIST)2.5 E F0 (may not be omitted:)2.5 E F1(print { $files[$i] } "stuff\\n";)152 686.4 Q(print { $OK ? STDOUT : STDERR } "stuff\\n";)152 698.4 Q F0 1.437 (Printing to a closed pipe or sock)128 716.4 R 1.437(et will generate a) -.1 F F3(SIGPIPE)3.937 E F0 3.937(signal. See)3.937 F 1.437 (perlipc for more on signal)3.937 F(handling.)128 728.4 Q(perl v5.14.2) 72 768 Q 198.17(2011-10-01 57)162.62 F 0 Cg EP %%Page: 58 58 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(printf)108 84 Q/F1 9/Times-Roman@0 SF .25(FILEHANDLE FORMA)2.5 F(T)-.999 E F0(,)A F1(LIST) 2.5 E F0(printf)108 96 Q F1(FILEHANDLE)2.5 E F0(printf)108 108 Q F1 (FORMA)2.5 E(T)-.999 E F0(,)A F1(LIST)2.5 E F0(printf)108 120 Q(Equi)128 132 Q -.25(va)-.25 G 1.933(lent to).25 F/F2 10/Courier@0 SF 1.933 (print FILEHANDLE sprintf\(FORMAT, LIST\))4.433 F F0 4.433(,e)C 1.933 (xcept that)-4.583 F F2($\\)4.433 E F0 1.933(\(the output)4.433 F 1.085 (record separator\) is not appended.)128 144 R 1.085(The \214rst ar) 6.085 F 1.085(gument of the list will be interpreted as the)-.18 F F2 (printf)3.585 E F0 .471(format. See)128 156 R F2(sprintf)2.97 E F0 .47 (for an e)2.97 F .47(xplanation of the format ar)-.15 F 7.97(gument. If) -.18 F .47(you omit the)2.97 F F1(LIST)2.97 E F0(,)A F2($_)2.97 E F0 .47 (is used;)2.97 F .846(to use)128 168 R F1(FILEHANDLE)3.346 E F0 .846 (without a)3.346 F F1(LIST)3.347 E F0 3.347(,y)C .847 (ou must use a real \214lehandle lik)-3.347 F(e)-.1 E F2(FH)3.347 E F0 3.347(,n)C .847(ot an indirect one lik)-3.347 F(e)-.1 E F2($fh)128 180 Q F0 5.447(.I)C(f)-5.447 E F2 .447(use locale)2.947 F F0 .446(is in ef) 2.947 F .446(fect and)-.25 F/F3 10/Times-Italic@0 SF (POSIX::setlocale\(\))2.946 E F0 .446 (has been called, the character used for the)2.946 F .562 (decimal separator in formatted \215oating-point numbers is af)128 192 R .563(fected by the)-.25 F F1(LC_NUMERIC)3.063 E F0 .563(locale setting.) 3.063 F(See perllocale and)128 204 Q F1(POSIX)2.5 E F0(.)A(Don')128 222 Q 3.69(tf)-.18 G 1.19(all into the trap of using a)-3.79 F F2(printf) 3.69 E F0 1.189(when a simple)3.689 F F2(print)3.689 E F0 -.1(wo)3.689 G 1.189(uld do.).1 F(The)6.189 E F2(print)3.689 E F0 1.189(is more)3.689 F (ef)128 234 Q(\214cient and less error prone.)-.25 E(prototype)108 250.8 Q F1(FUNCTION)2.5 E F0 2.992 (Returns the prototype of a function as a string \(or)128 262.8 R F2 (undef)5.493 E F0 2.993(if the function has no prototype\).)5.493 F F1 (FUNCTION)128 274.8 Q F0 (is a reference to, or the name of, the function whose prototype you w) 2.5 E(ant to retrie)-.1 E -.15(ve)-.25 G(.).15 E(If)128 292.8 Q F1 (FUNCTION)3.418 E F0 .918(is a string starting with)3.418 F F2(CORE::) 3.417 E F0 3.417(,t)C .917(he rest is tak)-3.417 F .917 (en as a name for a Perl b)-.1 F 3.417(uiltin. If)-.2 F(the)3.417 E -.2 (bu)128 304.8 S 1.515(iltin is not).2 F F3 -.1(ov)4.015 G(erridable).1 E F0 1.515(\(such as)4.015 F F2(qw//)4.015 E F0 4.015(\)o)C 4.015(ri) -4.015 G 4.015(fi)-4.015 G 1.515(ts ar)-4.015 F 1.515 (guments cannot be adequately e)-.18 F 1.515(xpressed by a)-.15 F .993 (prototype \(such as)128 316.8 R F2(system)3.493 E F0(\),)A F3(pr)3.493 E(ototype\(\))-.45 E F0(returns)3.492 E F2(undef)3.492 E F0 3.492(,b)C .992(ecause the b)-3.492 F .992(uiltin does not really beha)-.2 F -.15 (ve)-.2 G(lik)128 328.8 Q 2.5(eaP)-.1 G(erl function.)-2.5 E (Otherwise, the string describing the equi)5 E -.25(va)-.25 G (lent prototype is returned.).25 E(push)108 345.6 Q F1(ARRA)2.5 E(Y) -.945 E F0(,LIST)A(push)108 357.6 Q F1(EXPR)2.5 E F0(,LIST)A -.35(Tr)128 369.6 S(eats).35 E F1(ARRA)2.59 E(Y)-.945 E F0 .09 (as a stack by appending the v)2.59 F .09(alues of)-.25 F F1(LIST)2.59 E F0 .09(to the end of)2.59 F F1(ARRA)2.591 E(Y)-.945 E F0 5.091(.T)C .091 (he length of)-5.091 F F1(ARRA)2.591 E(Y)-.945 E F0 (increases by the length of)128 381.6 Q F1(LIST)2.5 E F0 5(.H)C (as the same ef)-5 E(fect as)-.25 E F2(for $value \(LIST\) {)152 399.6 Q ($ARRAY[++$#ARRAY] = $value;)176 411.6 Q(})152 423.6 Q F0 -.2(bu)128 441.6 S 2.5(ti).2 G 2.5(sm)-2.5 G(ore ef)-2.5 E 2.5(\214cient. Returns) -.25 F(the number of elements in the array follo)2.5 E (wing the completed)-.25 E F2(push)2.5 E F0(.)A .958 (Starting with Perl 5.14,)128 459.6 R F2(push)3.458 E F0 .958(can tak) 3.458 F 3.458(ea)-.1 G(scalar)-.001 E F1(EXPR)3.457 E F0 3.457(,w)C .957 (hich must hold a reference to an unblessed)-3.457 F(array)128 471.6 Q 6.184(.T)-.65 G 1.184(he ar)-6.184 F 1.184 (gument will be dereferenced automatically)-.18 F 6.185(.T)-.65 G 1.185 (his aspect of)-6.185 F F2(push)3.685 E F0 1.185(is considered highly) 3.685 F -.15(ex)128 483.6 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(q/STRING/)108 500.4 Q(qq/STRING/)108 512.4 Q(qx/STRING/)108 524.4 Q(qw/STRING/)108 536.4 Q(Generalized quotes.)128 548.4 Q(See `)5 E (`Quote-Lik)-.74 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np) -2.5 G(erlop.)-2.5 E(qr/STRING/)108 565.2 Q(Re)128 577.2 Q(ge)-.15 E (xp-lik)-.15 E 2.5(eq)-.1 G 2.5(uote. See)-2.5 F -.74(``)2.5 G(Re).74 E (ge)-.15 E(xp Quote-Lik)-.15 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E(quotemeta)108 594 Q F1(EXPR)2.5 E F0 (quotemeta)108 606 Q .874(Returns the v)128 618 R .874(alue of)-.25 F F1 (EXPR)3.374 E F0 .873(with all non\255`)3.373 F(`w)-.74 E(ord')-.1 E 3.373('c)-.74 G .873(haracters backslashed.)-3.373 F .873 (\(That is, all characters not)5.873 F(matching)128 630 Q F2 (/[A\255Za\255z_0\2559]/)3.776 E F0 1.277 (will be preceded by a backslash in the returned string, re)3.777 F -.05 (ga)-.15 G 1.277(rdless of).05 F(an)128 642 Q 4.801(yl)-.15 G 2.301 (ocale settings.\))-4.801 F 2.301 (This is the internal function implementing the)7.301 F F2(\\Q)4.801 E F0 2.3(escape in double-quoted)4.8 F(strings.)128 654 Q(If)128 672 Q F1 (EXPR)2.5 E F0(is omitted, uses)2.5 E F2($_)2.5 E F0(.)A .875 (quotemeta \(and)128 690 R F2(\\Q)3.375 E F0(...)3.375 E F2(\\E)3.375 E F0 3.376(\)a)C .876(re useful when interpolating strings into re)-3.376 F .876(gular e)-.15 F .876(xpressions, because by)-.15 F(def)128 702 Q (ault an interpolated v)-.1 E(ariable will be considered a mini-re)-.25 E(gular e)-.15 E(xpression. F)-.15 E(or e)-.15 E(xample:)-.15 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 58)162.62 F 0 Cg EP %%Page: 59 59 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (my $sentence = \010The quick brown fox jumped over the lazy dog\010;) 152 84 Q(my $substring = \010quick.*?fox\010;)152 96 Q ($sentence =~ s{$substring}{big bad wolf};)152 108 Q F0 -.4(Wi)128 126 S (ll cause).4 E F1($sentence)2.5 E F0(to become)2.5 E F1 (\010The big bad wolf jumped over...\010)2.5 E F0(.)A (On the other hand:)128 144 Q F1 (my $sentence = \010The quick brown fox jumped over the lazy dog\010;) 152 162 Q(my $substring = \010quick.*?fox\010;)152 174 Q ($sentence =~ s{\\Q$substring\\E}{big bad wolf};)152 186 Q F0(Or:)128 204 Q F1 (my $sentence = \010The quick brown fox jumped over the lazy dog\010;) 152 222 Q(my $substring = \010quick.*?fox\010;)152 234 Q (my $quoted_substring = quotemeta\($substring\);)152 246 Q ($sentence =~ s{$quoted_substring}{big bad wolf};)152 258 Q F0 -.4(Wi) 128 276 S 2.48(ll both lea).4 F 2.78 -.15(ve t)-.2 H 2.48 (he sentence as is. Normally).15 F 4.979(,w)-.65 G 2.479 (hen accepting literal string input from the user)-4.979 F(,)-.4 E/F2 10 /Times-Italic@0 SF(quotemeta\(\))128 288 Q F0(or)2.5 E F1(\\Q)2.5 E F0 (must be used.)2.5 E .334 (In Perl 5.14, all characters whose code points are abo)128 306 R .634 -.15(ve 1)-.15 H .335(27 are not quoted in UTF8\255encoded strings,).15 F -.2(bu)128 318 S 3.222(ta).2 G .722(ll are quoted in)-3.222 F/F3 9 /Times-Roman@0 SF(UTF\2558)3.222 E F0 3.222(strings. It)3.222 F .722 (is planned to change this beha)3.222 F .721(vior in 5.16, b)-.2 F .721 (ut the e)-.2 F .721(xact rules)-.15 F(ha)128 330 Q -.15(ve)-.2 G(n').15 E 2.5(tb)-.18 G(een determined yet.)-2.5 E(rand)108 346.8 Q F3(EXPR)2.5 E F0(rand)108 358.8 Q .018 (Returns a random fractional number greater than or equal to)128 370.8 R F1(0)2.518 E F0 .018(and less than the v)2.518 F .018(alue of)-.25 F F3 (EXPR)2.518 E F0 5.018(.\()C F3(EXPR)-5.018 E F0 .434(should be positi) 128 382.8 R -.15(ve)-.25 G 2.934(.\) If).15 F F3(EXPR)2.934 E F0 .434 (is omitted, the v)2.934 F(alue)-.25 E F1(1)2.934 E F0 .434(is used.) 2.934 F(Currently)5.434 E F3(EXPR)2.934 E F0 .434(with the v)2.934 F (alue)-.25 E F1(0)2.933 E F0 .433(is also)2.933 F .013(special-cased as) 128 394.8 R F1(1)2.513 E F0 .013(\(this w)2.513 F .014 (as undocumented before Perl 5.8.0 and is subject to change in future v) -.1 F(ersions)-.15 E(of Perl\).)128 406.8 Q(Automatically calls)5 E F1 (srand)2.5 E F0(unless)2.5 E F1(srand)2.5 E F0(has already been called.) 2.5 E(See also)5 E F1(srand)2.5 E F0(.)A(Apply)128 424.8 Q F1(int\(\)) 4.437 E F0 1.937(to the v)4.437 F 1.937(alue returned by)-.25 F F1 (rand\(\))4.437 E F0 1.937(if you w)4.437 F 1.936(ant random inte)-.1 F 1.936(gers instead of random)-.15 F(fractional numbers.)128 436.8 Q -.15 (Fo)5 G 2.5(re).15 G(xample,)-2.65 E F1(int\(rand\(10\)\))152 454.8 Q F0 (returns a random inte)128 472.8 Q(ger between)-.15 E F1(0)2.5 E F0(and) 2.5 E F1(9)2.5 E F0 2.5(,i)C(nclusi)-2.5 E -.15(ve)-.25 G(.).15 E 1.234 (\(Note: If your rand function consistently returns numbers that are to\ o lar)128 490.8 R 1.234(ge or too small, then your)-.18 F -.15(ve)128 502.8 S(rsion of Perl w).15 E (as probably compiled with the wrong number of)-.1 E F3(RANDBITS)2.5 E F0(.\))A/F4 10/Courier-Bold@0 SF(rand\(\))128 520.8 Q/F5 10/Times-Bold@0 SF 3.649(is not cryptographically secur)6.149 F 6.148(e. Y)-.18 F 3.648 (ou should not r)-1.11 F 3.648(ely on it in security-sensiti)-.18 F -.1 (ve)-.1 G(situations.)128 532.8 Q F0 .037 (As of this writing, a number of third-party)5.036 F F3(CP)2.537 E(AN) -.828 E F0 .037(modules of)2.537 F .037(fer random number generators) -.25 F 5.011(intended by their authors to be cryptographically secure, \ including: Math::Random::Secure,)128 544.8 R(Math::Random::MT)128 556.8 Q(::Perl, and Math::T)-.5 E(rulyRandom.)-.35 E(read)108 573.6 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH,OFFSET)A(read)108 585.6 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH)A .443(Attempts to read)128 597.6 R F3(LENGTH)2.943 E F2 -.15(ch)2.943 G(ar).15 E(acter)-.15 E(s)-.1 E F0 .443(of data into v)2.943 F(ariable)-.25 E F3(SCALAR)2.944 E F0 .444 (from the speci\214ed)2.944 F F3(FILEHANDLE)2.944 E F0(.)A .589 (Returns the number of characters actually read,)128 609.6 R F1(0)3.089 E F0 .588(at end of \214le, or undef if there w)3.089 F .588 (as an error \(in the)-.1 F .472(latter case)128 621.6 R F1($!)2.972 E F0 .473(is also set\).)2.973 F F3(SCALAR)5.473 E F0 .473(will be gro) 2.973 F .473(wn or shrunk so that the last character actually read is) -.25 F(the last character of the scalar after the read.)128 633.6 Q(An) 128 651.6 Q F3(OFFSET)4.883 E F0 2.383(may be speci\214ed to place the \ read data at some place in the string other than the)4.883 F(be)128 663.6 Q 3.056(ginning. A)-.15 F(ne)3.056 E -.05(ga)-.15 G(ti).05 E -.15 (ve)-.25 G F3(OFFSET)3.207 E F0 .557(speci\214es placement at that man) 3.057 F 3.057(yc)-.15 G .557(haracters counting backw)-3.057 F .557 (ards from)-.1 F .215(the end of the string.)128 675.6 R 2.715(Ap)5.215 G(ositi)-2.715 E -.15(ve)-.25 G F3(OFFSET)2.865 E F0 .215 (greater than the length of)2.715 F F3(SCALAR)2.715 E F0 .214 (results in the string being)2.715 F(padded to the required size with) 128 687.6 Q F1("\\0")2.5 E F0 (bytes before the result of the read is appended.)2.5 E .295 (The call is implemented in terms of either Perl')128 705.6 R 2.795(so) -.55 G 2.795(ry)-2.795 G .295(our system')-2.795 F 2.795(sn)-.55 G(ati) -2.795 E -.15(ve)-.25 G F2(fr)2.946 E(ead)-.37 E F0 .296 (\(3\) library function.)1.666 F -.8(To)5.296 G(get a true)128 717.6 Q F2 -.37(re)2.5 G(ad).37 E F0(\(2\) system call, see)1.666 E F1(sysread) 2.5 E F0(.)A(perl v5.14.2)72 768 Q 198.17(2011-10-01 59)162.62 F 0 Cg EP %%Page: 60 60 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.049(Note the)128 84 R/F1 10/Times-Italic@0 SF -.15(ch)3.549 G(ar).15 E(acter)-.15 E(s)-.1 E F0 3.549(:d)C 1.049(epending on the status of the \214lehandle, eithe\ r \(8\255bit\) bytes or characters are)-3.549 F 3.421(read. By)128 96 R (def)3.421 E .922(ault, all \214lehandles operate on bytes, b)-.1 F .922 (ut for e)-.2 F .922(xample if the \214lehandle has been opened)-.15 F 2.49(with the)128 108 R/F2 10/Courier@0 SF(:utf8)4.99 E F0 2.49 (I/O layer \(see `)4.99 F(`open')-.74 E 2.49(', and the)-.74 F F2(open) 4.99 E F0 2.49(pragma, open\), the I/O will operate on)4.99 F 1.29 (UTF8\255encoded Unicode characters, not bytes.)128 120 R 1.29 (Similarly for the)6.29 F F2(:encoding)3.79 E F0 1.29 (pragma: in that case)3.79 F(pretty much an)128 132 Q 2.5(yc)-.15 G (haracters can be read.)-2.5 E(readdir)108 148.8 Q/F3 9/Times-Roman@0 SF (DIRHANDLE)2.5 E F0 .77(Returns the ne)128 160.8 R .77 (xt directory entry for a directory opened by)-.15 F F2(opendir)3.269 E F0 5.769(.I)C 3.269(fu)-5.769 G .769(sed in list conte)-3.269 F .769 (xt, returns)-.15 F .683(all the rest of the entries in the directory) 128 172.8 R 5.684(.I)-.65 G 3.184(ft)-5.684 G .684 (here are no more entries, returns the unde\214ned v)-3.184 F .684 (alue in)-.25 F(scalar conte)128 184.8 Q (xt and the empty list in list conte)-.15 E(xt.)-.15 E .143(If you')128 202.8 R .143(re planning to \214letest the return v)-.5 F .143 (alues out of a)-.25 F F2(readdir)2.643 E F0 2.643(,y)C(ou')-2.643 E 2.643(db)-.5 G .143(etter prepend the directory in)-2.643 F 2.5 (question. Otherwise,)128 214.8 R(because we didn')2.5 E(t)-.18 E F2 (chdir)2.5 E F0(there, it w)2.5 E(ould ha)-.1 E .3 -.15(ve b)-.2 H (een testing the wrong \214le.).15 E F2 (opendir\(my $dh, $some_dir\) || die "can\010t opendir $some_dir: $!";) 152 232.8 Q (@dots = grep { /^\\./ && \255f "$some_dir/$_" } readdir\($dh\);)152 244.8 Q(closedir $dh;)152 256.8 Q F0 (As of Perl 5.11.2 you can use a bare)128 274.8 Q F2(readdir)2.5 E F0 (in a)2.5 E F2(while)2.5 E F0(loop, which will set)2.5 E F2($_)2.5 E F0 (on e)2.5 E -.15(ve)-.25 G(ry iteration.).15 E F2 (opendir\(my $dh, $some_dir\) || die;)152 292.8 Q (while\(readdir $dh\) {)152 304.8 Q(print "$some_dir/$_\\n";)176 316.8 Q (})152 328.8 Q(closedir $dh;)152 340.8 Q F0(readline)108 357.6 Q F3 (EXPR)2.5 E F0(readline)108 369.6 Q 1.879 (Reads from the \214lehandle whose type)128 381.6 R 1.879 (glob is contained in)-.15 F F3(EXPR)4.379 E F0 1.879(\(or from)4.379 F F2(*ARGV)4.379 E F0(if)4.379 E F3(EXPR)4.379 E F0 1.879(is not)4.379 F (pro)128 393.6 Q 4.244(vided\). In)-.15 F 1.744(scalar conte)4.244 F 1.744(xt, each call reads and returns the ne)-.15 F 1.744 (xt line until end-of-\214le is reached,)-.15 F .892 (whereupon the subsequent call returns)128 405.6 R F2(undef)3.393 E F0 5.893(.I)C 3.393(nl)-5.893 G .893(ist conte)-3.393 F .893 (xt, reads until end-of-\214le is reached and)-.15 F .212 (returns a list of lines.)128 417.6 R .212(Note that the notion of `) 5.212 F(`line')-.74 E 2.712('u)-.74 G .211(sed here is whate)-2.712 F -.15(ve)-.25 G 2.711(ry).15 G .211(ou may ha)-2.711 F .511 -.15(ve d)-.2 H .211(e\214ned with).15 F F2($/)128 429.6 Q F0(or)2.5 E F2 ($INPUT_RECORD_SEPARATOR)2.5 E F0 2.5(\). See)B -.74(``)2.5 G($/').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E(When)128 447.6 Q F2($/)3.162 E F0 .662(is set to)3.162 F F2(undef)3.162 E F0 3.162(,w)C(hen)-3.162 E F2(readline)3.162 E F0 .662(is in scalar conte) 3.162 F .663(xt \(i.e., \214le slurp mode\), and when an)-.15 F (empty \214le is read, it returns)128 459.6 Q F2<0808>2.5 E F0 (the \214rst time, follo)2.5 E(wed by)-.25 E F2(undef)2.5 E F0 (subsequently)2.5 E(.)-.65 E 1.597 (This is the internal function implementing the)128 477.6 R F2() 4.097 E F0(operator)4.097 E 4.097(,b)-.4 G 1.596 (ut you can use it directly)-4.297 F 6.596(.T)-.65 G(he)-6.596 E F2 ()128 489.6 Q F0(operator is discussed in more detail in `)2.5 E (`I/O Operators')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E F2 ($line = ;)152 507.6 Q($line = readline\(*STDIN\);)152 519.6 Q 6 (#s)24 G(ame thing)-6 E F0(If)128 537.6 Q F2(readline)4.482 E F0 1.982 (encounters an operating system error)4.482 F(,)-.4 E F2($!)4.482 E F0 1.982(will be set with the corresponding error)4.482 F 2.654 (message. It)128 549.6 R .154(can be helpful to check)2.654 F F2($!) 2.653 E F0 .153(when you are reading from \214lehandles you don')2.653 F 2.653(tt)-.18 G .153(rust, such as)-2.653 F 2.608(at)128 561.6 S .108 (ty or a sock)-2.608 F 2.608(et. The)-.1 F(follo)2.608 E .108(wing e) -.25 F .108(xample uses the operator form of)-.15 F F2(readline)2.609 E F0 .109(and dies if the result is)2.609 F(not de\214ned.)128 573.6 Q F2 (while \( ! eof\($fh\) \) {)152 591.6 Q (defined\( $_ = <$fh> \) or die "readline failed: $!";)176 603.6 Q(...) 176 615.6 Q(})152 627.6 Q F0 .982(Note that you ha)128 645.6 R 1.282 -.15(ve c)-.2 H(an').15 E 3.481(th)-.18 G(andle)-3.481 E F2(readline) 3.481 E F0 .981(errors that w)3.481 F .981(ay with the)-.1 F F2(ARGV) 3.481 E F0 .981(\214lehandle. In that case,)3.481 F(you ha)128 657.6 Q .3 -.15(ve t)-.2 H 2.5(oo).15 G(pen each element of)-2.5 E F2(@ARGV)2.5 E F0(yourself since)2.5 E F2(eof)2.5 E F0(handles)2.5 E F2(ARGV)2.5 E F0 (dif)2.5 E(ferently)-.25 E(.)-.65 E F2(foreach my $arg \(@ARGV\) {)152 675.6 Q(open\(my $fh, $arg\) or warn "Can\010t open $arg: $!";)176 687.6 Q(while \( ! eof\($fh\) \) {)176 711.6 Q(defined\( $_ = <$fh> \))200 723.6 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 60)162.62 F 0 Cg EP %%Page: 61 61 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (or die "readline failed for $arg: $!";)224 84 Q(...)200 96 Q(})176 108 Q(})152 120 Q F0(readlink)108 136.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0(readlink)108 148.8 Q .062(Returns the v)128 160.8 R .062 (alue of a symbolic link, if symbolic links are implemented.)-.25 F .063 (If not, raises an e)5.063 F 2.563(xception. If)-.15 F (there is a system error)128 172.8 Q 2.5(,r)-.4 G (eturns the unde\214ned v)-2.5 E(alue and sets)-.25 E F1($!)2.5 E F0 2.5 (\(errno\). If)2.5 F F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A(readpipe)108 189.6 Q F2(EXPR)2.5 E F0(readpipe)108 201.6 Q F2 (EXPR)128 213.6 Q F0 .735(is e)3.236 F -.15(xe)-.15 G .735 (cuted as a system command.).15 F .735 (The collected standard output of the command is returned.)5.735 F .35 (In scalar conte)128 225.6 R .35 (xt, it comes back as a single \(potentially multi-line\) string.)-.15 F .35(In list conte)5.35 F .35(xt, returns a list)-.15 F 1.76 (of lines \(ho)128 237.6 R(we)-.25 E -.15(ve)-.25 G 4.259(ry).15 G(ou') -4.259 E 2.059 -.15(ve d)-.5 H 1.759(e\214ned lines with).15 F F1($/) 4.259 E F0(or)4.259 E F1($INPUT_RECORD_SEPARATOR)4.259 E F0 4.259 (\). This)B 1.759(is the)4.259 F .432 (internal function implementing the)128 249.6 R F1(qx/EXPR/)2.932 E F0 (operator)2.932 E 2.932(,b)-.4 G .432(ut you can use it directly)-3.132 F 5.433(.T)-.65 G(he)-5.433 E F1(qx/EXPR/)2.933 E F0 (operator is discussed in more detail in `)128 261.6 Q(`I/O Operators') -.74 E 2.5('i)-.74 G 2.5(np)-2.5 G 2.5(erlop. If)-2.5 F F2(EXPR)2.5 E F0 (is omitted, uses)2.5 E F1($_)2.5 E F0(.)A(recv)108 278.4 Q F2(SOCKET) 2.5 E F0(,SCALAR,LENGTH,FLA)A(GS)-.4 E(Recei)128 290.4 Q -.15(ve)-.25 G 5.082(sam).15 G 2.582(essage on a sock)-5.082 F 5.081(et. Attempts)-.1 F 2.581(to recei)5.081 F -.15(ve)-.25 G F2(LENGTH)5.231 E F0 2.581 (characters of data into v)5.081 F(ariable)-.25 E F2(SCALAR)128 302.4 Q F0 2.035(from the speci\214ed)4.534 F F2(SOCKET)4.535 E F0 (\214lehandle.)4.535 E F2(SCALAR)7.035 E F0 2.035(will be gro)4.535 F 2.035(wn or shrunk to the length)-.25 F .783(actually read.)128 314.4 R -.8(Ta)5.783 G -.1(ke).8 G 3.283(st).1 G .783 (he same \215ags as the system call of the same name.)-3.283 F .782 (Returns the address of the)5.783 F 1.822(sender if)128 326.4 R F2 (SOCKET)4.322 E F0 2.922 -.55('s p)D 1.822 (rotocol supports this; returns an empty string otherwise.).55 F 1.822 (If there')6.822 F 4.322(sa)-.55 G 4.323(ne)-4.322 G(rror)-4.323 E(,)-.4 E 1.196(returns the unde\214ned v)128 338.4 R 3.696(alue. This)-.25 F 1.195(call is actually implemented in terms of)3.695 F/F3 10 /Times-Italic@0 SF -.37(re)3.695 G(cvfr).37 E(om)-.45 E F0 1.195 (\(2\) system call.)1.666 F(See `)128 350.4 Q(`)-.74 E F2(UDP:)A F0 (Message P)2.5 E(assing')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlipc for e)-2.5 E(xamples.)-.15 E 1.981(Note the)128 368.4 R F3 -.15 (ch)4.481 G(ar).15 E(acter)-.15 E(s)-.1 E F0 4.481(:d)C 1.981 (epending on the status of the sock)-4.481 F 1.982 (et, either \(8\255bit\) bytes or characters are)-.1 F(recei)128 380.4 Q -.15(ve)-.25 G 2.522(d. By).15 F(def)2.522 E .022(ault all sock)-.1 F .021(ets operate on bytes, b)-.1 F .021(ut for e)-.2 F .021 (xample if the sock)-.15 F .021(et has been changed using)-.1 F F3 (binmode\(\))128 392.4 Q F0 .695(to operate with the)3.195 F F1 (:encoding\(utf8\))3.196 E F0 .696(I/O layer \(see the)3.196 F F1(open) 3.196 E F0 .696(pragma, open\), the I/O)3.196 F .04 (will operate on UTF8\255encoded Unicode characters, not bytes.)128 404.4 R .04(Similarly for the)5.04 F F1(:encoding)2.54 E F0(pragma:)2.54 E(in that case pretty much an)128 416.4 Q 2.5(yc)-.15 G (haracters can be read.)-2.5 E(redo)108 433.2 Q F2(LABEL)2.5 E F0(redo) 108 445.2 Q(The)128 457.2 Q F1(redo)2.523 E F0 .024 (command restarts the loop block without e)2.523 F -.25(va)-.25 G .024 (luating the conditional ag).25 F 2.524(ain. The)-.05 F F1(continue) 2.524 E F0 .146(block, if an)128 469.2 R 1.446 -.65(y, i)-.15 H 2.646 (sn).65 G .146(ot e)-2.646 F -.15(xe)-.15 G 2.646(cuted. If).15 F(the) 2.646 E F2(LABEL)2.646 E F0 .146 (is omitted, the command refers to the innermost enclosing)2.646 F 2.5 (loop. Programs)128 481.2 R(that w)2.5 E(ant to lie to themselv)-.1 E (es about what w)-.15 E(as just input normally use this command:)-.1 E F1 6(#as)152 499.2 S(impleminded Pascal comment stripper)-6 E 6(#\()152 511.2 S(warning: assumes no { or } in strings\))-6 E (LINE: while \(\) {)152 523.2 Q (while \(s|\({.*}.*\){.*}|$1 |\) {})176 535.2 Q(s|{.*}| |;)176 547.2 Q (if \(s|{.*| |\) {)176 559.2 Q($front = $_;)200 571.2 Q (while \(\) {)200 583.2 Q(if \(/}/\) {)224 595.2 Q 6(#e)12 G (nd of comment?)-6 E(s|^|$front\\{|;)248 607.2 Q(redo LINE;)248 619.2 Q (})224 631.2 Q(})200 643.2 Q(})176 655.2 Q(print;)176 667.2 Q(})152 679.2 Q(redo)128 697.2 Q F0 .081 (cannot be used to retry a block that returns a v)2.58 F .081 (alue such as)-.25 F F1 .081(eval {})2.581 F F0(,)A F1 .081(sub {})2.581 F F0 2.581(,o)C(r)-2.581 E F1 .081(do {})2.581 F F0 2.581(,a)C(nd)-2.581 E(should not be used to e)128 709.2 Q(xit a)-.15 E F3(gr)2.5 E(ep\(\)) -.37 E F0(or)2.5 E F3(map\(\))2.5 E F0(operation.)2.5 E .932 (Note that a block by itself is semantically identical to a loop that e) 128 727.2 R -.15(xe)-.15 G .931(cutes once.).15 F(Thus)5.931 E F1(redo) 3.431 E F0(inside)3.431 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 61) 162.62 F 0 Cg EP %%Page: 62 62 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (such a block will ef)128 84 Q(fecti)-.25 E -.15(ve)-.25 G (ly turn it into a looping construct.).15 E(See also `)128 102 Q (`continue')-.74 E 2.5('f)-.74 G(or an illustration of ho)-2.5 E(w)-.25 E/F1 10/Courier@0 SF(last)2.5 E F0(,)A F1(next)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(redo)2.5 E F0 -.1(wo)2.5 G(rk.).1 E(ref)108 118.8 Q/F2 9 /Times-Roman@0 SF(EXPR)2.5 E F0(ref)108 130.8 Q 2.495 (Returns a non-empty string if)128 130.8 R F2(EXPR)4.996 E F0 2.496 (is a reference, the empty string otherwise. If)4.996 F F2(EXPR)4.996 E F0 2.496(is not)4.996 F(speci\214ed,)128 142.8 Q F1($_)4.808 E F0 2.307 (will be used.)4.807 F 2.307(The v)7.307 F 2.307 (alue returned depends on the type of thing the reference is a)-.25 F (reference to.)128 154.8 Q(Builtin types include:)5 E F1(SCALAR)152 172.8 Q(ARRAY)152 184.8 Q(HASH)152 196.8 Q(CODE)152 208.8 Q(REF)152 220.8 Q(GLOB)152 232.8 Q(LVALUE)152 244.8 Q(FORMAT)152 256.8 Q(IO)152 268.8 Q(VSTRING)152 280.8 Q(Regexp)152 292.8 Q F0 .757(If the reference\ d object has been blessed into a package, then that package name is ret\ urned instead.)128 310.8 R -1.1(Yo)128 322.8 S 2.5(uc)1.1 G(an think of) -2.5 E F1(ref)2.5 E F0(as a)2.5 E F1(typeof)2.5 E F0(operator)2.5 E(.) -.55 E F1(if \(ref\($r\) eq "HASH"\) {)152 340.8 Q (print "r is a reference to a hash.\\n";)176 352.8 Q(})152 364.8 Q (unless \(ref\($r\)\) {)152 376.8 Q (print "r is not a reference at all.\\n";)176 388.8 Q(})152 400.8 Q F0 .889(The return v)128 418.8 R(alue)-.25 E F1(LVALUE)3.389 E F0 .888 (indicates a reference to an lv)3.389 F .888(alue that is not a v)-.25 F .888(ariable. Y)-.25 F .888(ou get this from)-1.1 F 2.753 (taking the reference of function calls lik)128 430.8 R(e)-.1 E F1 (pos\(\))5.254 E F0(or)5.254 E F1(substr\(\))5.254 E F0(.)A F1(VSTRING) 5.254 E F0 2.754(is returned if the)5.254 F(reference points to a v)128 442.8 Q(ersion string.)-.15 E(The result)128 460.8 Q F1(Regexp)2.5 E F0 (indicates that the ar)2.5 E(gument is a re)-.18 E(gular e)-.15 E (xpression resulting from)-.15 E F1(qr//)2.5 E F0(.)A(See also perlref.) 128 478.8 Q(rename)108 495.6 Q F2(OLDN)2.5 E(AME)-.315 E F0(,NEWN)A(AME) -.35 E .919(Changes the name of a \214le; an e)128 507.6 R .919 (xisting \214le)-.15 F F2(NEWN)3.418 E(AME)-.315 E F0 .918 (will be clobbered.)3.418 F .918(Returns true for success,)5.918 F -.1 (fa)128 519.6 S(lse otherwise.).1 E(Beha)128 537.6 Q 1.281 (vior of this function v)-.2 F 1.282 (aries wildly depending on your system implementation.)-.25 F -.15(Fo) 6.282 G 3.782(re).15 G 1.282(xample, it)-3.932 F .518 (will usually not w)128 549.6 R .518 (ork across \214le system boundaries, e)-.1 F -.15(ve)-.25 G 3.018(nt) .15 G .518(hough the system)-3.018 F/F3 10/Times-Italic@0 SF(mv)3.018 E F0 .517(command sometimes)3.017 F 1.305(compensates for this.)128 561.6 R 1.306(Other restrictions include whether it w)6.305 F 1.306 (orks on directories, open \214les, or pre-)-.1 F -.15(ex)128 573.6 S .535(isting \214les.).15 F .535(Check perlport and either the)5.535 F F3 -.37(re)3.034 G(name).37 E F0 .534(\(2\) manpage or equi)1.666 F -.25 (va)-.25 G .534(lent system documentation).25 F(for details.)128 585.6 Q -.15(Fo)128 603.6 S 2.5(rap).15 G(latform independent)-2.5 E F1(move)2.5 E F0(function look at the File::Cop)2.5 E 2.5(ym)-.1 G(odule.)-2.5 E (require)108 620.4 Q F2(VERSION)2.5 E F0(require)108 632.4 Q F2(EXPR)2.5 E F0(require)108 644.4 Q .679(Demands a v)128 656.4 R .68 (ersion of Perl speci\214ed by)-.15 F F2(VERSION)3.18 E F0 3.18(,o)C 3.18(rd)-3.18 G .68(emands some semantics speci\214ed by)-3.18 F F2 (EXPR)3.18 E F0(or)3.18 E(by)128 668.4 Q F1($_)2.5 E F0(if)2.5 E F2 (EXPR)2.5 E F0(is not supplied.)2.5 E F2(VERSION)128 686.4 Q F0 .27 (may be either a numeric ar)2.771 F .27 (gument such as 5.006, which will be compared to)-.18 F F1($])2.77 E F0 2.77(,o)C 2.77(ral)-2.77 G(iteral)-2.77 E .488 (of the form v5.6.1, which will be compared to)128 698.4 R F1($^V)2.988 E F0(\(aka)2.988 E F1($PERL_VERSION)2.988 E F0 2.988(\). An)B -.15(ex) 2.988 G .488(ception is raised).15 F(if)128 710.4 Q F2(VERSION)2.639 E F0 .139(is greater than the v)2.639 F .139 (ersion of the current Perl interpreter)-.15 F 5.139(.C)-.55 G .139 (ompare with `)-5.139 F(`use')-.74 E .139(', which can)-.74 F (do a similar check at compile time.)128 722.4 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 62)162.62 F 0 Cg EP %%Page: 63 63 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(Specifying)128 84 Q/F1 9/Times-Roman@0 SF(VERSION)3.497 E F0 .998 (as a literal of the form v5.6.1 should generally be a)3.497 F -.2(vo) -.2 G .998(ided, because it leads to).2 F 2.935 (misleading error messages under earlier v)128 96 R 2.935 (ersions of Perl that do not support this syntax.)-.15 F(The)7.935 E (equi)128 108 Q -.25(va)-.25 G(lent numeric v).25 E (ersion should be used instead.)-.15 E/F2 10/Courier@0 SF (require v5.6.1;)152 126 Q 6(#r)30 G(un time version check)-6 E (require 5.6.1;)152 138 Q 6(#d)36 G(itto)-6 E(require 5.006_001;)152 150 Q 6(#d)12 G(itto; preferred for backwards compatibility)-6 E F0 (Otherwise,)128 168 Q F2(require)3.257 E F0 .757 (demands that a library \214le be included if it hasn')3.257 F 3.258(ta) -.18 G .758(lready been included.)-3.258 F(The)5.758 E .084(\214le is i\ ncluded via the do-FILE mechanism, which is essentially just a v)128 180 R .083(ariety of)-.25 F F2(eval)2.583 E F0 .083(with the ca)2.583 F -.15 (ve)-.2 G(at).15 E 1.84(that le)128 192 R 1.84(xical v)-.15 F 1.84 (ariables in the in)-.25 F -.2(vo)-.4 G 1.84(king script will be in).2 F 1.84(visible to the included code.)-.4 F 1.84(Has semantics)6.84 F (similar to the follo)128 204 Q(wing subroutine:)-.25 E F2 (sub require {)152 222 Q(my \($filename\) = @_;)170 234 Q (if \(exists $INC{$filename}\) {)170 246 Q(return 1 if $INC{$filename};) 194 258 Q(die "Compilation failed in require";)194 270 Q(})170 282 Q (my \($realfilename,$result\);)170 294 Q(ITER: {)170 306 Q (foreach $prefix \(@INC\) {)194 318 Q ($realfilename = "$prefix/$filename";)218 330 Q (if \(\255f $realfilename\) {)218 342 Q ($INC{$filename} = $realfilename;)242 354 Q($result = do $realfilename;) 242 366 Q(last ITER;)242 378 Q(})218 390 Q(})194 402 Q (die "Can\010t find $filename in \\@INC";)194 414 Q(})170 426 Q (if \($@\) {)170 438 Q($INC{$filename} = undef;)194 450 Q(die $@;)194 462 Q 6(}e)170 474 S(lsif \(!$result\) {)-6 E(delete $INC{$filename};) 194 486 Q(die "$filename did not return true value";)194 498 Q 6(}e)170 510 S(lse {)-6 E(return $result;)194 522 Q(})170 534 Q(})152 546 Q F0(N\ ote that the \214le will not be included twice under the same speci\214\ ed name.)128 564 Q 1.481(The \214le must return true as the last statem\ ent to indicate successful e)128 582 R -.15(xe)-.15 G 1.481 (cution of an).15 F 3.981(yi)-.15 G(nitialization)-3.981 E .062 (code, so it')128 594 R 2.562(sc)-.55 G .062 (ustomary to end such a \214le with)-2.562 F F2(1;)2.563 E F0 .063 (unless you')2.563 F .063(re sure it')-.5 F .063 (ll return true otherwise.)-.1 F .063(But it')5.063 F(s)-.55 E (better just to put the)128 606 Q F2(1;)2.5 E F0 2.5(,i)C 2.5(nc)-2.5 G (ase you add more statements.)-2.5 E(If)128 624 Q F1(EXPR)4.344 E F0 1.844(is a bare)4.344 F -.1(wo)-.25 G 1.844(rd, the require assumes a ") .1 F/F3 10/Times-Italic@0 SF(.pm)A F0 3.324 -.74(`` e)D 1.844 (xtension and replaces ').59 F(')-.74 E F3(::)A F0 3.324 -.74(`` w)D 1.844(ith ').74 F(')-.74 E F3(/)A F0 4.343("i)C 4.343(nt)-4.343 G(he) -4.343 E .226(\214lename for you, to mak)128 636 R 2.726(ei)-.1 G 2.726 (te)-2.726 G .227(asy to load standard modules.)-2.726 F .227 (This form of loading of modules does not)5.227 F (risk altering your namespace.)128 648 Q(In other w)128 666 Q (ords, if you try this:)-.1 E F2(require Foo::Bar;)176 684 Q 6(#as)30 G (plendid bareword)-6 E F0 1.552 (The require function will actually look for the ")128 702 R F3 -1.05 (Fo)C(o/Bar)1.05 E(.pm)-1.11 E F0 4.051<228c>C 1.551 (le in the directories speci\214ed in the)-4.051 F F2(@INC)128 714 Q F0 (array)2.5 E(.)-.65 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 63)162.62 F 0 Cg EP %%Page: 64 64 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (But if you try this:)128 84 Q/F1 10/Courier@0 SF ($class = \010Foo::Bar\010;)176 102 Q(require $class;)176 114 Q 6(#$)42 G(class is not a bareword)-6 E(#or)152 126 Q(require "Foo::Bar";)176 138 Q 6(#n)18 G(ot a bareword because of the "")-6 E F0 .519 (The require function will look for the ")128 156 R/F2 10/Times-Italic@0 SF -1.05(Fo)C(o::Bar)1.05 E F0 1.999 -.74(`` \214)D .519(le in the).74 F F1(@INC)3.019 E F0 .519(array and will complain about not)3.019 F (\214nding ')128 168 Q(')-.74 E F2 -1.05(Fo)C(o::Bar)1.05 E F0 2.5("t)C 2.5(here. In)-2.5 F(this case you can do:)2.5 E F1 (eval "require $class";)176 186 Q F0(No)128 204 Q 3.8(wt)-.25 G 1.3 (hat you understand ho)-3.8 F(w)-.25 E F1(require)3.8 E F0 1.3 (looks for \214les with a bare)3.8 F -.1(wo)-.25 G 1.3(rd ar).1 F 1.3 (gument, there is a little)-.18 F -.15(ex)128 216 S .448 (tra functionality going on behind the scenes.).15 F(Before)5.449 E F1 (require)2.949 E F0 .449(looks for a ")2.949 F F2(.pm)A F0 1.929 -.74 (`` e)D .449(xtension, it will).59 F .198 (\214rst look for a similar \214lename with a ')128 228 R(')-.74 E F2 (.pmc)A F0 1.678 -.74(`` e)D .197 (xtension. If this \214le is found, it will be loaded in place).59 F (of an)128 240 Q 2.5<798c>-.15 G(le ending in a ')-2.5 E(')-.74 E F2 (.pm)A F0 2.5("e)C(xtension.)-2.65 E -1.1(Yo)128 258 S 3.473(uc)1.1 G .973(an also insert hooks into the import f)-3.473 F .974 (acility by putting Perl code directly into the)-.1 F F1(@INC)3.474 E F0 (array)3.474 E(.)-.65 E(There are three forms of hooks: subroutine refe\ rences, array references, and blessed objects.)128 270 Q 1.633 (Subroutine references are the simplest case.)128 288 R 1.632 (When the inclusion system w)6.632 F 1.632(alks through)-.1 F F1(@INC) 4.132 E F0(and)4.132 E .441 (encounters a subroutine, this subroutine gets called with tw)128 300 R 2.941(op)-.1 G .442(arameters, the \214rst a reference to itself,)-2.941 F .448(and the second the name of the \214le to be included \(e.g., ") 128 312 R F2 -1.05(Fo)C(o/Bar)1.05 E(.pm)-1.11 E F0 2.948("\). The)B .448(subroutine should return)2.948 F (either nothing or else a list of up to three v)128 324 Q (alues in the follo)-.25 E(wing order:)-.25 E(1.)128 340.8 Q 2.5<418c> 148 340.8 S(lehandle, from which the \214le will be read.)-2.5 E(2.)128 357.6 Q 4.413(Ar)148 357.6 S 1.913 (eference to a subroutine. If there is no \214lehandle \(pre)-4.413 F 1.914(vious item\), then this subroutine is)-.25 F -.15(ex)148 369.6 S 1.043(pected to generate one line of source code per call, writing the \ line into).15 F F1($_)3.543 E F0 1.043(and returning 1,)3.543 F .224 (then \214nally at end of \214le returning 0.)148 381.6 R .225 (If there is a \214lehandle, then the subroutine will be called to)5.225 F .169(act as a simple source \214lter)148 393.6 R 2.669(,w)-.4 G .169 (ith the line as read in)-2.669 F F1($_)2.669 E F0 5.169(.A)C -.05(ga) -5.169 G .169(in, return 1 for each v).05 F .169(alid line, and 0)-.25 F (after all lines ha)148 405.6 Q .3 -.15(ve b)-.2 H(een returned.).15 E (3.)128 422.4 Q .476 (Optional state for the subroutine. The state is passed in as)148 422.4 R F1($_[1])2.976 E F0 -5.475 2.976(.A r)D .477 (eference to the subroutine)-2.976 F(itself is passed in as)148 434.4 Q F1($_[0])2.5 E F0(.)A .656(If an empty list,)128 452.4 R F1(undef)3.156 E F0 3.156(,o)C 3.155(rn)-3.156 G .655 (othing that matches the \214rst 3 v)-3.155 F .655(alues abo)-.25 F .955 -.15(ve i)-.15 H 3.155(sr).15 G .655(eturned, then)-3.155 F F1(require) 3.155 E F0 .195(looks at the remaining elements of)128 464.4 R F1(@INC) 2.695 E F0 5.195(.N)C .195 (ote that this \214lehandle must be a real \214lehandle \(strictly a) -5.195 F(type)128 476.4 Q .048(glob or reference to a type)-.15 F .047(\ glob, whether blessed or unblessed\); tied \214lehandles will be ignore\ d and)-.15 F(processing will stop there.)128 488.4 Q .776(If the hook i\ s an array reference, its \214rst element must be a subroutine referenc\ e.)128 506.4 R .777(This subroutine is)5.777 F .504(called as abo)128 518.4 R -.15(ve)-.15 G 3.003(,b).15 G .503 (ut the \214rst parameter is the array reference.)-3.203 F .503 (This lets you indirectly pass ar)5.503 F(guments)-.18 E (to the subroutine.)128 530.4 Q(In other w)128 548.4 Q (ords, you can write:)-.1 E F1(push @INC, \\&my_sub;)152 566.4 Q (sub my_sub {)152 578.4 Q(my \($coderef, $filename\) = @_;)176 590.4 Q 6 (#$)12 G(coderef is \\&my_sub)-6 E(...)176 602.4 Q(})152 614.4 Q F0(or:) 128 632.4 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 64)162.62 F 0 Cg EP %%Page: 65 65 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (push @INC, [ \\&my_sub, $x, $y, ... ];)152 84 Q(sub my_sub {)152 96 Q (my \($arrayref, $filename\) = @_;)176 108 Q 6(#R)176 120 S (etrieve $x, $y, ...)-6 E(my @parameters = @$arrayref[1..$#$arrayref];) 176 132 Q(...)176 144 Q(})152 156 Q F0 .183 (If the hook is an object, it must pro)128 174 R .184(vide an)-.15 F/F2 9/Times-Roman@0 SF(INC)2.684 E F0 .184 (method that will be called as abo)2.684 F -.15(ve)-.15 G 2.684(,t).15 G .184(he \214rst parameter)-2.684 F .216(being the object itself.)128 186 R .216(\(Note that you must fully qualify the sub')5.216 F 2.716(sn)-.55 G .216(ame, as unquali\214ed)-2.716 F F1(INC)2.716 E F0 .215(is al)2.715 F -.1(wa)-.1 G(ys).1 E(forced into package)128 198 Q F1(main)2.5 E F0 2.5(.\) Here)B(is a typical code layout:)2.5 E F1 6(#I)152 216 S 6(nF)-6 G(oo.pm)-6 E(package Foo;)152 228 Q(sub new { ... })152 240 Q (sub Foo::INC {)152 252 Q(my \($self, $filename\) = @_;)176 264 Q(...) 176 276 Q(})152 288 Q 6(#I)152 312 S 6(nt)-6 G(he main program)-6 E (push @INC, Foo\255>new\(...\);)152 324 Q F0 .373 (These hooks are also permitted to set the)128 342 R F1(%INC)2.873 E F0 .373(entry corresponding to the \214les the)2.873 F 2.873(yh)-.15 G -2.25 -.2(av e)-2.873 H .373(loaded. See)3.073 F -.74(``)128 354 S (%INC').74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar)-.25 E(.)-.55 E -.15(Fo)128 372 S 2.5(ray).15 G(et-more-po)-2.5 E(werful import f)-.25 E (acility)-.1 E 2.5(,s)-.65 G(ee `)-2.5 E(`use')-.74 E 2.5('a)-.74 G (nd perlmod.)-2.5 E(reset)108 388.8 Q F2(EXPR)2.5 E F0(reset)108 400.8 Q .46(Generally used in a)128 412.8 R F1(continue)2.96 E F0 .459 (block at the end of a loop to clear v)2.96 F .459(ariables and reset) -.25 F F1(??)2.959 E F0 .459(searches so)2.959 F .455(that the)128 424.8 R 2.955(yw)-.15 G .455(ork ag)-3.055 F 2.955(ain. The)-.05 F -.15(ex) 2.955 G .455(pression is interpreted as a list of single characters \(h) .15 F .455(yphens allo)-.05 F .455(wed for)-.25 F 2.761(ranges\). All) 128 436.8 R -.25(va)2.761 G .261(riables and arrays be).25 F .26 (ginning with one of those letters are reset to their pristine state.) -.15 F(If)5.26 E 1.192(the e)128 448.8 R 1.192 (xpression is omitted, one-match searches \()-.15 F F1(?pattern?)A F0 3.692(\)a)C 1.192(re reset to match ag)-3.692 F 3.693(ain. Only)-.05 F (resets)3.693 E -.25(va)128 460.8 S (riables or searches in the current package.).25 E(Al)5 E -.1(wa)-.1 G (ys returns 1.).1 E(Examples:)5 E F1(reset \010X\010;)152 478.8 Q 6(#r) 36 G(eset all X variables)-6 E(reset \010a\255z\010;)152 490.8 Q 6(#r)24 G(eset lower case variables)-6 E 54(reset; #)152 502.8 R (just reset ?one\255time? searches)6 E F0(Resetting)128 520.8 Q F1 ("A\255Z")3.916 E F0 1.416(is not recommended because you')3.916 F 1.416 (ll wipe out your)-.1 F F1(@ARGV)3.916 E F0(and)3.915 E F1(@INC)3.915 E F0 1.415(arrays and)3.915 F(your)128 532.8 Q F1(%ENV)4.714 E F0 4.714 (hash. Resets)4.714 F 2.214(only package v)4.714 F 2.215(ariables; le) -.25 F 2.215(xical v)-.15 F 2.215(ariables are unaf)-.25 F 2.215 (fected, b)-.25 F 2.215(ut the)-.2 F 4.715(yc)-.15 G(lean)-4.715 E (themselv)128 544.8 Q(es up on scope e)-.15 E(xit an)-.15 E(yw)-.15 E (ay)-.1 E 2.5(,s)-.65 G 2.5(oy)-2.5 G(ou')-2.5 E(ll probably w)-.1 E (ant to use them instead.)-.1 E(See `)5 E(`my')-.74 E('.)-.74 E(return) 108 561.6 Q F2(EXPR)2.5 E F0(return)108 573.6 Q .909 (Returns from a subroutine,)128 585.6 R F1(eval)3.409 E F0 3.408(,o)C(r) -3.408 E F1 .908(do FILE)3.408 F F0 .908(with the v)3.408 F .908 (alue gi)-.25 F -.15(ve)-.25 G 3.408(ni).15 G(n)-3.408 E F2(EXPR)3.408 E F0 5.908(.E)C -.25(va)-5.908 G .908(luation of).25 F F2(EXPR)3.408 E F0 .225(may be in list, scalar)128 597.6 R 2.726(,o)-.4 G 2.726(rv)-2.726 G .226(oid conte)-2.926 F .226(xt, depending on ho)-.15 F 2.726(wt)-.25 G .226(he return v)-2.726 F .226(alue will be used, and the conte)-.25 F (xt)-.15 E .82(may v)128 609.6 R .82(ary from one e)-.25 F -.15(xe)-.15 G .82(cution to the ne).15 F .82(xt \(see)-.15 F F1(wantarray)3.32 E F0 3.32(\). If)B(no)3.32 E F2(EXPR)3.32 E F0 .819(is gi)3.32 F -.15(ve)-.25 G .819(n, returns an empty).15 F(list in list conte)128 621.6 Q (xt, the unde\214ned v)-.15 E(alue in scalar conte)-.25 E (xt, and \(of course\) nothing at all in v)-.15 E(oid conte)-.2 E(xt.) -.15 E .585(\(In the absence of an e)128 639.6 R(xplicit)-.15 E F1 (return)3.085 E F0 3.085(,as)C .585(ubroutine, e)-3.085 F -.25(va)-.25 G .585(l, or do).25 F F2(FILE)3.085 E F0 .585(automatically returns the v) 3.085 F(alue)-.25 E(of the last e)128 651.6 Q(xpression e)-.15 E -.25 (va)-.25 G(luated.\)).25 E(re)108 668.4 Q -.15(ve)-.25 G(rse).15 E F2 (LIST)2.5 E F0 .763(In list conte)128 680.4 R .763(xt, returns a list v) -.15 F .762(alue consisting of the elements of)-.25 F F2(LIST)3.262 E F0 .762(in the opposite order)3.262 F 5.762(.I)-.55 G 3.262(ns)-5.762 G (calar)-3.262 E(conte)128 692.4 Q .061(xt, concatenates the elements of) -.15 F F2(LIST)2.561 E F0 .061(and returns a string v)2.561 F .062 (alue with all characters in the opposite)-.25 F(order)128 704.4 Q(.) -.55 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 65)162.62 F 0 Cg EP %%Page: 66 66 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (print join\(", ", reverse "world", "Hello"\); # Hello, world)152 84 Q (print scalar reverse "dlrow ,", "olleH";)152 108 Q 6(#H)24 G (ello, world)-6 E F0(Used without ar)128 126 Q(guments in scalar conte) -.18 E(xt,)-.15 E/F2 10/Times-Italic@0 SF -1.91 -.37(re v)2.5 H(er).37 E (se\(\))-.1 E F0(re)2.5 E -.15(ve)-.25 G(rses).15 E F1($_)2.5 E F0(.)A F1($_ = "dlrow ,olleH";)152 144 Q(print reverse;)152 156 Q 6(#N)180 G 6 (oo)-6 G(utput, list context)-6 E(print scalar reverse;)152 168 Q 6(#H) 138 G(ello, world)-6 E F0 .225(Note that re)128 186 R -.15(ve)-.25 G .225(rsing an array to itself \(as in).15 F F1 .225(@a = reverse @a) 2.725 F F0 2.725(\)w)C .225(ill preserv)-2.725 F 2.725(en)-.15 G(on-e) -2.725 E .225(xistent elements)-.15 F(whene)128 198 Q -.15(ve)-.25 G 2.5 (rp).15 G(ossible, i.e., for non magical arrays or tied arrays with)-2.5 E F1(EXISTS)2.5 E F0(and)2.5 E F1(DELETE)2.5 E F0(methods.)2.5 E 2.183 (This operator is also handy for in)128 216 R -.15(ve)-.4 G 2.184 (rting a hash, although there are some ca).15 F -.15(ve)-.2 G 4.684 (ats. If).15 F 4.684(av)4.684 G 2.184(alue is)-4.934 F 1.24(duplicated \ in the original hash, only one of those can be represented as a k)128 228 R 1.54 -.15(ey i)-.1 H 3.74(nt).15 G 1.24(he in)-3.74 F -.15(ve)-.4 G 1.24(rted hash.).15 F .694(Also, this has to unwind one hash and b)128 240 R .694(uild a whole ne)-.2 F 3.195(wo)-.25 G .695(ne, which may tak) -3.195 F 3.195(es)-.1 G .695(ome time on a lar)-3.195 F(ge)-.18 E (hash, such as from a)128 252 Q/F3 9/Times-Roman@0 SF(DBM)2.5 E F0 (\214le.)2.5 E F1(%by_name = reverse %by_address;)152 270 Q 6(#I)12 G (nvert the hash)-6 E F0(re)108 286.8 Q(winddir)-.25 E F3(DIRHANDLE)2.5 E F0(Sets the current position to the be)128 298.8 Q (ginning of the directory for the)-.15 E F1(readdir)2.5 E F0(routine on) 2.5 E F3(DIRHANDLE)2.5 E F0(.)A(rinde)108 315.6 Q(x)-.15 E F3(STR)2.5 E F0(,SUBSTR,POSITION)A(rinde)108 327.6 Q(x)-.15 E F3(STR)2.5 E F0 (,SUBSTR)A -.8(Wo)128 339.6 S .433(rks just lik).8 F(e)-.1 E F2(inde) 2.933 E(x\(\))-.2 E F0 -.15(ex)2.933 G .433 (cept that it returns the position of the).15 F F2(last)2.933 E F0 .433 (occurrence of)2.933 F F3(SUBSTR)2.933 E F0(in)2.933 E F3(STR)2.933 E F0 5.432(.I)C(f)-5.432 E F3(POSITION)128 351.6 Q F0 (is speci\214ed, returns the last occurrence be)2.5 E (ginning at or before that position.)-.15 E(rmdir)108 368.4 Q F3(FILEN) 2.5 E(AME)-.315 E F0(rmdir)108 380.4 Q .644 (Deletes the directory speci\214ed by)128 392.4 R F3(FILEN)3.144 E(AME) -.315 E F0 .644(if that directory is empty)3.144 F 5.645(.I)-.65 G 3.145 (fi)-5.645 G 3.145(ts)-3.145 G .645(ucceeds it returns true;)-3.145 F (otherwise it returns f)128 404.4 Q(alse and sets)-.1 E F1($!)2.5 E F0 2.5(\(errno\). If)2.5 F F3(FILEN)2.5 E(AME)-.315 E F0(is omitted, uses) 2.5 E F1($_)2.5 E F0(.)A 3.799 -.8(To r)128 422.4 T(emo).8 E 2.499 -.15 (ve a d)-.15 H 2.199(irectory tree recursi).15 F -.15(ve)-.25 G 2.199 (ly \().15 F F1 2.199(rm \255rf)B F0 2.199(on Unix\) look at the)4.699 F F1(rmtree)4.698 E F0 2.198(function of the)4.698 F(File::P)128 434.4 Q (ath module.)-.15 E(s///)108 451.2 Q(The substitution operator)128 451.2 Q 5(.S)-.55 G(ee `)-5 E(`Re)-.74 E(ge)-.15 E(xp Quote-Lik)-.15 E 2.5(eO) -.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E(say)108 468 Q F3 .25(FILEHANDLE LIST)2.5 F F0(say)108 480 Q F3(FILEHANDLE)2.5 E F0(say)108 492 Q F3(LIST)2.5 E F0(say)108 504 Q 2.013(Just lik)128 504 R (e)-.1 E F1(print)4.513 E F0 4.513(,b)C 2.013 (ut implicitly appends a ne)-4.713 F(wline.)-.25 E F1 2.013(say LIST) 7.013 F F0 2.014(is simply an abbre)4.513 F 2.014(viation for)-.25 F F1 ({)4.514 E .135(local $\\ = "\\n"; print LIST })128 516 R F0 5.135(.T)C 2.635(ou)-5.935 G(se)-2.635 E F3(FILEHANDLE)2.634 E F0 .134(without a) 2.634 F F3(LIST)2.634 E F0 .134(to print the contents)2.634 F(of)128 528 Q F1($_)2.5 E F0(to it, you must use a real \214lehandle lik)2.5 E(e)-.1 E F1(FH)2.5 E F0 2.5(,n)C(ot an indirect one lik)-2.5 E(e)-.1 E F1($fh) 2.5 E F0(.)A .236(This k)128 546 R -.15(ey)-.1 G -.1(wo).15 G .236 (rd is a).1 F -.25(va)-.2 G .236(ilable only when the).25 F F1("say") 2.736 E F0 .236(feature is enabled; see feature.)2.736 F(Alternately) 5.236 E 2.736(,i)-.65 G .236(nclude a)-2.736 F F1(use v5.10)128 558 Q F0 (or later to the current scope.)2.5 E(scalar)108 574.8 Q F3(EXPR)2.5 E F0 -.15(Fo)128 586.8 S(rces).15 E F3(EXPR)2.5 E F0 (to be interpreted in scalar conte)2.5 E(xt and returns the v)-.15 E (alue of)-.25 E F3(EXPR)2.5 E F0(.)A F1 (@counts = \( scalar @a, scalar @b, scalar @c \);)152 604.8 Q F0 1.465 (There is no equi)128 622.8 R -.25(va)-.25 G 1.465 (lent operator to force an e).25 F 1.464 (xpression to be interpolated in list conte)-.15 F 1.464(xt because in) -.15 F .507(practice, this is ne)128 634.8 R -.15(ve)-.25 G 3.007(rn).15 G 3.007(eeded. If)-3.007 F .508(you really w)3.007 F .508 (anted to do so, ho)-.1 F(we)-.25 E -.15(ve)-.25 G 1.308 -.4(r, y).15 H .508(ou could use the construction).4 F F1(@{[ \(some expression\) ]}) 128 646.8 Q F0 2.5(,b)C(ut usually a simple)-2.7 E F1 (\(some expression\))2.5 E F0(suf)2.5 E(\214ces.)-.25 E(Because)128 664.8 Q F1(scalar)3.446 E F0 .946(is a unary operator)3.446 F 3.446(,i) -.4 G 3.446(fy)-3.446 G .946 (ou accidentally use a parenthesized list for the)-3.446 F F3(EXPR)3.446 E F0 3.446(,t)C(his)-3.446 E(beha)128 676.8 Q -.15(ve)-.2 G 2.639(sa).15 G 2.639(sas)-2.639 G .139(calar comma e)-2.639 F .139(xpression, e)-.15 F -.25(va)-.25 G .139(luating all b).25 F .14(ut the last element in v) -.2 F .14(oid conte)-.2 F .14(xt and returning)-.15 F (the \214nal element e)128 688.8 Q -.25(va)-.25 G (luated in scalar conte).25 E 2.5(xt. This)-.15 F(is seldom what you w) 2.5 E(ant.)-.1 E(The follo)128 706.8 Q(wing single statement:)-.25 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 66)162.62 F 0 Cg EP %%Page: 67 67 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (print uc\(scalar\(&foo,$bar\)\),$baz;)152 84 Q F0(is the moral equi)128 102 Q -.25(va)-.25 G(lent of these tw).25 E(o:)-.1 E F1(&foo;)152 120 Q (print\(uc\($bar\),$baz\);)152 132 Q F0 (See perlop for more details on unary operators and the comma operator) 128 150 Q(.)-.55 E(seek)108 166.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(,POSITION,WHENCE)A(Sets)128 178.8 Q F2(FILEHANDLE)5.886 E F0 4.486 -.55('s p)D 3.386(osition, just lik).55 F 5.886(et)-.1 G(he)-5.886 E F1 (fseek)5.886 E F0 3.385(call of)5.886 F F1(stdio)5.885 E F0(.)A F2 (FILEHANDLE)8.385 E F0 3.385(may be an)5.885 F -.15(ex)128 190.8 S .061 (pression whose v).15 F .061(alue gi)-.25 F -.15(ve)-.25 G 2.561(st).15 G .061(he name of the \214lehandle.)-2.561 F .062(The v)5.061 F .062 (alues for)-.25 F F2(WHENCE)2.562 E F0(are)2.562 E F1(0)2.562 E F0 .062 (to set the ne)2.562 F(w)-.25 E(position)128 202.8 Q/F3 10 /Times-Italic@0 SF .299(in bytes)2.799 F F0(to)2.799 E F2(POSITION)2.799 E F0(;)A F1(1)2.799 E F0 .299(to set it to the current position plus) 2.799 F F2(POSITION)2.798 E F0 2.798(;a)C(nd)-2.798 E F1(2)2.798 E F0 .298(to set it to)2.798 F F2(EOF)2.798 E F0(plus)128 214.8 Q F2 (POSITION)2.527 E F0 2.527(,t)C .027(ypically ne)-2.527 F -.05(ga)-.15 G (ti).05 E -.15(ve)-.25 G 5.027(.F).15 G(or)-5.177 E F2(WHENCE)2.528 E F0 .028(you may use the constants)2.528 F F1(SEEK_SET)2.528 E F0(,)A F1 (SEEK_CUR)2.528 E F0(,)A(and)128 226.8 Q F1(SEEK_END)3.218 E F0 .718(\(\ start of the \214le, current position, end of the \214le\) from the Fcn\ tl module.)3.218 F(Returns)5.717 E F1(1)3.217 E F0(on success, f)128 238.8 Q(alse otherwise.)-.1 E .095(Note the)128 256.8 R F3 .095 (in bytes)2.595 F F0 2.595(:e)C -.15(ve)-2.845 G 2.595(ni).15 G 2.595 (ft)-2.595 G .095 (he \214lehandle has been set to operate on characters \(for e)-2.595 F .096(xample by using the)-.15 F F1(:encoding\(utf8\))128 268.8 Q F0 3.039(open layer\),)5.539 F F3(tell\(\))5.538 E F0 3.038 (will return byte of)5.538 F 3.038(fsets, not character of)-.25 F 3.038 (fsets \(because)-.25 F(implementing that w)128 280.8 Q(ould render)-.1 E F3(seek\(\))2.5 E F0(and)2.5 E F3(tell\(\))2.5 E F0(rather slo)2.5 E (w\).)-.25 E 1.788(If you w)128 298.8 R 1.788 (ant to position the \214le for)-.1 F F1(sysread)4.289 E F0(or)4.289 E F1(syswrite)4.289 E F0 4.289(,d)C(on')-4.289 E 4.289(tu)-.18 G(se)-4.289 E F1(seek)4.289 E F0 4.289(,b)C 1.789(ecause b)-4.289 F(uf)-.2 E(fering) -.25 E(mak)128 310.8 Q 2.257(es its ef)-.1 F 2.257(fect on the \214le') -.25 F 4.757(sr)-.55 G 2.257 (ead-write position unpredictable and non-portable.)-4.757 F(Use)7.256 E F1(sysseek)4.756 E F0(instead.)128 322.8 Q .687 (Due to the rules and rigors of)128 340.8 R F2(ANSI)3.187 E F0 .688 (C, on some systems you ha)3.188 F .988 -.15(ve t)-.2 H 3.188(od).15 G 3.188(oas)-3.188 G .688(eek whene)-3.188 F -.15(ve)-.25 G 3.188(ry).15 G .688(ou switch)-3.188 F 2.471(between reading and writing.)128 352.8 R 2.471(Amongst other things, this may ha)7.471 F 2.771 -.15(ve t)-.2 H 2.47(he ef).15 F 2.47(fect of calling stdio')-.25 F(s)-.55 E F3(clear) 128 364.8 Q(err)-.37 E F0 2.5(\(3\). A)1.666 F F2(WHENCE)2.5 E F0(of)2.5 E F1(1)2.5 E F0(\()2.5 E F1(SEEK_CUR)A F0 2.5(\)i)C 2.5(su)-2.5 G (seful for not mo)-2.5 E(ving the \214le position:)-.15 E F1 (seek\(TEST,0,1\);)152 382.8 Q F0 1.126 (This is also useful for applications emulating)128 400.8 R F1 1.126 (tail \255f)3.626 F F0 6.126(.O)C 1.126(nce you hit)-6.126 F F2(EOF) 3.627 E F0 1.127(on your read and then)3.627 F .648 (sleep for a while, you \(probably\) ha)128 412.8 R .947 -.15(ve t)-.2 H 3.147(os).15 G .647(tick in a dummy)-3.147 F F3(seek\(\))3.147 E F0 .647 (to reset things.)3.147 F(The)5.647 E F1(seek)3.147 E F0(doesn')3.147 E (t)-.18 E .327(change the position, b)128 424.8 R .327(ut it)-.2 F F3 (does)2.827 E F0 .327 (clear the end-of-\214le condition on the handle, so that the ne)2.827 F (xt)-.15 E F1()2.828 E F0(mak)128 436.8 Q(es Perl try ag)-.1 E (ain to read something.)-.05 E(\(W)5 E 2.5(eh)-.8 G(ope.\))-2.5 E 2.681 (If that doesn')128 454.8 R 5.181(tw)-.18 G 2.681 (ork \(some I/O implementations are particularly cantank)-5.281 F 2.68 (erous\), you might need)-.1 F(something lik)128 466.8 Q 2.5(et)-.1 G (his:)-2.5 E F1(for \(;;\) {)152 484.8 Q (for \($curpos = tell\(FILE\); $_ = ;)176 496.8 Q ($curpos = tell\(FILE\)\) {)206 508.8 Q 6(#s)200 520.8 S (earch for some stuff and put it into files)-6 E(})176 532.8 Q (sleep\($for_a_while\);)176 544.8 Q(seek\(FILE, $curpos, 0\);)176 556.8 Q(})152 568.8 Q F0(seekdir)108 585.6 Q F2(DIRHANDLE)2.5 E F0(,POS)A .393 (Sets the current position for the)128 597.6 R F1(readdir)2.893 E F0 .393(routine on)2.893 F F2(DIRHANDLE)2.894 E F0(.)A F2(POS)5.394 E F0 .394(must be a v)2.894 F .394(alue returned by)-.25 F F1(telldir)128 609.6 Q F0(.)A F1(seekdir)8.617 E F0 3.617(also has the same ca)6.117 F -.15(ve)-.2 G 3.616(ats about possible directory compaction as the).15 F (corresponding system library routine.)128 621.6 Q(select)108 638.4 Q F2 (FILEHANDLE)2.5 E F0(select)108 650.4 Q 1.391 (Returns the currently selected \214lehandle.)128 662.4 R(If)6.391 E F2 (FILEHANDLE)3.892 E F0 1.392(is supplied, sets the ne)3.892 F 3.892(wc) -.25 G 1.392(urrent def)-3.892 F(ault)-.1 E .441 (\214lehandle for output.)128 674.4 R .441(This has tw)5.441 F 2.941(oe) -.1 G -.25(ff)-2.941 G .441(ects: \214rst, a).25 F F1(write)2.941 E F0 .44(or a)2.941 F F1(print)2.94 E F0 .44(without a \214lehandle def)2.94 F .44(ault to)-.1 F(this)128 686.4 Q F2(FILEHANDLE)2.5 E F0 5(.S)C (econd, references to v)-5 E (ariables related to output will refer to this output channel.)-.25 E -.15(Fo)128 704.4 S 4.591(re).15 G 2.091(xample, to set the top-of-form\ format for more than one output channel, you might do the)-4.741 F (follo)128 716.4 Q(wing:)-.25 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 67)162.62 F 0 Cg EP %%Page: 68 68 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (select\(REPORT1\);)152 84 Q($^ = \010report1_top\010;)152 96 Q (select\(REPORT2\);)152 108 Q($^ = \010report2_top\010;)152 120 Q/F2 9 /Times-Roman@0 SF(FILEHANDLE)128 138 Q F0(may be an e)2.5 E (xpression whose v)-.15 E(alue gi)-.25 E -.15(ve)-.25 G 2.5(st).15 G (he name of the actual \214lehandle.)-2.5 E(Thus:)5 E F1 ($oldfh = select\(STDERR\); $| = 1; select\($oldfh\);)152 156 Q F0 .397 (Some programmers may prefer to think of \214lehandles as objects with \ methods, preferring to write the)128 174 R(last e)128 186 Q(xample as:) -.15 E F1(use IO::Handle;)152 204 Q(STDERR\255>autoflush\(1\);)152 216 Q F0(select)108 232.8 Q F2(RBITS)2.5 E F0(,WBITS,EBITS,TIMEOUT)A .514 (This calls the)128 244.8 R/F3 10/Times-Italic@0 SF(select)3.014 E F0 .514(\(2\) syscall with the bit masks speci\214ed, which can be constru\ cted using)1.666 F F1(fileno)3.015 E F0(and)128 256.8 Q F1(vec)2.5 E F0 2.5(,a)C(long these lines:)-2.5 E F1($rin = $win = $ein = \010\010;)152 274.8 Q(vec\($rin,fileno\(STDIN\),1\) = 1;)152 286.8 Q (vec\($win,fileno\(STDOUT\),1\) = 1;)152 298.8 Q($ein = $rin | $win;)152 310.8 Q F0(If you w)128 328.8 Q(ant to select on man)-.1 E 2.5<798c>-.15 G(lehandles, you may wish to write a subroutine lik)-2.5 E 2.5(et)-.1 G (his:)-2.5 E F1(sub fhbits {)152 346.8 Q (my\(@fhlist\) = split\(\010 \010,$_[0]\);)176 358.8 Q(my\($bits\);)176 370.8 Q(for \(@fhlist\) {)176 382.8 Q(vec\($bits,fileno\($_\),1\) = 1;) 200 394.8 Q(})176 406.8 Q($bits;)176 418.8 Q(})152 430.8 Q ($rin = fhbits\(\010STDIN TTY SOCK\010\);)152 442.8 Q F0 (The usual idiom is:)128 460.8 Q F1(\($nfound,$timeleft\) =)152 478.8 Q (select\($rout=$rin, $wout=$win, $eout=$ein, $timeout\);)164 490.8 Q F0 (or to block until something becomes ready just do this)128 508.8 Q F1 ($nfound = select\($rout=$rin, $wout=$win, $eout=$ein, undef\);)152 526.8 Q F0 1.472(Most systems do not bother to return an)128 544.8 R 1.471(ything useful in)-.15 F F1($timeleft)3.971 E F0 3.971(,s)C 3.971 (oc)-3.971 G(alling)-3.971 E F3(select\(\))3.971 E F0 1.471(in scalar) 3.971 F(conte)128 556.8 Q(xt just returns)-.15 E F1($nfound)2.5 E F0(.)A (An)128 574.8 Q 4.396(yo)-.15 G 4.396(ft)-4.396 G 1.896 (he bit masks can also be undef.)-4.396 F 1.897 (The timeout, if speci\214ed, is in seconds, which may be)6.897 F 4.542 (fractional. Note:)128 586.8 R 2.042 (not all implementations are capable of returning the)4.542 F F1 ($timeleft)4.541 E F0 7.041(.I)C 4.541(fn)-7.041 G 2.041(ot, the)-4.541 F(y)-.15 E(al)128 598.8 Q -.1(wa)-.1 G(ys return).1 E F1($timeleft)2.5 E F0(equal to the supplied)2.5 E F1($timeout)2.5 E F0(.)A -1.1(Yo)128 616.8 S 2.5(uc)1.1 G(an ef)-2.5 E (fect a sleep of 250 milliseconds this w)-.25 E(ay:)-.1 E F1 (select\(undef, undef, undef, 0.25\);)152 634.8 Q F0 .59 (Note that whether)128 652.8 R F1(select)3.09 E F0 .59 (gets restarted after signals \(say)3.09 F(,)-.65 E F2(SIGALRM)3.09 E F0 3.09(\)i)C 3.09(si)-3.09 G(mplementation-dependent.)-3.09 E (See also perlport for notes on the portability of)128 664.8 Q F1 (select)2.5 E F0(.)A(On error)128 682.8 Q(,)-.4 E F1(select)2.5 E F0 (beha)2.5 E -.15(ve)-.2 G 2.5(sl).15 G(ik)-2.5 E(e)-.1 E F3(select)2.5 E F0(\(2\): it returns \2551 and sets)1.666 E F1($!)2.5 E F0(.)A .873 (On some Unix)128 700.8 R(es,)-.15 E F3(select)3.373 E F0 .873 (\(2\) may report a sock)1.666 F .873(et \214le descriptor as `)-.1 F .873(`ready for reading')-.74 F 3.372('e)-.74 G -.15(ve)-3.622 G 3.372 (nw).15 G .872(hen no)-3.372 F .599(data is a)128 712.8 R -.25(va)-.2 G .599(ilable, and thus an).25 F 3.099(ys)-.15 G(ubsequent)-3.099 E F1 (read)3.099 E F0 -.1(wo)3.099 G .6(uld block. This can be a).1 F -.2(vo) -.2 G .6(ided if you al).2 F -.1(wa)-.1 G .6(ys use).1 F (O_NONBLOCK on the sock)128 724.8 Q(et. See)-.1 E F3(select)2.5 E F0 (\(2\) and)1.666 E F3(fcntl)2.5 E F0(\(2\) for further details.)1.666 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 68)162.62 F 0 Cg EP %%Page: 69 69 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 9/Times-Bold@0 SF -1.08(WA)128 84 S(RNING)1.08 E F0 2.586(:O)C .086 (ne should not attempt to mix b)-2.586 F(uf)-.2 E .086(fered I/O \(lik) -.25 F(e)-.1 E/F2 10/Courier@0 SF(read)2.586 E F0 .086(or <)2.586 F/F3 9 /Times-Roman@0 SF(FH)A F0 .086(>\) with)B F2(select)2.585 E F0 2.585(,e) C .085(xcept as)-2.735 F(permitted by)128 96 Q F3(POSIX)2.5 E F0 2.5(,a) C(nd e)-2.5 E -.15(ve)-.25 G 2.5(nt).15 G(hen only on)-2.5 E F3(POSIX) 2.5 E F0 2.5(systems. Y)2.5 F(ou ha)-1.1 E .3 -.15(ve t)-.2 H 2.5(ou).15 G(se)-2.5 E F2(sysread)2.5 E F0(instead.)2.5 E(semctl)108 112.8 Q F3(ID) 2.5 E F0(,SEMNUM,CMD,ARG)A(Calls the System V)128 124.8 Q F3(IPC)2.5 E F0(function)2.5 E/F4 10/Times-Italic@0 SF(semctl)2.5 E F0 2.5(\(2\). Y) 1.666 F(ou')-1.1 E(ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G (ay)-2.5 E F2(use IPC::SysV;)152 142.8 Q F0 1.521 (\214rst to get the correct constant de\214nitions.)128 160.8 R(If)6.521 E F3(CMD)4.021 E F0(is)4.022 E F3(IPC_ST)4.022 E -.999(AT)-.837 G F0(or) 5.021 E F3(GET)4.022 E(ALL)-.837 E F0 4.022(,t)C(hen)-4.022 E F3(ARG) 4.022 E F0 1.522(must be a)4.022 F -.25(va)128 172.8 S .118 (riable that will hold the returned semid_ds structure or semaphore v) .25 F .118(alue array)-.25 F 5.118(.R)-.65 G .117(eturns lik)-5.118 F(e) -.1 E F2(ioctl)2.617 E F0(:)A .033(the unde\214ned v)128 184.8 R .033 (alue for error)-.25 F 2.533(,")-.4 G F2 6.033(0b)-2.533 G .033(ut true) -6.033 F F0 2.533("f)C .033(or zero, or the actual return v)-2.533 F .033(alue otherwise.)-.25 F(The)5.033 E F3(ARG)2.533 E F0 8.503 (must consist of a v)128 196.8 R 8.502(ector of nati)-.15 F 8.802 -.15 (ve s)-.25 H 8.502(hort inte).15 F 8.502 (gers, which may be created with)-.15 F F2(pack\("s!",\(0\)x$nsem\))128 208.8 Q F0 6.298(.S)C 1.298(ee also `)-6.298 F(`SysV)-.74 E F3(IPC)3.798 E F0 2.778 -.74('' i)D 3.798(np).74 G(erlipc,)-3.798 E F2(IPC::SysV) 3.799 E F0(,)A F2(IPC::Semaphore)3.799 E F0(documentation.)128 220.8 Q (semget)108 237.6 Q F3(KEY)2.5 E F0(,NSEMS,FLA)A(GS)-.4 E 1.56 (Calls the System V)128 249.6 R F3(IPC)4.06 E F0(function)4.06 E F4 (semg)4.059 E(et)-.1 E F0 4.059(\(2\). Returns)1.666 F 1.559 (the semaphore id, or the unde\214ned v)4.059 F 1.559(alue on)-.25 F (error)128 261.6 Q 5(.S)-.55 G(ee also `)-5 E(`SysV)-.74 E F3(IPC)2.5 E F0 1.48 -.74('' i)D 2.5(np).74 G(erlipc,)-2.5 E F2(IPC::SysV)2.5 E F0(,) A F2(IPC::SysV::Semaphore)2.5 E F0(documentation.)2.5 E(semop)108 278.4 Q F3(KEY)2.5 E F0(,OPSTRING)A .839(Calls the System V)128 290.4 R F3 (IPC)3.339 E F0(function)3.339 E F4(semop)3.339 E F0 .839 (\(2\) for semaphore operations such as signalling and w)1.666 F (aiting.)-.1 E F3(OPSTRING)128 302.4 Q F0 .602(must be a pack)3.102 F .602(ed array of semop structures.)-.1 F .602 (Each semop structure can be generated with)5.602 F F2 3.272 (pack\("s!3", $semnum, $semop, $semflag\))128 314.4 R F0 8.272(.T)C 3.272(he length of)-8.272 F F3(OPSTRING)5.772 E F0 3.273(implies the) 5.772 F 2.151(number of semaphore operations.)128 326.4 R 2.151 (Returns true if successful, f)7.151 F 2.151(alse on error)-.1 F 7.15 (.A)-.55 G 4.65(sa)-7.15 G 4.65(ne)-4.65 G 2.15(xample, the)-4.8 F (follo)128 338.4 Q(wing code w)-.25 E(aits on semaphore)-.1 E F2 ($semnum)2.5 E F0(of semaphore id)2.5 E F2($semid:)2.5 E ($semop = pack\("s!3", $semnum, \2551, 0\);)152 356.4 Q (die "Semaphore trouble: $!\\n" unless semop\($semid, $semop\);)152 368.4 Q F0 3.303 -.8(To s)128 386.4 T 1.703 (ignal the semaphore, replace).8 F F24.204 E F0(with)4.204 E F2(1) 4.204 E F0 6.704(.S)C 1.704(ee also `)-6.704 F(`SysV)-.74 E F3(IPC)4.204 E F0 3.184 -.74('' i)D 4.204(np).74 G(erlipc,)-4.204 E F2(IPC::SysV) 4.204 E F0 4.204(,a)C(nd)-4.204 E F2(IPC::SysV::Semaphore)128 398.4 Q F0 (documentation.)2.5 E(send)108 415.2 Q F3(SOCKET)2.5 E F0(,MSG,FLA)A (GS,T)-.4 E(O)-.18 E(send)108 427.2 Q F3(SOCKET)2.5 E F0(,MSG,FLA)A(GS) -.4 E .585(Sends a message on a sock)128 439.2 R 3.085(et. Attempts)-.1 F .584(to send the scalar)3.085 F F3(MSG)3.084 E F0 .584(to the)3.084 F F3(SOCKET)3.084 E F0 3.084(\214lehandle. T)3.084 F(ak)-.8 E .584(es the) -.1 F 2.479(same \215ags as the system call of the same name.)128 451.2 R 2.479(On unconnected sock)7.479 F 2.479(ets, you must specify a)-.1 F 1.223(destination to)128 463.2 R F4 1.223(send to)3.723 F F0 3.723(,i)C 3.723(nw)-3.723 G 1.223(hich case it does a)-3.723 F F4(sendto)3.723 E F0 1.223(\(2\) syscall.)1.666 F 1.222(Returns the number of characters) 6.223 F .123(sent, or the unde\214ned v)128 475.2 R .123(alue on error) -.25 F 5.123(.T)-.55 G(he)-5.123 E F4(sendmsg)2.623 E F0 .123 (\(2\) syscall is currently unimplemented.)1.666 F .123(See `)5.123 F(`) -.74 E F3(UDP:)A F0(Message P)128 487.2 Q(assing')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc for e)-2.5 E(xamples.)-.15 E .539(Note the)128 505.2 R F4 -.15(ch)3.039 G(ar).15 E(acter)-.15 E(s)-.1 E F0 3.038(:d)C .538(epending on the status of the sock)-3.038 F .538 (et, either \(8\255bit\) bytes or characters are sent.)-.1 F 2.583 (By def)128 517.2 R 2.583(ault all sock)-.1 F 2.583 (ets operate on bytes, b)-.1 F 2.583(ut for e)-.2 F 2.583 (xample if the sock)-.15 F 2.583(et has been changed using)-.1 F F4 (binmode\(\))128 529.2 Q F0 1.612(to operate with the)4.112 F F2 (:encoding\(utf8\))4.112 E F0 1.611(I/O layer \(see `)4.112 F(`open') -.74 E 1.611(', or the)-.74 F F2(open)4.111 E F0(pragma,)4.111 E 2.456 (open\), the I/O will operate on)128 541.2 R F3(UTF\2558)4.956 E F0 2.456(encoded Unicode characters, not bytes.)4.956 F 2.456 (Similarly for the)7.456 F F2(:encoding)128 553.2 Q F0 (pragma: in that case pretty much an)2.5 E 2.5(yc)-.15 G (haracters can be sent.)-2.5 E(setpgrp)108 570 Q F3(PID)2.5 E F0(,PGRP)A 1.098(Sets the current process group for the speci\214ed)128 582 R F3 (PID)3.598 E F0(,)A F2(0)3.598 E F0 1.098(for the current process.)3.598 F 1.098(Raises an e)6.098 F(xception)-.15 E 2.885 (when used on a machine that doesn')128 594 R 5.385(ti)-.18 G(mplement) -5.385 E F3(POSIX)5.385 E F4(setpgid)5.385 E F0 2.885(\(2\) or)1.666 F F3(BSD)5.385 E F4(setpgrp)5.385 E F0 5.386(\(2\). If)1.666 F(the)5.386 E (ar)128 606 Q .113(guments are omitted, it def)-.18 F .113(aults to)-.1 F F2(0,0)2.613 E F0 5.113(.N)C .113(ote that the)-5.113 F F3(BSD)2.613 E F0 .112(4.2 v)2.613 F .112(ersion of)-.15 F F2(setpgrp)2.612 E F0 .112 (does not accept)2.612 F(an)128 618 Q 2.5(ya)-.15 G -.18(rg)-2.5 G (uments, so only).18 E F2(setpgrp\(0,0\))2.5 E F0(is portable.)2.5 E (See also)5 E F2(POSIX::setsid\(\))2.5 E F0(.)A(setpriority)108 634.8 Q F3(WHICH)2.5 E F0(,WHO,PRIORITY)A 1.588 (Sets the current priority for a process, a process group, or a user)128 646.8 R 6.589(.\()-.55 G(See)-6.589 E F4(setpriority)4.089 E F0 4.089 (\(2\).\) Raises)1.666 F(an)4.089 E -.15(ex)128 658.8 S (ception when used on a machine that doesn').15 E 2.5(ti)-.18 G (mplement)-2.5 E F4(setpriority)2.5 E F0(\(2\).)1.666 E(setsock)108 675.6 Q(opt)-.1 E F3(SOCKET)2.5 E F0(,LEVEL,OPTN)A(AME,OPTV)-.35 E(AL) -1.35 E 1.485(Sets the sock)128 687.6 R 1.485(et option requested.)-.1 F (Returns)6.484 E F2(undef)3.984 E F0 1.484(on error)3.984 F 6.484(.U) -.55 G 1.484(se inte)-6.484 F 1.484(ger constants pro)-.15 F 1.484 (vided by the)-.15 F F2(Socket)128 699.6 Q F0 4.315(module for)6.815 F F3(LEVEL)6.815 E F0(and)6.815 E F3(OPN)6.815 E(AME)-.315 E F0 9.315(.V)C 4.315(alues for)-10.425 F F3(LEVEL)6.815 E F0 4.316 (can also be obtained from)6.815 F(getprotobyname.)128 711.6 Q F3(OPTV) 7.222 E(AL)-1.215 E F0 2.222(might either be a pack)4.722 F 2.222 (ed string or an inte)-.1 F(ger)-.15 E 7.222(.A)-.55 G 4.722(ni)-7.222 G (nte)-4.722 E(ger)-.15 E F3(OPTV)4.722 E(AL)-1.215 E F0(is)4.722 E (shorthand for pack\(`)128 723.6 Q(`i')-.74 E(',)-.74 E F3(OPTV)2.5 E (AL)-1.215 E F0(\).)A(perl v5.14.2)72 768 Q 198.17(2011-10-01 69)162.62 F 0 Cg EP %%Page: 70 70 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(An e)128 84 Q (xample disabling Nagle')-.15 E 2.5(sa)-.55 G(lgorithm on a sock)-2.5 E (et:)-.1 E/F1 10/Courier@0 SF(use Socket qw\(IPPROTO_TCP TCP_NODELAY\);) 152 102 Q(setsockopt\($socket, IPPROTO_TCP, TCP_NODELAY, 1\);)152 114 Q F0(shift)108 130.8 Q/F2 9/Times-Roman@0 SF(ARRA)2.5 E(Y)-.945 E F0 (shift)108 142.8 Q F2(EXPR)2.5 E F0(shift)108 154.8 Q .805 (Shifts the \214rst v)128 166.8 R .805(alue of the array of)-.25 F 3.305 (fa)-.25 G .806(nd returns it, shortening the array by 1 and mo)-3.305 F .806(ving e)-.15 F -.15(ve)-.25 G(rything).15 E(do)128 178.8 Q 3.164 (wn. If)-.25 F .663(there are no elements in the array)3.164 F 3.163(,r) -.65 G .663(eturns the unde\214ned v)-3.163 F 3.163(alue. If)-.25 F F2 (ARRA)3.163 E(Y)-.945 E F0 .663(is omitted, shifts)3.163 F(the)128 190.8 Q F1(@_)4.232 E F0 1.732(array within the le)4.232 F 1.733 (xical scope of subroutines and formats, and the)-.15 F F1(@ARGV)4.233 E F0 1.733(array outside a)4.233 F .616(subroutine and also within the le) 128 202.8 R .616(xical scopes established by the)-.15 F F1 .615 (eval STRING)3.116 F F0(,)A F1 .615(BEGIN {})3.115 F F0(,)A F1(INIT) 3.115 E({})128 214.8 Q F0(,)A F1(CHECK {})2.5 E F0(,)A F1(UNITCHECK {}) 2.5 E F0 2.5(,a)C(nd)-2.5 E F1(END {})2.5 E F0(constructs.)2.5 E .604 (Starting with Perl 5.14,)128 232.8 R F1(shift)3.104 E F0 .604(can tak) 3.104 F 3.104(eas)-.1 G(calar)-3.104 E F2(EXPR)3.104 E F0 3.105(,w)C .605(hich must hold a reference to an unblessed)-3.105 F(array)128 244.8 Q 5.724(.T)-.65 G .723(he ar)-5.724 F .723 (gument will be dereferenced automatically)-.18 F 5.723(.T)-.65 G .723 (his aspect of)-5.723 F F1(shift)3.223 E F0 .723(is considered highly) 3.223 F -.15(ex)128 256.8 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E .705(See also)128 274.8 R F1(unshift)3.205 E F0(,)A F1(push)3.205 E F0 3.205(,a)C(nd)-3.205 E F1(pop)3.205 E F0(.)A F1(shift)5.705 E F0 (and)3.205 E F1(unshift)3.205 E F0 .706 (do the same thing to the left end of an)3.206 F(array that)128 286.8 Q F1(pop)2.5 E F0(and)2.5 E F1(push)2.5 E F0(do to the right end.)2.5 E (shmctl)108 303.6 Q F2(ID)2.5 E F0(,CMD,ARG)A(Calls the System V)128 315.6 Q F2(IPC)2.5 E F0(function shmctl.)2.5 E -1.1(Yo)5 G(u')1.1 E (ll probably ha)-.1 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay)-2.5 E F1 (use IPC::SysV;)152 333.6 Q F0 .739 (\214rst to get the correct constant de\214nitions.)128 351.6 R(If)5.739 E F2(CMD)3.239 E F0(is)3.239 E F1(IPC_STAT)3.239 E F0 3.239(,t)C(hen) -3.239 E F2(ARG)3.239 E F0 .738(must be a v)3.239 F .738(ariable that) -.25 F .046(will hold the returned)128 363.6 R F1(shmid_ds)2.547 E F0 2.547(structure. Returns)2.547 F(lik)2.547 E 2.547(ei)-.1 G(octl:)-2.547 E F1(undef)2.547 E F0 .047(for error; ")2.547 F F1(0)A F0 -.2(bu)2.547 G 2.547(tt).2 G .047(rue" for zero;)-2.547 F 4.442 (and the actual return v)128 375.6 R 4.441(alue otherwise.)-.25 F 4.441 (See also `)9.441 F(`SysV)-.74 E F2(IPC)6.941 E F0 5.921 -.74('' i)D 6.941(np).74 G 4.441(erlipc and)-6.941 F F1(IPC::SysV)6.941 E F0 (documentation.)128 387.6 Q(shmget)108 404.4 Q F2(KEY)2.5 E F0 (,SIZE,FLA)A(GS)-.4 E .337(Calls the System V)128 416.4 R F2(IPC)2.837 E F0 .337(function shmget.)2.837 F .337(Returns the shared memory se)5.337 F .337(gment id, or)-.15 F F1(undef)2.838 E F0 .338(on error)2.838 F(.) -.55 E(See also `)128 428.4 Q(`SysV)-.74 E F2(IPC)2.5 E F0 1.48 -.74 ('' i)D 2.5(np).74 G(erlipc and)-2.5 E F1(IPC::SysV)2.5 E F0 (documentation.)2.5 E(shmread)108 445.2 Q F2(ID)2.5 E F0(,V)A (AR,POS,SIZE)-1.35 E(shmwrite)108 457.2 Q F2(ID)2.5 E F0 (,STRING,POS,SIZE)A 1.126(Reads or writes the System V shared memory se) 128 469.2 R(gment)-.15 E F2(ID)3.625 E F0 1.125(starting at position) 3.625 F F2(POS)3.625 E F0 1.125(for size)3.625 F F2(SIZE)3.625 E F0(by) 3.625 E .336(attaching to it, cop)128 481.2 R .336 (ying in/out, and detaching from it.)-.1 F .336(When reading,)5.336 F F2 -1.215(VA)2.836 G(R)1.215 E F0 .337(must be a v)2.836 F .337 (ariable that will)-.25 F .672(hold the data read.)128 493.2 R .671 (When writing, if)5.672 F F2(STRING)3.171 E F0 .671(is too long, only) 3.171 F F2(SIZE)3.171 E F0 .671(bytes are used; if)3.171 F F2(STRING) 3.171 E F0 .671(is too)3.171 F .157 (short, nulls are written to \214ll out)128 505.2 R F2(SIZE)2.658 E F0 2.658(bytes. Return)2.658 F .158(true if successful, f)2.658 F .158 (alse on error)-.1 F(.)-.55 E/F3 10/Times-Italic@0 SF(shmr)5.158 E (ead\(\))-.37 E F0(taints)2.658 E .009(the v)128 517.2 R .008 (ariable. See also `)-.25 F(`SysV)-.74 E F2(IPC)2.508 E F0 1.488 -.74 ('' i)D 2.508(np).74 G(erlipc,)-2.508 E F1(IPC::SysV)2.508 E F0 2.508 (,a)C .008(nd the)-2.508 F F1(IPC::Shareable)2.508 E F0 .008 (module from)2.508 F F2(CP)128 529.2 Q(AN)-.828 E F0(.)A(shutdo)108 546 Q(wn)-.25 E F2(SOCKET)2.5 E F0(,HO)A(W)-.35 E .059(Shuts do)128 558 R .059(wn a sock)-.25 F .059(et connection in the manner indicated by)-.1 F F2(HO)2.56 E(W)-.315 E F0 2.56(,w)C .06 (hich has the same interpretation as)-2.56 F (in the syscall of the same name.)128 570 Q F1(shutdown\(SOCKET, 0\);) 152 588 Q 6(#I)24 G(/we have stopped reading data)-6 E (shutdown\(SOCKET, 1\);)152 600 Q 6(#I)24 G (/we have stopped writing data)-6 E(shutdown\(SOCKET, 2\);)152 612 Q 6 (#I)24 G(/we have stopped using this socket)-6 E F0 1.49 (This is useful with sock)128 630 R 1.49(ets when you w)-.1 F 1.49 (ant to tell the other side you')-.1 F 1.49(re done writing b)-.5 F 1.49 (ut not done)-.2 F 2.352(reading, or vice v)128 642 R 4.852(ersa. It') -.15 F 4.852(sa)-.55 G 2.352 (lso a more insistent form of close because it also disables the \214le) -4.852 F(descriptor in an)128 654 Q 2.5(yf)-.15 G(ork)-2.5 E (ed copies in other processes.)-.1 E(Returns)128 672 Q F1(1)2.667 E F0 .167(for success; on error)2.667 F 2.667(,r)-.4 G(eturns)-2.667 E F1 (undef)2.667 E F0 .167(if the \214rst ar)2.667 F .166(gument is not a v) -.18 F .166(alid \214lehandle, or returns)-.25 F F1(0)128 684 Q F0 (and sets)2.5 E F1($!)2.5 E F0(for an)2.5 E 2.5(yo)-.15 G(ther f)-2.5 E (ailure.)-.1 E(sin)108 700.8 Q F2(EXPR)2.5 E F0(sin)108 712.8 Q (Returns the sine of)128 712.8 Q F2(EXPR)2.5 E F0(\(e)2.5 E (xpressed in radians\).)-.15 E(If)5 E F2(EXPR)2.5 E F0 (is omitted, returns sine of)2.5 E F1($_)2.5 E F0(.)A -.15(Fo)128 730.8 S 2.5(rt).15 G(he in)-2.5 E -.15(ve)-.4 G (rse sine operation, you may use the).15 E F1(Math::Trig::asin)2.5 E F0 (function, or use this relation:)2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 70)162.62 F 0 Cg EP %%Page: 71 71 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (sub asin { atan2\($_[0], sqrt\(1 \255 $_[0] * $_[0]\)\) })152 84 Q F0 (sleep)108 100.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0(sleep)108 112.8 Q .469(Causes the script to sleep for \(inte)128 124.8 R(ger\))-.15 E F2 (EXPR)2.969 E F0 .469(seconds, or fore)2.969 F -.15(ve)-.25 G 2.969(ri) .15 G 2.969(fn)-2.969 G 2.969(oa)-2.969 G -.18(rg)-2.969 G .469 (ument is gi).18 F -.15(ve)-.25 G 2.97(n. Returns).15 F(the)2.97 E(inte) 128 136.8 Q(ger number of seconds actually slept.)-.15 E (May be interrupted if the process recei)128 154.8 Q -.15(ve)-.25 G 2.5 (sas).15 G(ignal such as)-2.5 E F1(SIGALRM)2.5 E F0(.)A F1(eval {)152 172.8 Q(local $SIG{ALARM} = sub { die "Alarm!\\n" };)176 184.8 Q(sleep;) 176 196.8 Q(};)152 208.8 Q(die $@ unless $@ eq "Alarm!\\n";)152 220.8 Q F0 -1.1(Yo)128 238.8 S 4.622(up)1.1 G 2.122(robably cannot mix)-4.622 F F1(alarm)4.622 E F0(and)4.622 E F1(sleep)4.622 E F0 2.121 (calls, because)4.622 F F1(sleep)4.621 E F0 2.121 (is often implemented using)4.621 F F1(alarm)128 250.8 Q F0(.)A .7(On s\ ome older systems, it may sleep up to a full second less than what you \ requested, depending on)128 268.8 R(ho)128 280.8 Q 2.631(wi)-.25 G 2.631 (tc)-2.631 G .131(ounts seconds.)-2.631 F .131(Most modern systems al) 5.131 F -.1(wa)-.1 G .131(ys sleep the full amount.).1 F(The)5.13 E 2.63 (ym)-.15 G .13(ay appear to sleep)-2.63 F 2.812(longer than that, ho)128 292.8 R(we)-.25 E -.15(ve)-.25 G 3.612 -.4(r, b).15 H 2.812 (ecause your process might not be scheduled right a).4 F -.1(wa)-.15 G 5.312(yi).1 G 5.312(nab)-5.312 G(usy)-5.512 E(multitasking system.)128 304.8 Q -.15(Fo)128 322.8 S 3.844(rd).15 G 1.344 (elays of \214ner granularity than one second, the T)-3.844 F 1.344 (ime::HiRes module \(from)-.35 F F2(CP)3.844 E(AN)-.828 E F0 3.844(,a)C 1.343(nd starting)-3.844 F 2.024 (from Perl 5.8 part of the standard distrib)128 334.8 R 2.025 (ution\) pro)-.2 F(vides)-.15 E/F3 10/Times-Italic@0 SF(usleep\(\))4.525 E F0 7.025(.Y)C 2.025(ou may also use Perl')-8.125 F 4.525(sf)-.55 G (our)-4.525 E(-)-.2 E(ar)128 346.8 Q .816(gument v)-.18 F .816 (ersion of)-.15 F F3(select\(\))3.316 E F0(lea)3.316 E .816 (ving the \214rst three ar)-.2 F .815 (guments unde\214ned, or you might be able to use)-.18 F(the)128 358.8 Q F1(syscall)2.5 E F0(interf)2.5 E(ace to access)-.1 E F3(setitimer)2.5 E F0(\(2\) if your system supports it. See perlf)1.666 E(aq8 for details.) -.1 E(See also the)128 376.8 Q F2(POSIX)2.5 E F0(module')2.5 E(s)-.55 E F1(pause)2.5 E F0(function.)2.5 E(sock)108 393.6 Q(et)-.1 E F2(SOCKET) 2.5 E F0(,DOMAIN,TYPE,PR)A -1.88 -.4(OT O)-.4 H(COL).4 E 1.787 (Opens a sock)128 405.6 R 1.788 (et of the speci\214ed kind and attaches it to \214lehandle)-.1 F F2 (SOCKET)4.288 E F0(.)A F2(DOMAIN)6.788 E F0(,)A F2(TYPE)4.288 E F0 4.288 (,a)C(nd)-4.288 E F2(PR)128 417.6 Q -1.692 -.36(OT O)-.36 H(COL).36 E F0 1.086(are speci\214ed the same as for the syscall of the same name.) 3.586 F -1.1(Yo)6.085 G 3.585(us)1.1 G(hould)-3.585 E F1 1.085 (use Socket)3.585 F F0 4.986 (\214rst to get the proper de\214nitions imported.)128 429.6 R 4.986 (See the e)9.986 F 4.986(xamples in `)-.15 F(`Sock)-.74 E 4.986 (ets: Client/Serv)-.1 F(er)-.15 E(Communication')128 441.6 Q 2.5('i)-.74 G 2.5(np)-2.5 G(erlipc.)-2.5 E 1.179 (On systems that support a close-on-e)128 459.6 R -.15(xe)-.15 G 3.679 <638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.679 F 1.178(wly opened \214le)-.25 F(descriptor)128 471.6 Q 2.5(,a) -.4 G 2.5(sd)-2.5 G(etermined by the v)-2.5 E(alue of $^F)-.25 E 5(.S) -.8 G(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E(ar) -.25 E(.)-.55 E(sock)108 488.4 Q(etpair)-.1 E F2(SOCKET1)2.5 E F0 (,SOCKET2,DOMAIN,TYPE,PR)A -1.88 -.4(OT O)-.4 H(COL).4 E .955 (Creates an unnamed pair of sock)128 500.4 R .955 (ets in the speci\214ed domain, of the speci\214ed type.)-.1 F F2 (DOMAIN)5.956 E F0(,)A F2(TYPE)3.456 E F0(,)A(and)128 512.4 Q F2(PR) 3.067 E -1.692 -.36(OT O)-.36 H(COL).36 E F0 .567 (are speci\214ed the same as for the syscall of the same name.)3.067 F .566(If unimplemented, raises)5.567 F(an e)128 524.4 Q 2.5 (xception. Returns)-.15 F(true if successful.)2.5 E 1.178 (On systems that support a close-on-e)128 542.4 R -.15(xe)-.15 G 3.678 <638d>.15 G 1.178(ag on \214les, the \215ag will be set for the ne) -3.678 F 1.179(wly opened \214le)-.25 F (descriptors, as determined by the v)128 554.4 Q(alue of $^F)-.25 E 5 (.S)-.8 G(ee `)-5 E(`$^F')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlv)-2.5 E (ar)-.25 E(.)-.55 E 1.249(Some systems de\214ned)128 572.4 R F1(pipe) 3.749 E F0 1.249(in terms of)3.749 F F1(socketpair)3.749 E F0 3.749(,i)C 3.749(nw)-3.749 G 1.248(hich a call to)-3.749 F F1 1.248 (pipe\(Rdr, Wtr\))3.748 F F0(is)3.748 E(essentially:)128 584.4 Q F1 (use Socket;)152 602.4 Q (socketpair\(Rdr, Wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC\);)152 614.4 Q (shutdown\(Rdr, 1\);)152 626.4 Q 6(#n)48 G 6(om)-6 G (ore writing for reader)-6 E(shutdown\(Wtr, 0\);)152 638.4 Q 6(#n)48 G 6 (om)-6 G(ore reading for writer)-6 E F0 1.786(See perlipc for an e)128 656.4 R 1.787(xample of sock)-.15 F 1.787(etpair use.)-.1 F 1.787 (Perl 5.8 and later will emulate sock)6.787 F 1.787(etpair using)-.1 F F2(IP)4.287 E F0(sock)128 668.4 Q (ets to localhost if your system implements sock)-.1 E(ets b)-.1 E (ut not sock)-.2 E(etpair)-.1 E(.)-.55 E(sort)108 685.2 Q F2(SUBN)2.5 E .25(AME LIST)-.315 F F0(sort)108 697.2 Q F2 .25(BLOCK LIST)2.5 F F0 (perl v5.14.2)72 768 Q 198.17(2011-10-01 71)162.62 F 0 Cg EP %%Page: 72 72 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(sort)108 84 Q/F1 9 /Times-Roman@0 SF(LIST)2.5 E F0 .489(In list conte)128 96 R .489 (xt, this sorts the)-.15 F F1(LIST)2.989 E F0 .489 (and returns the sorted list v)2.989 F 2.989(alue. In)-.25 F .489 (scalar conte)2.989 F .489(xt, the beha)-.15 F .488(viour of)-.2 F/F2 10 /Courier@0 SF(sort\(\))128 108 Q F0(is unde\214ned.)2.5 E(If)128 126 Q F1(SUBN)4.395 E(AME)-.315 E F0(or)4.395 E F1(BLOCK)4.395 E F0 1.895 (is omitted,)4.395 F F2(sort)4.395 E F0 4.395(si)C 4.396(ns)-4.395 G 1.896(tandard string comparison order)-4.396 F 6.896(.I)-.55 G(f)-6.896 E F1(SUBN)4.396 E(AME)-.315 E F0(is)4.396 E .159(speci\214ed, it gi)128 138 R -.15(ve)-.25 G 2.659(st).15 G .159 (he name of a subroutine that returns an inte)-2.659 F .158 (ger less than, equal to, or greater than)-.15 F F2(0)2.658 E F0(,)A 2.153(depending on ho)128 150 R 4.653(wt)-.25 G 2.153 (he elements of the list are to be ordered.)-4.653 F(\(The)7.154 E F2 (<=>)4.654 E F0(and)4.654 E F2(cmp)4.654 E F0 2.154(operators are)4.654 F -.15(ex)128 162 S 1.873(tremely useful in such routines.\)).15 F F1 (SUBN)6.873 E(AME)-.315 E F0 1.873(may be a scalar v)4.373 F 1.872 (ariable name \(unsubscripted\), in)-.25 F .322(which case the v)128 174 R .322(alue pro)-.25 F .323 (vides the name of \(or a reference to\) the actual subroutine to use.) -.15 F .323(In place of)5.323 F(a)128 186 Q F1(SUBN)2.5 E(AME)-.315 E F0 2.5(,y)C(ou can pro)-2.5 E(vide a)-.15 E F1(BLOCK)2.5 E F0(as an anon) 2.5 E(ymous, in-line sort subroutine.)-.15 E .538(If the subroutine')128 204 R 3.038(sp)-.55 G .538(rototype is)-3.038 F F2(\($$\))3.038 E F0 3.038(,t)C .538(he elements to be compared are passed by reference in) -3.038 F F2(@_)3.037 E F0 3.037(,a)C(s)-3.037 E 1.85 (for a normal subroutine.)128 216 R 1.851(This is slo)6.85 F 1.851 (wer than unprototyped subroutines, where the elements to be)-.25 F 1.585(compared are passed into the subroutine as the package global v) 128 228 R(ariables)-.25 E F2($a)4.084 E F0(and)4.084 E F2($b)4.084 E F0 1.584(\(see e)4.084 F(xample)-.15 E(belo)128 240 Q 3.481(w\). Note)-.25 F .982(that in the latter case, it is usually highly counter)3.481 F (-producti)-.2 E 1.282 -.15(ve t)-.25 H 3.482(od).15 G(eclare)-3.482 E F2($a)3.482 E F0(and)3.482 E F2($b)3.482 E F0(as)3.482 E(le)128 252 Q (xicals.)-.15 E(The v)128 270 Q(alues to be compared are al)-.25 E -.1 (wa)-.1 G(ys passed by reference and should not be modi\214ed.).1 E -1.1 (Yo)128 288 S 4.549(ua)1.1 G 2.049(lso cannot e)-4.549 F 2.049 (xit out of the sort block or subroutine using an)-.15 F 4.549(yo)-.15 G 4.549(ft)-4.549 G 2.048(he loop control operators)-4.549 F (described in perlsyn or with)128 300 Q F2(goto)2.5 E F0(.)A(When)128 318 Q F2 1.009(use locale)3.509 F F0 1.009(is in ef)3.509 F(fect,)-.25 E F2 1.009(sort LIST)3.509 F F0(sorts)3.509 E F1(LIST)3.509 E F0 1.01 (according to the current collation locale.)3.51 F(See perllocale.)128 330 Q/F3 10/Times-Italic@0 SF(sort\(\))128 348 Q F0 .291 (returns aliases into the original list, much as a for loop')2.791 F 2.79(si)-.55 G(nde)-2.79 E 2.79(xv)-.15 G .29 (ariable aliases the list elements.)-3.04 F .255 (That is, modifying an element of a list returned by)128 360 R F3 (sort\(\))2.755 E F0 .255(\(for e)2.755 F .255(xample, in a)-.15 F F2 (foreach)2.755 E F0(,)A F2(map)2.755 E F0(or)2.755 E F2(grep)2.755 E F0 (\))A 2.068(actually modi\214es the element in the original list.)128 372 R 2.068(This is usually something to be a)7.068 F -.2(vo)-.2 G 2.068 (ided when).2 F(writing clear code.)128 384 Q .862 (Perl 5.6 and earlier used a quicksort algorithm to implement sort.)128 402 R .863(That algorithm w)5.863 F .863(as not stable, so)-.1 F F3 (could)128 414 Q F0 .093(go quadratic.)2.593 F(\(A)5.093 E F3(stable) 2.593 E F0 .093(sort preserv)2.593 F .093 (es the input order of elements that compare equal.)-.15 F(Although) 5.092 E(quicksort')128 426 Q 2.644(sr)-.55 G .144 (un time is O\(NlogN\) when a)-2.644 F -.15(ve)-.2 G .145(raged o).15 F -.15(ve)-.15 G 2.645(ra).15 G .145 (ll arrays of length N, the time can be O\(N**2\),)-2.645 F F3(quadr)128 438 Q(atic)-.15 E F0(beha)2.886 E(vior)-.2 E 2.886(,f)-.4 G .386 (or some inputs.\))-2.886 F .386(In 5.7, the quicksort implementation w) 5.386 F .385(as replaced with a stable)-.1 F(mer)128 450 Q .027 (gesort algorithm whose w)-.18 F .027(orst-case beha)-.1 F .027 (vior is O\(NlogN\).)-.2 F .028(But benchmarks indicated that for some) 5.028 F .435(inputs, on some platforms, the original quicksort w)128 462 R .435(as f)-.1 F(aster)-.1 E 5.435(.5)-.55 G .435 (.8 has a sort pragma for limited control)-5.435 F .784(of the sort.)128 474 R .785(Its rather blunt control of the underlying algorithm may not\ persist into future Perls, b)5.784 F(ut)-.2 E .212(the ability to char\ acterize the input or output in implementation independent w)128 486 R .212(ays quite probably will.)-.1 F(See the sort pragma.)128 498 Q (Examples:)128 516 Q F2 6(#s)152 534 S(ort lexically)-6 E (@articles = sort @files;)152 546 Q 6(#s)152 570 S (ame thing, but with explicit sort routine)-6 E (@articles = sort {$a cmp $b} @files;)152 582 Q 6(#n)152 606 S (ow case\255insensitively)-6 E (@articles = sort {uc\($a\) cmp uc\($b\)} @files;)152 618 Q 6(#s)152 642 S(ame thing in reversed order)-6 E(@articles = sort {$b cmp $a} @files;) 152 654 Q 6(#s)152 678 S(ort numerically ascending)-6 E (@articles = sort {$a <=> $b} @files;)152 690 Q 6(#s)152 714 S (ort numerically descending)-6 E(@articles = sort {$b <=> $a} @files;) 152 726 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 72)162.62 F 0 Cg EP %%Page: 73 73 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#t)152 96 S(his sorts the %age hash by value instead of key)-6 E 6(#u) 152 108 S(sing an in\255line function)-6 E (@eldest = sort { $age{$b} <=> $age{$a} } keys %age;)152 120 Q 6(#s)152 144 S(ort using explicit subroutine name)-6 E(sub byage {)152 156 Q ($age{$a} <=> $age{$b};)152 168 Q 6(#p)12 G(resuming numeric)-6 E(})152 180 Q(@sortedclass = sort byage @class;)152 192 Q (sub backwards { $b cmp $a })152 216 Q 6(@harry =)152 228 R (qw\(dog cat x Cain Abel\);)6 E (@george = qw\(gone chased yz Punished Axed\);)152 240 Q (print sort @harry;)152 252 Q 6(#p)176 264 S(rints AbelCaincatdogx)-6 E (print sort backwards @harry;)152 276 Q 6(#p)176 288 S (rints xdogcatCainAbel)-6 E(print sort @george, \010to\010, @harry;)152 300 Q 6(#p)176 312 S(rints AbelAxedCainPunishedcatchaseddoggonetoxyz)-6 E 6(#i)152 336 S(nefficiently sort by descending numeric compare using) -6 E 6(#t)152 348 S(he first integer after the first = sign, or the)-6 E 6(#w)152 360 S(hole record case\255insensitively otherwise)-6 E (my @new = sort {)152 384 Q (\($b =~ /=\(\\d+\)/\)[0] <=> \($a =~ /=\(\\d+\)/\)[0])176 396 Q(||)200 408 Q 6(uc\($a\) cmp uc\($b\))176 420 R 6(}@)152 432 S(old;)-6 E 6(#s) 152 456 S(ame thing, but much more efficiently;)-6 E 6(#w)152 468 S (e\010ll build auxiliary indices instead)-6 E 6(#f)152 480 S(or speed)-6 E(my @nums = @caps = \(\);)152 492 Q(for \(@old\) {)152 504 Q (push @nums, \( /=\(\\d+\)/ ? $1 : undef \);)176 516 Q (push @caps, uc\($_\);)176 528 Q(})152 540 Q(my @new = @old[ sort {)152 564 Q($nums[$b] <=> $nums[$a])176 576 Q(||)200 588 Q ($caps[$a] cmp $caps[$b])176 600 Q 6(}0)176 612 S(..$#old)-6 E(];)152 624 Q 6(#s)152 648 S(ame thing, but without any temps)-6 E (@new = map { $_\255>[0] })152 660 Q(sort { $b\255>[1] <=> $a\255>[1]) 194 672 Q(||)218 684 Q($a\255>[2] cmp $b\255>[2])194 696 Q 6(}m)152 708 S(ap { [$_, /=\(\\d+\)/, uc\($_\)] } @old;)-6 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 73)162.62 F 0 Cg EP %%Page: 74 74 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(#u)152 84 S (sing a prototype allows you to use any comparison subroutine)-6 E 6(#a) 152 96 S 6(sas)-6 G (ort subroutine \(including other package\010s subroutines\))-6 E (package other;)152 108 Q(sub backwards \($$\) { $_[1] cmp $_[0]; })152 120 Q 6(#$)12 G 6(aa)-6 G(nd $b are not set here)-6 E(package main;)152 144 Q(@new = sort other::backwards @old;)152 156 Q 6(#g)152 180 S (uarantee stability, regardless of algorithm)-6 E (use sort \010stable\010;)152 192 Q (@new = sort { substr\($a, 3, 5\) cmp substr\($b, 3, 5\) } @old;)152 204 Q 6(#f)152 228 S (orce use of mergesort \(not portable outside Perl 5.8\))-6 E (use sort \010_mergesort\010;)152 240 Q 6(#n)12 G(ote discouraging _)-6 E(@new = sort { substr\($a, 3, 5\) cmp substr\($b, 3, 5\) } @old;)152 252 Q F0 -.8(Wa)128 270 S .142(rning: syntactical care is required when\ sorting the list returned from a function. If you w).8 F .143 (ant to sort)-.1 F(the list returned by the function call)128 282 Q F1 (find_records\(@key\))2.5 E F0 2.5(,y)C(ou can use:)-2.5 E F1 (@contact = sort { $a cmp $b } find_records @key;)152 300 Q (@contact = sort +find_records\(@key\);)152 312 Q (@contact = sort &find_records\(@key\);)152 324 Q (@contact = sort\(find_records\(@key\)\);)152 336 Q F0 .295 (If instead you w)128 354 R .295(ant to sort the array)-.1 F F1(@key) 2.795 E F0 .294(with the comparison routine)2.795 F F1(find_records\(\)) 2.794 E F0 .294(then you)2.794 F(can use:)128 366 Q F1 (@contact = sort { find_records\(\) } @key;)152 384 Q (@contact = sort find_records\(@key\);)152 396 Q (@contact = sort\(find_records @key\);)152 408 Q (@contact = sort\(find_records \(@key\)\);)152 420 Q F0 1.045(If you') 128 438 R 1.045(re using strict, you)-.5 F/F2 10/Times-Italic@0 SF 1.045 (must not)3.545 F F0(declare)3.545 E F1($a)3.545 E F0(and)3.545 E F1($b) 3.545 E F0 1.045(as le)3.545 F 3.546(xicals. The)-.15 F 3.546(ya)-.15 G 1.046(re package globals.)-3.546 F(That)6.046 E(means that if you')128 450 Q(re in the)-.5 E F1(main)2.5 E F0(package and type)2.5 E F1 (@articles = sort {$b <=> $a} @files;)152 468 Q F0(then)128 486 Q F1($a) 2.793 E F0(and)2.793 E F1($b)2.793 E F0(are)2.793 E F1($main::a)2.793 E F0(and)2.793 E F1($main::b)2.792 E F0(\(or)2.792 E F1($::a)2.792 E F0 (and)2.792 E F1($::b)2.792 E F0 .292(\), b)B .292(ut if you')-.2 F .292 (re in the)-.5 F F1(FooPack)2.792 E F0(package, it')128 498 Q 2.5(st) -.55 G(he same as typing)-2.5 E F1 (@articles = sort {$FooPack::b <=> $FooPack::a} @files;)152 516 Q F0 1.317(The comparison function is required to beha)128 534 R -.15(ve)-.2 G 6.317(.I).15 G 3.817(fi)-6.317 G 3.817(tr)-3.817 G 1.317 (eturns inconsistent results \(sometimes saying)-3.817 F F1($x[1])128 546 Q F0 .537(is less than)3.037 F F1($x[2])3.037 E F0 .536 (and sometimes saying the opposite, for e)3.036 F .536 (xample\) the results are not well-)-.15 F(de\214ned.)128 558 Q(Because) 128 576 Q F1(<=>)3.985 E F0(returns)3.985 E F1(undef)3.985 E F0 1.485 (when either operand is)3.985 F F1(NaN)3.985 E F0 1.486 (\(not-a-number\), and laso because)3.986 F F1(sort)3.986 E F0 2.17 (raises an e)128 588 R 2.17(xception unless the result of a comparison \ is de\214ned, be careful when sorting with a)-.15 F 1.137 (comparison function lik)128 600 R(e)-.1 E F1 1.137($a <=> $b)3.637 F F0 (an)3.637 E 3.637(yl)-.15 G 1.137(ists that might contain a)-3.637 F F1 (NaN)3.638 E F0 6.138(.T)C 1.138(he follo)-6.138 F 1.138(wing e)-.25 F (xample)-.15 E(tak)128 612 Q(es adv)-.1 E(antage that)-.25 E F1 (NaN != NaN)2.5 E F0(to eliminate an)2.5 E(y)-.15 E F1(NaN)2.5 E F0 2.5 (sf)C(rom the input list.)-2.5 E F1 (@result = sort { $a <=> $b } grep { $_ == $_ } @input;)152 630 Q F0 (splice)108 646.8 Q/F3 9/Times-Roman@0 SF(ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR)2.5 E F0(,OFFSET)A(,LENGTH,LIST)-.74 E(splice)108 658.8 Q F3 (ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR)2.5 E F0(,OFFSET)A(,LENGTH) -.74 E(splice)108 670.8 Q F3(ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR) 2.5 E F0(,OFFSET)A(splice)108 682.8 Q F3(ARRA)2.5 E(Y)-.945 E F0(or)2.5 E F3(EXPR)2.5 E F0(Remo)128 694.8 Q -.15(ve)-.15 G 2.876(st).15 G .376 (he elements designated by)-2.876 F F3(OFFSET)2.876 E F0(and)2.876 E F3 (LENGTH)2.875 E F0 .375(from an array)2.875 F 2.875(,a)-.65 G .375 (nd replaces them with the)-2.875 F 1.943(elements of)128 706.8 R F3 (LIST)4.443 E F0 4.443(,i)C 4.443(fa)-4.443 G -.15(ny)-4.443 G 6.943(.I) -.5 G 4.443(nl)-6.943 G 1.943(ist conte)-4.443 F 1.943 (xt, returns the elements remo)-.15 F -.15(ve)-.15 G 4.443(df).15 G 1.943(rom the array)-4.443 F 6.944(.I)-.65 G 4.444(ns)-6.944 G(calar) -4.444 E(conte)128 718.8 Q .437(xt, returns the last element remo)-.15 F -.15(ve)-.15 G .436(d, or).15 F F1(undef)2.936 E F0 .436 (if no elements are remo)2.936 F -.15(ve)-.15 G 2.936(d. The).15 F .436 (array gro)2.936 F .436(ws or)-.25 F .045(shrinks as necessary)128 730.8 R 5.045(.I)-.65 G(f)-5.045 E F3(OFFSET)2.545 E F0 .045(is ne)2.545 F -.05(ga)-.15 G(ti).05 E .345 -.15(ve t)-.25 H .045(hen it starts that f) .15 F .046(ar from the end of the array)-.1 F 5.046(.I)-.65 G(f)-5.046 E F3(LENGTH)2.546 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 74)162.62 F 0 Cg EP %%Page: 75 75 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .811 (is omitted, remo)128 84 R -.15(ve)-.15 G 3.31(se).15 G -.15(ve)-3.56 G .81(rything from).15 F/F1 9/Times-Roman@0 SF(OFFSET)3.31 E F0(onw)3.31 E 3.31(ard. If)-.1 F F1(LENGTH)3.31 E F0 .81(is ne)3.31 F -.05(ga)-.15 G (ti).05 E -.15(ve)-.25 G 3.31(,r).15 G(emo)-3.31 E -.15(ve)-.15 G 3.31 (st).15 G .81(he elements)-3.31 F(from)128 96 Q F1(OFFSET)3.791 E F0 (onw)3.791 E 1.291(ard e)-.1 F 1.291 (xcept for \255LENGTH elements at the end of the array)-.15 F 6.292(.I) -.65 G 3.792(fb)-6.292 G(oth)-3.792 E F1(OFFSET)3.792 E F0(and)3.792 E F1(LENGTH)128 108 Q F0 2.269(are omitted, remo)4.769 F -.15(ve)-.15 G 4.769(se).15 G -.15(ve)-5.019 G 2.269(rything. If).15 F F1(OFFSET)4.769 E F0 2.269(is past the end of the array)4.769 F 4.768(,P)-.65 G 2.268 (erl issues a)-4.768 F -.1(wa)128 120 S (rning, and splices at the end of the array).1 E(.)-.65 E(The follo)128 138 Q(wing equi)-.25 E -.25(va)-.25 G(lences hold \(assuming).25 E/F2 10 /Courier@0 SF($[ == 0 and $#a >= $i)2.5 E F0(\))2.5 E F2 30 (push\(@a,$x,$y\) splice\(@a,@a,0,$x,$y\))152 156 R 72 (pop\(@a\) splice\(@a,\2551\))152 168 R 60(shift\(@a\) splice\(@a,0,1\)) 152 180 R 12(unshift\(@a,$x,$y\) splice\(@a,0,0,$x,$y\))152 192 R ($a[$i] = $y)152 204 Q(splice\(@a,$i,1,$y\))54 E F0 (Example, assuming array lengths are passed before arrays:)128 222 Q F2 (sub aeq {)152 240 Q 6(#c)12 G(ompare two list values)-6 E (my\(@a\) = splice\(@_,0,shift\);)176 252 Q (my\(@b\) = splice\(@_,0,shift\);)176 264 Q(return 0 unless @a == @b;) 176 276 Q 6(#s)12 G(ame len?)-6 E(while \(@a\) {)176 288 Q (return 0 if pop\(@a\) ne pop\(@b\);)200 300 Q(})176 312 Q(return 1;)176 324 Q(})152 336 Q(if \(&aeq\($len,@foo[1..$len],0+@bar,@bar\)\) { ... }) 152 348 Q F0 .701(Starting with Perl 5.14,)128 366 R F2(splice)3.201 E F0 .701(can tak)3.201 F 3.201(es)-.1 G(calar)-3.201 E F1(EXPR)3.201 E F0 3.201(,w)C .701(hich must hold a reference to an unblessed)-3.201 F (array)128 378 Q 5.262(.T)-.65 G .262(he ar)-5.262 F .262 (gument will be dereferenced automatically)-.18 F 5.262(.T)-.65 G .261 (his aspect of)-5.262 F F2(splice)2.761 E F0 .261(is considered highly) 2.761 F -.15(ex)128 390 S 2.5(perimental. The).15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(split /P)108 406.8 Q -1.11(AT)-.92 G(TERN/,EXPR,LIMIT)1.11 E (split /P)108 418.8 Q -1.11(AT)-.92 G(TERN/,EXPR)1.11 E(split /P)108 430.8 Q -1.11(AT)-.92 G(TERN/)1.11 E(split)108 442.8 Q .798 (Splits the string)128 454.8 R F1(EXPR)3.298 E F0 .799 (into a list of strings and returns that list.)3.298 F .799(By def)5.799 F .799(ault, empty leading \214elds are)-.1 F(preserv)128 466.8 Q 1.718 (ed, and empty trailing ones are deleted.)-.15 F 1.718 (\(If all \214elds are empty)6.718 F 4.218(,t)-.65 G(he)-4.218 E 4.218 (ya)-.15 G 1.718(re considered to be)-4.218 F(trailing.\))128 478.8 Q (In scalar conte)128 496.8 Q(xt, returns the number of \214elds found.) -.15 E(If)128 514.8 Q F1(EXPR)4.444 E F0 1.944(is omitted, splits the) 4.444 F F2($_)4.444 E F0 4.445(string. If)4.444 F F1 -.828(PA)4.445 G (TTERN)-.171 E F0 1.945(is also omitted, splits on whitespace \(after) 4.445 F .611(skipping an)128 526.8 R 3.111(yl)-.15 G .611 (eading whitespace\).)-3.111 F(An)5.611 E .611(ything matching)-.15 F F1 -.828(PA)3.111 G(TTERN)-.171 E F0 .61(is tak)3.111 F .61 (en to be a delimiter separating)-.1 F(the \214elds.)128 538.8 Q (\(Note that the delimiter may be longer than one character)5 E(.\))-.55 E(If)128 556.8 Q F1(LIMIT)3.119 E F0 .619(is speci\214ed and positi) 3.119 F -.15(ve)-.25 G 3.119(,i).15 G 3.119(tr)-3.119 G .62 (epresents the maximum number of \214elds the)-3.119 F F1(EXPR)3.12 E F0 .62(will be split)3.12 F .781(into, though the actual number of \214eld\ s returned depends on the number of times)128 568.8 R F1 -.828(PA)3.28 G (TTERN)-.171 E F0(matches)3.28 E(within)128 580.8 Q F1(EXPR)2.77 E F0 5.27(.I)C(f)-5.27 E F1(LIMIT)2.77 E F0 .27(is unspeci\214ed or zero, tr\ ailing null \214elds are stripped \(which potential users of)2.77 F F2 (pop)128 592.8 Q F0 -.1(wo)2.557 G .057(uld do well to remember\).).1 F (If)5.057 E F1(LIMIT)2.557 E F0 .057(is ne)2.557 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 2.557(,i).15 G 2.556(ti)-2.557 G 2.556(st)-2.556 G .056 (reated as if an arbitrarily lar)-2.556 F(ge)-.18 E F1(LIMIT)2.556 E F0 (had)2.556 E .052(been speci\214ed.)128 604.8 R .053 (Note that splitting an)5.052 F F1(EXPR)2.553 E F0 .053(that e)2.553 F -.25(va)-.25 G .053(luates to the empty string al).25 F -.1(wa)-.1 G .053(ys returns the empty).1 F(list, re)128 616.8 Q -.05(ga)-.15 G (rdless of the).05 E F1(LIMIT)2.5 E F0(speci\214ed.)2.5 E 3.104(Ap)128 634.8 S .604(attern matching the empty string \(not to be confused with\ an empty pattern)-3.104 F F2(//)3.104 E F0 3.104(,w)C .603 (hich is just one)-3.104 F .518 (member of the set of patterns matching the epmty string\), splits)128 646.8 R F1(EXPR)3.018 E F0 .518(into indi)3.018 F .518 (vidual characters.)-.25 F -.15(Fo)5.518 G(r).15 E -.15(ex)128 658.8 S (ample:).15 E F2 (print join\(\010:\010, split\(/ */, \010hi there\010\)\), "\\n";)152 676.8 Q F0(produces the output 'h:i:t:h:e:r:e'.)128 694.8 Q .049 (As a special case for)128 712.8 R F2(split)2.549 E F0 2.549(,t)C .049 (he empty pattern)-2.549 F F2(//)2.549 E F0 .049 (speci\214cally matches the empty string; this is not be)2.549 F 1.255(\ confused with the normal use of an empty pattern to mean the last succe\ ssful match.)128 724.8 R 1.256(So to split a)6.256 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 75)162.62 F 0 Cg EP %%Page: 76 76 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(string into indi) 128 84 Q(vidual characters, the follo)-.25 E(wing:)-.25 E/F1 10 /Courier@0 SF (print join\(\010:\010, split\(//, \010hi there\010\)\), "\\n";)152 102 Q F0(produces the output 'h:i: :t:h:e:r:e'.)128 120 Q 1.854 (Empty leading \214elds are produced when there are positi)128 138 R -.15(ve)-.25 G 1.853(-width matches at the be).15 F 1.853 (ginning of the)-.15 F(string; a zero-width match at the be)128 150 Q (ginning of the string does not produce an empty \214eld. F)-.15 E(or e) -.15 E(xample:)-.15 E F1 (print join\(\010:\010, split\(/\(?=\\w\)/, \010hi there!\010\)\);)146 168 Q F0 .545(produces the output 'h:i :t:h:e:r:e!'. Empty trailing \ \214elds, on the other hand, are produced when there)128 186 R .563 (is a match at the end of the string \(and when)128 198 R/F2 9 /Times-Roman@0 SF(LIMIT)3.063 E F0 .563(is gi)3.063 F -.15(ve)-.25 G 3.063(na).15 G .563(nd is not 0\), re)-3.063 F -.05(ga)-.15 G .563 (rdless of the length of).05 F(the match.)128 210 Q -.15(Fo)5 G 2.5(re) .15 G(xample:)-2.65 E F1(print join\(\010:\010, split\(//,)146 228 Q (\010hi there!\010, \2551\)\), "\\n";)18 E(print join\(\010:\010, split\ \(/\\W/, \010hi there!\010, \2551\)\), "\\n";)146 240 Q F0 (produce the output 'h:i: :t:h:e:r:e:!:' and 'hi:there:', respecti)128 258 Q -.15(ve)-.25 G(ly).15 E 2.5(,b)-.65 G (oth with an empty trailing \214eld.)-2.5 E(The)128 276 Q F2(LIMIT)2.5 E F0(parameter can be used to split a line partially)2.5 E F1 (\($login, $passwd, $remainder\) = split\(/:/, $_, 3\);)152 294 Q F0 .059(When assigning to a list, if)128 312 R F2(LIMIT)2.559 E F0 .059 (is omitted, or zero, Perl supplies a)2.559 F F2(LIMIT)2.559 E F0 .059 (one lar)2.559 F .06(ger than the number)-.18 F 1.117(of v)128 324 R 1.117(ariables in the list, to a)-.25 F -.2(vo)-.2 G 1.117 (id unnecessary w).2 F 3.617(ork. F)-.1 F 1.116(or the list abo)-.15 F -.15(ve)-.15 G F2(LIMIT)3.766 E F0 -.1(wo)3.616 G 1.116(uld ha).1 F 1.416 -.15(ve b)-.2 H 1.116(een 4 by).15 F(def)128 336 Q 2.5(ault. In) -.1 F(time critical applications it behoo)2.5 E -.15(ve)-.15 G 2.5(sy) .15 G(ou not to split into more \214elds than you really need.)-2.5 E 3.177(If the)128 354 R F2 -.828(PA)5.677 G(TTERN)-.171 E F0 3.177(conta\ ins parentheses, additional list elements are created from each matchin\ g)5.677 F(substring in the delimiter)128 366 Q(.)-.55 E F1 (split\(/\([,\255]\)/, "1\25510,20", 3\);)152 384 Q F0 (produces the list v)128 402 Q(alue)-.25 E F1 (\(1, \010\255\010, 10, \010,\010, 20\))152 420 Q F0 .617 (If you had the entire header of a normal Unix email message in)128 438 R F1($header)3.116 E F0 3.116(,y)C .616(ou could split it up into)-3.116 F(\214elds and their v)128 450 Q(alues this w)-.25 E(ay:)-.1 E F1 ($header =~ s/\\n\(?=\\s\)//g;)152 468 Q 6(#f)12 G (ix continuation lines)-6 E 12(%hdrs =)152 480 R (\(UNIX_FROM => split /^\(\\S*?\):\\s*/m, $header\);)12 E F0 .342 (The pattern)128 498 R F1(/PATTERN/)2.842 E F0 .343 (may be replaced with an e)2.842 F .343 (xpression to specify patterns that v)-.15 F .343(ary at runtime.)-.25 F (\(T)128 510 Q 2.5(od)-.8 G 2.5(or)-2.5 G (untime compilation only once, use)-2.5 E F1(/$variable/o)2.5 E F0(.\))A .012(As a special case, specifying a)128 528 R F2 -.828(PA)2.512 G (TTERN)-.171 E F0 .012(of space \()2.512 F F1<08c22008>A F0 2.512(\)w)C .012(ill split on white space just as)-2.512 F F1(split)2.512 E F0(with) 2.512 E 1.025(no ar)128 540 R 1.025(guments does.)-.18 F(Thus,)6.025 E F1(split\(\010\302 \010\))3.525 E F0 1.025(can be used to emulate)3.525 F/F3 10/Times-Bold@0 SF(awk)3.526 E F0 2.126 -.55('s d)D(ef).55 E 1.026 (ault beha)-.1 F(vior)-.2 E 3.526(,w)-.4 G(hereas)-3.526 E F1 (split\(/\302 /\))128 552 Q F0 .308(will gi)2.808 F .608 -.15(ve y)-.25 H .308(ou as man).15 F 2.808(yi)-.15 G .307 (nitial null \214elds \(empty string\) as there are leading spaces.) -2.808 F(A)5.307 E F1(split)128 564 Q F0(on)3.281 E F1(/\\s+/)3.281 E F0 .781(is lik)3.281 F 3.281(ea)-.1 G F1(split\(\010\302 \010\))A F0 -.15 (ex)3.281 G .781(cept that an).15 F 3.281(yl)-.15 G .782 (eading whitespace produces a null \214rst)-3.281 F 2.5(\214eld. A)128 576 R F1(split)2.5 E F0(with no ar)2.5 E(guments really does a)-.18 E F1 (split\(\010\302 \010,\302 $_\))2.5 E F0(internally)2.5 E(.)-.65 E(A)128 594 Q F2 -.828(PA)2.5 G(TTERN)-.171 E F0(of)2.5 E F1(/^/)2.5 E F0 (is treated as if it were)2.5 E F1(/^/m)2.5 E F0 2.5(,s)C(ince it isn') -2.5 E 2.5(tm)-.18 G(uch use otherwise.)-2.5 E(Example:)128 612 Q F1 (open\(PASSWD, \010/etc/passwd\010\);)152 630 Q(while \(\) {)152 642 Q(chomp;)176 654 Q(\($login, $passwd, $uid, $gid,)176 666 Q ($gcos, $home, $shell\) = split\(/:/\);)182 678 Q(#...)176 690 Q(})152 702 Q F0 .506(As with re)128 720 R .506(gular pattern matching, an)-.15 F 3.006(yc)-.15 G .506(apturing parentheses that are not matched in a) -3.006 F F1(split\(\))3.006 E F0(will)3.006 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 76)162.62 F 0 Cg EP %%Page: 77 77 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(be set to)128 84 Q /F1 10/Courier@0 SF(undef)2.5 E F0(when returned:)2.5 E F1 (@fields = split /\(A\)|B/, "1A2B3";)152 102 Q 6(#@)152 114 S (fields is \(1, \010A\010, 2, undef, 3\))-6 E F0(sprintf)108 130.8 Q/F2 9/Times-Roman@0 SF(FORMA)2.5 E(T)-.999 E F0(,)A F2(LIST)2.5 E F0 .102 (Returns a string formatted by the usual)128 142.8 R F1(printf)2.602 E F0(con)2.602 E -.15(ve)-.4 G .102(ntions of the C library function).15 F F1(sprintf)2.602 E F0 5.102(.S)C(ee)-5.102 E(belo)128 154.8 Q 3.194(wf) -.25 G .694(or more details and see)-3.194 F F1(sprintf\(3\))3.193 E F0 (or)3.193 E F1(printf\(3\))3.193 E F0 .693(on your system for an e)3.193 F .693(xplanation of)-.15 F(the general principles.)128 166.8 Q -.15(Fo) 128 184.8 S 2.5(re).15 G(xample:)-2.65 E F1 6(#F)176 202.8 S (ormat number with up to 8 leading zeroes)-6 E ($result = sprintf\("%08d", $number\);)176 214.8 Q 6(#R)176 238.8 S (ound number to 3 digits after decimal point)-6 E ($rounded = sprintf\("%.3f", $number\);)176 250.8 Q F0 .136 (Perl does its o)128 268.8 R(wn)-.25 E F1(sprintf)2.636 E F0 .136 (formatting: it emulates the C function)2.636 F/F3 10/Times-Italic@0 SF (sprintf)2.637 E F0 .137(\(3\), b)1.666 F .137(ut doesn')-.2 F 2.637(tu) -.18 G .137(se it e)-2.637 F(xcept)-.15 E 3.529 (for \215oating-point numbers, and e)128 280.8 R -.15(ve)-.25 G 6.029 (nt).15 G 3.529(hen only standard modi\214ers are allo)-6.029 F 6.029 (wed. Non-standard)-.25 F -.15(ex)128 292.8 S(tensions in your local).15 E F3(sprintf)2.5 E F0(\(3\) are therefore una)1.666 E -.25(va)-.2 G (ilable from Perl.).25 E(Unlik)128 310.8 Q(e)-.1 E F1(printf)3.267 E F0 (,)A F1(sprintf)3.267 E F0 .767 (does not do what you probably mean when you pass it an array as your) 3.267 F .712(\214rst ar)128 322.8 R .712(gument. The array is gi)-.18 F -.15(ve)-.25 G 3.212(ns).15 G .712(calar conte)-3.212 F .711 (xt, and instead of using the 0th element of the array as)-.15 F(the fo\ rmat, Perl will use the count of elements in the array as the format, w\ hich is almost ne)128 334.8 Q -.15(ve)-.25 G 2.5(ru).15 G(seful.)-2.5 E (Perl')128 352.8 Q(s)-.55 E F1(sprintf)2.5 E F0(permits the follo)2.5 E (wing uni)-.25 E -.15(ve)-.25 G(rsally-kno).15 E(wn con)-.25 E -.15(ve) -.4 G(rsions:).15 E F1 18(%% a)146 370.8 R(percent sign)6 E 18(%c a)146 382.8 R(character with the given number)6 E 18(%s a)146 394.8 R(string)6 E 18(%d a)146 406.8 R(signed integer, in decimal)6 E 18(%u an)146 418.8 R(unsigned integer, in decimal)6 E 18(%o an)146 430.8 R (unsigned integer, in octal)6 E 18(%x an)146 442.8 R (unsigned integer, in hexadecimal)6 E 18(%e a)146 454.8 R (floating\255point number, in scientific notation)6 E 18(%f a)146 466.8 R(floating\255point number, in fixed decimal notation)6 E 18(%g a)146 478.8 R(floating\255point number, in %e or %f notation)6 E F0 (In addition, Perl permits the follo)128 496.8 Q (wing widely-supported con)-.25 E -.15(ve)-.4 G(rsions:).15 E F1 18 (%X like)146 514.8 R(%x, but using upper\255case letters)6 E 18(%E like) 146 526.8 R(%e, but using an upper\255case "E")6 E 18(%G like)146 538.8 R(%g, but with an upper\255case "E" \(if applicable\))6 E 18(%b an)146 550.8 R(unsigned integer, in binary)6 E 18(%B like)146 562.8 R (%b, but using an upper\255case "B" with the # flag)6 E 18(%p a)146 574.8 R(pointer \(outputs the Perl value\010s address in hexadecimal\))6 E 18(%n special:)146 586.8 R (*stores* the number of characters output so far)6 E (into the next variable in the parameter list)176 598.8 Q F0(Finally)128 616.8 Q 2.542(,f)-.65 G .042(or backw)-2.542 F .042 (ard \(and we do mean `)-.1 F(`backw)-.74 E(ard')-.1 E .042 ('\) compatibility)-.74 F 2.542(,P)-.65 G .043 (erl permits these unnecessary b)-2.542 F(ut)-.2 E(widely-supported con) 128 628.8 Q -.15(ve)-.4 G(rsions:).15 E F1 18(%i a)146 646.8 R (synonym for %d)6 E 18(%D a)146 658.8 R(synonym for %ld)6 E 18(%U a)146 670.8 R(synonym for %lu)6 E 18(%O a)146 682.8 R(synonym for %lo)6 E 18 (%F a)146 694.8 R(synonym for %f)6 E F0 .418(Note that the number of e) 128 712.8 R .418 (xponent digits in the scienti\214c notation produced by)-.15 F F1(%e) 2.918 E F0(,)A F1(%E)2.918 E F0(,)A F1(%g)2.917 E F0(and)2.917 E F1(%G) 2.917 E F0(for)2.917 E .537(numbers with the modulus of the e)128 724.8 R .537 (xponent less than 100 is system-dependent: it may be three or less)-.15 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 77)162.62 F 0 Cg EP %%Page: 78 78 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 1.081 (\(zero-padded as necessary\).)128 84 R 1.081(In other w)6.081 F 1.081 (ords, 1.23 times ten to the 99th may be either `)-.1 F(`1.23e99')-.74 E 3.58('o)-.74 G(r)-3.58 E -.74(``)128 96 S(1.23e099').74 E('.)-.74 E 1.833(Between the)128 114 R/F1 10/Courier@0 SF(%)4.333 E F0 1.833 (and the format letter)4.333 F 4.334(,y)-.4 G 1.834(ou may specify se) -4.334 F -.15(ve)-.25 G 1.834(ral additional attrib).15 F 1.834 (utes controlling the)-.2 F(interpretation of the format.)128 126 Q (In order)5 E 2.5(,t)-.4 G(hese are:)-2.5 E(format parameter inde)128 142.8 Q(x)-.15 E .985(An e)148 154.8 R .985 (xplicit format parameter inde)-.15 F .985(x, such as)-.15 F F1(2$)3.485 E F0 3.485(.B)C 3.485(yd)-3.485 G(ef)-3.485 E .984 (ault sprintf will format the ne)-.1 F .984(xt unused)-.15 F(ar)148 166.8 Q(gument in the list, b)-.18 E(ut this allo)-.2 E(ws you to tak) -.25 E 2.5(et)-.1 G(he ar)-2.5 E(guments out of order:)-.18 E F1 (printf \010%2$d %1$d\010, 12, 34;)160 184.8 Q 6(#p)36 G(rints "34 12") -6 E(printf \010%3$d %d %1$d\010, 1, 2, 3;)160 196.8 Q 6(#p)12 G (rints "3 1 1")-6 E F0(\215ags)128 213.6 Q(one or more of:)148 225.6 Q F1 12(space prefix)166 243.6 R(non\255negative number with a space)6 E 42(+p)166 255.6 S(refix non\255negative number with a plus sign)-42 E 42 166 267.6 S(eft\255justify within the field)-42 E 42(0u)166 279.6 S(se zeros, not spaces, to right\255justify)-42 E 42(#e)166 291.6 S (nsure the leading "0" for any octal,)-42 E (prefix non\255zero hexadecimal with "0x" or "0X",)214 303.6 Q (prefix non\255zero binary with "0b" or "0B")214 315.6 Q F0 -.15(Fo)148 333.6 S 2.5(re).15 G(xample:)-2.65 E F1(printf \010<% d>\010,)160 351.6 Q 12(12; #)12 F(prints "< 12>")6 E(printf \010<%+d>\010,)160 363.6 Q 12 (12; #)12 F(prints "<+12>")6 E(printf \010<%6s>\010,)160 375.6 Q 12 (12; #)12 F(prints "<)6 E(12>")24 E(printf \010<%\2556s>\010, 12;)160 387.6 Q 6(#p)18 G(rints "<12)-6 E(>")24 E(printf \010<%06s>\010, 12;)160 399.6 Q 6(#p)18 G(rints "<000012>")-6 E(printf \010<%#o>\010,)160 411.6 Q 12(12; #)12 F(prints "<014>")6 E(printf \010<%#x>\010,)160 423.6 Q 12 (12; #)12 F(prints "<0xc>")6 E(printf \010<%#X>\010,)160 435.6 Q 12 (12; #)12 F(prints "<0XC>")6 E(printf \010<%#b>\010,)160 447.6 Q 12 (12; #)12 F(prints "<0b1100>")6 E(printf \010<%#B>\010,)160 459.6 Q 12 (12; #)12 F(prints "<0B1100>")6 E F0 .117 (When a space and a plus sign are gi)148 477.6 R -.15(ve)-.25 G 2.617 (na).15 G 2.617(st)-2.617 G .117 (he \215ags at once, a plus sign is used to pre\214x a positi)-2.617 F -.15(ve)-.25 G(number)148 489.6 Q(.)-.55 E F1 (printf \010<%+ d>\010, 12;)160 507.6 Q 6(#p)18 G(rints "<+12>")-6 E (printf \010<% +d>\010, 12;)160 519.6 Q 6(#p)18 G(rints "<+12>")-6 E F0 .01(When the # \215ag and a precision are gi)148 537.6 R -.15(ve)-.25 G 2.51(ni).15 G 2.51(nt)-2.51 G(he)-2.51 E F1(%o)2.51 E F0(con)2.51 E -.15 (ve)-.4 G .01(rsion, the precision is incremented if it').15 F(s)-.55 E (necessary for the leading `)148 549.6 Q(`0')-.74 E('.)-.74 E F1 (printf \010<%#.5o>\010, 012;)160 567.6 Q 6(#p)36 G(rints "<00012>")-6 E (printf \010<%#.5o>\010, 012345;)160 579.6 Q 6(#p)18 G(rints "<012345>") -6 E(printf \010<%#.0o>\010, 0;)160 591.6 Q 6(#p)48 G(rints "<0>")-6 E F0 -.15(ve)128 608.4 S(ctor \215ag).15 E .116 (This \215ag tells Perl to interpret the supplied string as a v)148 620.4 R .117(ector of inte)-.15 F .117(gers, one for each character in) -.15 F .929(the string. Perl applies the format to each inte)148 632.4 R .929(ger in turn, then joins the resulting strings with a)-.15 F 1.01 (separator \(a dot)148 644.4 R F1(.)3.51 E F0 1.01(by def)3.51 F 1.01 (ault\). This can be useful for displaying ordinal v)-.1 F 1.01 (alues of characters in)-.25 F(arbitrary strings:)148 656.4 Q F1 (printf "%vd", "AB\\x{100}";)160 674.4 Q 6(#p)66 G(rints "65.66.256")-6 E(printf "version is v%vd\\n", $^V;)160 686.4 Q 6(#P)30 G (erl\010s version)-6 E F0(Put an asterisk)148 704.4 Q F1(*)2.5 E F0 (before the)2.5 E F1(v)2.5 E F0(to o)2.5 E -.15(ve)-.15 G (rride the string to use to separate the numbers:).15 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 78)162.62 F 0 Cg EP %%Page: 79 79 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (printf "address is %*vX\\n", ":", $addr;)160 84 Q 6(#I)18 G (Pv6 address)-6 E(printf "bits are %0*v8b\\n", " ", $bits;)160 96 Q 6 (#r)18 G(andom bitstring)-6 E F0 -1.1(Yo)148 114 S 3.49(uc)1.1 G .99 (an also e)-3.49 F .99(xplicitly specify the ar)-.15 F .99 (gument number to use for the join string using something)-.18 F(lik)148 126 Q(e)-.1 E F1(*2$v)2.5 E F0 2.5(;f)C(or e)-2.5 E(xample:)-.15 E F1 (printf \010%*4$vX %*4$vX %*4$vX\010, @addr[1..3], ":";)160 144 Q 6(#3I) 18 G(Pv6 addresses)-6 E F0(\(minimum\) width)128 160.8 Q(Ar)148 172.8 Q .787(guments are usually formatted to be only as wide as required to di\ splay the gi)-.18 F -.15(ve)-.25 G 3.288(nv).15 G .788(alue. Y)-3.538 F (ou)-1.1 E .682(can o)148 184.8 R -.15(ve)-.15 G .681 (rride the width by putting a number here, or get the width from the ne) .15 F .681(xt ar)-.15 F .681(gument \(with)-.18 F F1(*)148 196.8 Q F0 2.5(\)o)C 2.5(rf)-2.5 G(rom a speci\214ed ar)-2.5 E(gument \(e.g., with) -.18 E F1(*2$)2.5 E F0(\):)A F1(printf "<%s>", "a";)160 214.8 Q 6(#p)42 G(rints "")-6 E(printf "<%6s>", "a";)160 226.8 Q 6(#p)36 G(rints "<) -6 E(a>")30 E(printf "<%*s>", 6, "a";)160 238.8 Q 6(#p)18 G(rints "<)-6 E(a>")30 E(printf "<%*2$s>", "a", 6; # prints "<)160 250.8 Q(a>")30 E (printf "<%2s>", "long";)160 262.8 Q 6(#p)18 G (rints "" \(does not truncate\))-6 E F0 2.565 (If a \214eld width obtained through)148 280.8 R F1(*)5.065 E F0 2.565 (is ne)5.065 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 5.066(,i).15 G 5.066(th)-5.066 G 2.566(as the same ef)-5.066 F 2.566(fect as the)-.25 F F15.066 E F0 2.566(\215ag: left-)5.066 F(justi\214cation.)148 292.8 Q(precision, or maximum width)128 309.6 Q -1.1(Yo)148 321.6 S 6.141(uc) 1.1 G 3.641(an specify a precision \(for numeric con)-6.141 F -.15(ve) -.4 G 3.641(rsions\) or a maximum width \(for string).15 F(con)148 333.6 Q -.15(ve)-.4 G .232(rsions\) by specifying a).15 F F1(.)2.732 E F0 (follo)2.732 E .232(wed by a number)-.25 F 5.232(.F)-.55 G .232 (or \215oating-point formats e)-5.382 F(xcept)-.15 E F1(g)2.732 E F0 (and)2.732 E F1(G)2.732 E F0(,)A 1.642(this speci\214es ho)148 345.6 R 4.142(wm)-.25 G(an)-4.142 E 4.142(yp)-.15 G 1.642 (laces right of the decimal point to sho)-4.142 F 4.142(w\()-.25 G 1.642 (the def)-4.142 F 1.642(ault being 6\).)-.1 F -.15(Fo)6.641 G(r).15 E -.15(ex)148 357.6 S(ample:).15 E F1 6(#t)160 375.6 S (hese examples are subject to system\255specific variation)-6 E (printf \010<%f>\010, 1;)160 387.6 Q 6(#p)24 G(rints "<1.000000>")-6 E (printf \010<%.1f>\010, 1;)160 399.6 Q 6(#p)12 G(rints "<1.0>")-6 E (printf \010<%.0f>\010, 1;)160 411.6 Q 6(#p)12 G(rints "<1>")-6 E (printf \010<%e>\010, 10;)160 423.6 Q 6(#p)18 G(rints "<1.000000e+01>") -6 E(printf \010<%.1e>\010, 10; # prints "<1.0e+01>")160 435.6 Q F0 -.15 (Fo)148 453.6 S 3.12(r`).15 G(`g')-3.86 E 3.12('a)-.74 G .62(nd `)-3.12 F(`G')-.74 E .621 (', this speci\214es the maximum number of digits to sho)-.74 F 1.921 -.65(w, i)-.25 H .621(ncluding thoe prior to).65 F (the decimal point and those after it; for e)148 465.6 Q(xample:)-.15 E F1 6(#T)160 483.6 S (hese examples are subject to system\255specific variation.)-6 E (printf \010<%g>\010, 1;)160 495.6 Q 6(#p)48 G(rints "<1>")-6 E (printf \010<%.10g>\010, 1;)160 507.6 Q 6(#p)30 G(rints "<1>")-6 E (printf \010<%g>\010, 100;)160 519.6 Q 6(#p)36 G(rints "<100>")-6 E (printf \010<%.1g>\010, 100;)160 531.6 Q 6(#p)24 G(rints "<1e+02>")-6 E (printf \010<%.2g>\010, 100.01; # prints "<1e+02>")160 543.6 Q (printf \010<%.5g>\010, 100.01; # prints "<100.01>")160 555.6 Q (printf \010<%.4g>\010, 100.01; # prints "<100>")160 567.6 Q F0 -.15(Fo) 148 585.6 S 2.726(ri).15 G(nte)-2.726 E .226(ger con)-.15 F -.15(ve)-.4 G .226(rsions, specifying a precision implies that the output of the nu\ mber itself should).15 F (be zero-padded to this width, where the 0 \215ag is ignored:)148 597.6 Q F1(printf \010<%.6d>\010, 1;)160 615.6 Q 6(#p)36 G(rints "<000001>")-6 E(printf \010<%+.6d>\010, 1;)160 627.6 Q 6(#p)30 G(rints "<+000001>")-6 E(printf \010<%\25510.6d>\010, 1;)160 639.6 Q 6(#p)18 G(rints "<000001) -6 E(>")24 E(printf \010<%10.6d>\010, 1;)160 651.6 Q 6(#p)24 G(rints "<) -6 E(000001>")24 E(printf \010<%010.6d>\010, 1;)160 663.6 Q 6(#p)18 G (rints "<)-6 E(000001>")24 E(printf \010<%+10.6d>\010, 1;)160 675.6 Q 6 (#p)18 G(rints "<)-6 E(+000001>")18 E(printf \010<%.6x>\010, 1;)160 699.6 Q 6(#p)36 G(rints "<000001>")-6 E(printf \010<%#.6x>\010, 1;)160 711.6 Q 6(#p)30 G(rints "<0x000001>")-6 E (printf \010<%\25510.6x>\010, 1;)160 723.6 Q 6(#p)18 G(rints "<000001)-6 E(>")24 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 79)162.62 F 0 Cg EP %%Page: 80 80 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (printf \010<%10.6x>\010, 1;)160 84 Q 6(#p)24 G(rints "<)-6 E(000001>") 24 E(printf \010<%010.6x>\010, 1;)160 96 Q 6(#p)18 G(rints "<)-6 E (000001>")24 E(printf \010<%#10.6x>\010, 1;)160 108 Q 6(#p)18 G (rints "<)-6 E(0x000001>")12 E F0 -.15(Fo)148 126 S 2.5(rs).15 G (tring con)-2.5 E -.15(ve)-.4 G(rsions, specifying a precision truncate\ s the string to \214t the speci\214ed width:).15 E F1 (printf \010<%.5s>\010, "truncated";)160 144 Q 6(#p)18 G (rints "")-6 E(printf \010<%10.5s>\010, "truncated"; # prints "<) 160 156 Q(trunc>")30 E F0 -1.1(Yo)148 174 S 2.5(uc)1.1 G (an also get the precision from the ne)-2.5 E(xt ar)-.15 E(gument using) -.18 E F1(.*)2.5 E F0(:)A F1(printf \010<%.6x>\010, 1;)160 192 Q 6(#p)42 G(rints "<000001>")-6 E(printf \010<%.*x>\010, 6, 1;)160 204 Q 6(#p)24 G (rints "<000001>")-6 E F0(If a precision obtained through)148 222 Q F1 (*)2.5 E F0(is ne)2.5 E -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 2.5(,i) .15 G 2.5(tc)-2.5 G(ounts as ha)-2.5 E(ving no precision at all.)-.2 E F1(printf \010<%.*s>\010,)160 240 Q(7, "string";)12 E 6(#p)18 G (rints "")-6 E(printf \010<%.*s>\010,)160 252 Q(3, "string";)12 E 6(#p)18 G(rints "")-6 E(printf \010<%.*s>\010,)160 264 Q (0, "string";)12 E 6(#p)18 G(rints "<>")-6 E (printf \010<%.*s>\010, \2551, "string";)160 276 Q 6(#p)18 G (rints "")-6 E(printf \010<%.*d>\010,)160 300 Q(1, 0;)12 E 6(#p) 18 G(rints "<0>")-6 E(printf \010<%.*d>\010,)160 312 Q(0, 0;)12 E 6(#p) 18 G(rints "<>")-6 E(printf \010<%.*d>\010, \2551, 0;)160 324 Q 6(#p)18 G(rints "<0>")-6 E F0 -1.1(Yo)148 342 S 2.72(uc)1.1 G .22 (annot currently get the precision from a speci\214ed number)-2.72 F 2.72(,b)-.4 G .22(ut it is intended that this will be)-2.92 F (possible in the future, for e)148 354 Q(xample using)-.15 E F1(.*2$)2.5 E F0(:)A F1(printf "<%.*2$x>", 1, 6;)160 372 Q 6(#I)18 G (NVALID, but in future will print "<000001>")-6 E F0(size)128 388.8 Q -.15(Fo)148 400.8 S 2.962(rn).15 G .462(umeric con)-2.962 F -.15(ve)-.4 G .462 (rsions, you can specify the size to interpret the number as using).15 F F1(l)2.961 E F0(,)A F1(h)2.961 E F0(,)A F1(V)2.961 E F0(,)A F1(q)2.961 E F0(,)A F1(L)2.961 E F0(,)A(or)148 412.8 Q F1(ll)2.636 E F0 2.636(.F)C .136(or inte)-2.786 F .136(ger con)-.15 F -.15(ve)-.4 G .136(rsions \() .15 F F1 -12.135 6.136(duoxXb i D U O)D F0 .137 (\), numbers are usually assumed to be)-6.136 F(whate)148 424.8 Q -.15 (ve)-.25 G 2.82(rt).15 G .32(he def)-2.82 F .32(ault inte)-.1 F .32 (ger size is on your platform \(usually 32 or 64 bits\), b)-.15 F .32 (ut you can o)-.2 F -.15(ve)-.15 G(rride).15 E(this to use instead one \ of the standard C types, as supported by the compiler used to b)148 436.8 Q(uild Perl:)-.2 E F1 54(hh interpret)166 454.8 R (integer as C type "char" or "unsigned char")6 E(on Perl 5.14 or later) 238 466.8 Q 66(hi)166 478.8 S (nterpret integer as C type "short" or "unsigned short")-66 E 66(ji)166 490.8 S(ntepret integer as C type "intmax_t" on Perl 5.14)-66 E (or later, and only with a C99 compiler \(unportable\))238 502.8 Q 66 (li)166 514.8 S(nterpret integer as C type "long" or "unsigned long")-66 E(q, L, or ll interpret integer as C type "long long", "unsigned long l\ ong",)166 526.8 Q(or "quad" \(typically 64\255bit integers\))238 538.8 Q 66(ti)166 550.8 S (ntepret integer as C type "ptrdiff_t" on Perl 5.14 or later)-66 E 66 (zi)166 562.8 S (ntepret integer as C type "size_t" on Perl 5.14 or later)-66 E F0 2.526 (As of 5.14, none of these raises an e)148 580.8 R 2.526 (xception if the)-.15 F 5.026(ya)-.15 G 2.527 (re not supported on your platform.)-5.026 F(Ho)148 592.8 Q(we)-.25 E -.15(ve)-.25 G 2.87 -.4(r, i).15 H 4.57(fw).4 G 2.07 (arnings are enabled, a w)-4.67 F 2.069(arning of the)-.1 F F1(printf) 4.569 E F0 -.1(wa)4.569 G 2.069(rning class is issued on an).1 F (unsupported con)148 604.8 Q -.15(ve)-.4 G(rsion \215ag.).15 E (Should you instead prefer an e)5 E(xception, do this:)-.15 E F1 (use warnings FATAL => "printf";)172 622.8 Q F0 .436(If you w)148 640.8 R .436(ould lik)-.1 F 2.936(et)-.1 G 2.936(ok)-2.936 G(no)-2.936 E 2.936 (wa)-.25 G .436(bout a v)-2.936 F .436(ersion dependenc)-.15 F 2.936(yb) -.15 G .437(efore you start running the program, put)-2.936 F (something lik)148 652.8 Q 2.5(et)-.1 G(his at its top:)-2.5 E F1 (use 5.014;)172 670.8 Q 6(#f)12 G(or hh/j/t/z/ printf modifiers)-6 E F0 -1.1(Yo)148 688.8 S 2.5(uc)1.1 G (an \214nd out whether your Perl supports quads via Con\214g:)-2.5 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 80)162.62 F 0 Cg EP %%Page: 81 81 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Config;)172 84 Q (if \($Config{use64bitint} eq "define" || $Config{longsize} >= 8\) {)172 96 Q(print "Nice quads!\\n";)196 108 Q(})172 120 Q F0 -.15(Fo)148 138 S 2.928<728d>.15 G .428(oating-point con)-2.928 F -.15(ve)-.4 G .428 (rsions \().15 F F1 6.428(efgEFG)C F0 .427 (\), numbers are usually assumed to be the def)-6.428 F(ault)-.1 E 1.12 (\215oating-point size on your platform \(double or long double\), b)148 150 R 1.12(ut you can force `)-.2 F 1.12(`long double')-.74 F(')-.74 E (with)148 162 Q F1(q)3.691 E F0(,)A F1(L)3.691 E F0 3.691(,o)C(r)-3.691 E F1(ll)3.691 E F0 1.191(if your platform supports them. Y)3.691 F 1.19 (ou can \214nd out whether your Perl supports)-1.1 F (long doubles via Con\214g:)148 174 Q F1(use Config;)172 192 Q (print "long doubles\\n" if $Config{d_longdbl} eq "define";)172 204 Q F0 -1.1(Yo)148 222 S 2.656(uc)1.1 G .157 (an \214nd out whether Perl considers `)-2.656 F .157(`long double')-.74 F 2.657('t)-.74 G 2.657(ob)-2.657 G 2.657(et)-2.657 G .157(he def)-2.657 F .157(ault \215oating-point size to use)-.1 F (on your platform via Con\214g:)148 234 Q F1(use Config;)172 252 Q (if \($Config{uselongdouble} eq "define"\) {)172 264 Q (print "long doubles by default\\n";)196 276 Q(})172 288 Q F0 (It can also be that long doubles and doubles are the same thing:)148 306 Q F1(use Config;)196 324 Q (\($Config{doublesize} == $Config{longdblsize}\) &&)196 336 Q (print "doubles are long doubles\\n";)244 348 Q F0 .54 (The size speci\214er)148 366 R F1(V)3.04 E F0 .54(has no ef)3.04 F .54 (fect for Perl code, b)-.25 F .54 (ut is supported for compatibility with)-.2 F/F2 9/Times-Roman@0 SF(XS) 3.039 E F0(code.)3.039 E(It means `)148 378 Q (`use the standard size for a Perl inte)-.74 E (ger or \215oating-point number')-.15 E(', which is the def)-.74 E (ault.)-.1 E(order of ar)128 394.8 Q(guments)-.18 E(Normally)148 406.8 Q (,)-.65 E/F3 10/Times-Italic@0 SF(sprintf\(\))5.024 E F0(tak)5.024 E 2.524(es the ne)-.1 F 2.524(xt unused ar)-.15 F 2.524(gument as the v) -.18 F 2.525(alue to format for each format)-.25 F 3.067 (speci\214cation. If the format speci\214cation uses)148 418.8 R F1(*) 5.567 E F0 3.066(to require additional ar)5.567 F 3.066 (guments, these are)-.18 F .869(consumed from the ar)148 430.8 R .869 (gument list in the order the)-.18 F 3.369(ya)-.15 G .87 (ppear in the format speci\214cation)-3.369 F F3(befor)3.37 E(e)-.37 E F0(the)3.37 E -.25(va)148 442.8 S 1.319(lue to format.).25 F 1.319 (Where an ar)6.319 F 1.319(gument is speci\214ed by an e)-.18 F 1.319 (xplicit inde)-.15 F 1.318(x, this does not af)-.15 F 1.318(fect the) -.25 F 1.255(normal order for the ar)148 454.8 R 1.255(guments, e)-.18 F -.15(ve)-.25 G 3.755(nw).15 G 1.255(hen the e)-3.755 F 1.255 (xplicitly speci\214ed inde)-.15 F 3.755(xw)-.15 G 1.255(ould ha)-3.855 F 1.555 -.15(ve b)-.2 H 1.255(een the).15 F(ne)148 466.8 Q(xt ar)-.15 E (gument.)-.18 E(So:)148 484.8 Q F1(printf "<%*.*s>", $a, $b, $c;)172 502.8 Q F0(uses)148 520.8 Q F1($a)2.5 E F0(for the width,)2.5 E F1($b) 2.5 E F0(for the precision, and)2.5 E F1($c)2.5 E F0(as the v)2.5 E (alue to format; while:)-.25 E F1(printf "<%*1$.*s>", $a, $b;)160 538.8 Q F0 -.1(wo)148 556.8 S(uld use).1 E F1($a)2.5 E F0 (for the width and precision, and)2.5 E F1($b)2.5 E F0(as the v)2.5 E (alue to format.)-.25 E 1.796(Here are some more e)148 574.8 R 1.796 (xamples; be a)-.15 F -.1(wa)-.15 G 1.796(re that when using an e).1 F 1.795(xplicit inde)-.15 F 1.795(x, the)-.15 F F1($)4.295 E F0 1.795 (may need)4.295 F(escaping:)148 586.8 Q F1(printf "%2\\$d %d\\n",)160 604.8 Q(12, 34;)24 E 6(#w)48 G(ill print "34 12\\n")-6 E (printf "%2\\$d %d %d\\n", 12, 34;)160 616.8 Q 6(#w)48 G (ill print "34 12 34\\n")-6 E(printf "%3\\$d %d %d\\n", 12, 34, 56;)160 628.8 Q 6(#w)24 G(ill print "56 12 34\\n")-6 E (printf "%2\\$*3\\$d %d\\n", 12, 34, 3;)160 640.8 Q 6(#w)24 G (ill print " 34 12\\n")-6 E F0(If)128 658.8 Q F1 2.176(use locale)4.676 F F0 2.176(is in ef)4.676 F 2.176(fect and)-.25 F F3 (POSIX::setlocale\(\))4.676 E F0 2.176 (has been called, the character used for the)4.676 F 1.373 (decimal separator in formatted \215oating-point numbers is af)128 670.8 R 1.373(fected by the)-.25 F F2(LC_NUMERIC)3.873 E F0 3.873(locale. See) 3.873 F(perllocale and)128 682.8 Q F2(POSIX)2.5 E F0(.)A(sqrt)108 699.6 Q F2(EXPR)2.5 E F0(sqrt)108 711.6 Q .763(Return the positi)128 711.6 R 1.064 -.15(ve s)-.25 H .764(quare root of).15 F F2(EXPR)3.264 E F0 5.764 (.I)C(f)-5.764 E F2(EXPR)3.264 E F0 .764(is omitted, uses)3.264 F F1($_) 3.264 E F0 5.764(.W)C .764(orks only for non-ne)-6.564 F -.05(ga)-.15 G (ti).05 E -.15(ve)-.25 G(operands unless you')128 723.6 Q .3 -.15(ve l) -.5 H(oaded the).15 E F1(Math::Complex)2.5 E F0(module.)2.5 E (perl v5.14.2)72 768 Q 198.17(2011-10-01 81)162.62 F 0 Cg EP %%Page: 82 82 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use Math::Complex;)152 84 Q(print sqrt\(\2554\);)152 96 Q 6(#p)24 G (rints 2i)-6 E F0(srand)108 112.8 Q/F2 9/Times-Roman@0 SF(EXPR)2.5 E F0 (srand)108 124.8 Q(Sets and returns the random number seed for the)128 136.8 Q F1(rand)2.5 E F0(operator)2.5 E(.)-.55 E 1.959 (The point of the function is to `)128 154.8 R(`seed')-.74 E 4.459('t) -.74 G(he)-4.459 E F1(rand)4.459 E F0 1.959(function so that)4.459 F F1 (rand)4.459 E F0 1.958(can produce a dif)4.459 F(ferent)-.25 E .972 (sequence each time you run your program.)128 166.8 R .972 (When called with a parameter)5.972 F(,)-.4 E F1(srand)3.472 E F0 .972 (uses that for the)3.472 F .873 (seed; otherwise it \(semi\255\)randomly chooses a seed.)128 178.8 R .872(In either case, starting with Perl 5.14, it returns)5.873 F (the seed.)128 190.8 Q(If)128 208.8 Q F1(srand\(\))3.425 E F0 .925 (is not called e)3.425 F(xplicitly)-.15 E 3.425(,i)-.65 G 3.425(ti) -3.425 G 3.425(sc)-3.425 G .926 (alled implicitly without a parameter at the \214rst use of the)-3.425 F F1(rand)128 220.8 Q F0(operator)2.943 E 5.443(.H)-.55 G -.25(ow)-5.443 G -2.15 -.25(ev e).25 H 1.243 -.4(r, t).25 H .443(his w).4 F .443 (as not true of v)-.1 F .443 (ersions of Perl before 5.004, so if your script will run)-.15 F (under older Perl v)128 232.8 Q(ersions, it should call)-.15 E F1(srand) 2.5 E F0 2.5(;o)C(therwise most programs w)-2.5 E(on')-.1 E 2.5(tc)-.18 G(all)-2.5 E F1(srand\(\))2.5 E F0(at all.)2.5 E .176 (But there are a fe)128 250.8 R 2.677(ws)-.25 G .177 (ituations in recent Perls where programs are lik)-2.677 F .177 (ely to w)-.1 F .177(ant to call)-.1 F F1(srand)2.677 E F0 5.177(.O)C .177(ne is)-5.177 F 6.823 (for generating predictable results generally for testing or deb)128 262.8 R 9.322(ugging. There,)-.2 F 6.822(you use)9.322 F F1 (srand\($seed\))128 274.8 Q F0 5.421(,w)C 2.921(ith the same)-5.421 F F1 ($seed)5.421 E F0 2.921(each time.)5.421 F 2.922 (Another other case is where you need a)7.921 F .529(cryptographically-\ strong starting point rather than the generally acceptable def)128 286.8 R .529(ault, which is based on)-.1 F 1.317(time of day)128 298.8 R 3.817 (,p)-.65 G(rocess)-3.817 E F2(ID)3.817 E F0 3.817(,a)C 1.318 (nd memory allocation, or the)-3.817 F/F3 10/Times-Italic@0 SF(/de)3.818 E(v/ur)-.15 E(andom)-.15 E F0(de)3.818 E 1.318(vice if a)-.25 F -.25(va) -.2 G 3.818(ilable. And).25 F(still)3.818 E .514 (another case is that you may w)128 310.8 R .514(ant to call)-.1 F F1 (srand\(\))3.014 E F0 .513(after a)3.013 F F1(fork\(\))3.013 E F0 .513 (to a)3.013 F -.2(vo)-.2 G .513(id child processes sharing).2 F (the same seed v)128 322.8 Q (alue as the parent \(and consequently each other\).)-.25 E(Do)128 340.8 Q/F4 10/Times-Bold@0 SF(not)3.331 E F0(call)3.331 E F1(srand\(\))3.332 E F0 .832(\(i.e., without an ar)3.332 F .832 (gument\) more than once per process.)-.18 F .832(The internal state of) 5.832 F 1.795(the random number generator should contain more entrop)128 352.8 R 4.295(yt)-.1 G 1.795(han can be pro)-4.295 F 1.794(vided by an) -.15 F 4.294(ys)-.15 G 1.794(eed, so)-4.294 F(calling)128 364.8 Q F1 (srand\(\))2.5 E F0(ag)2.5 E(ain actually)-.05 E F3(loses)2.5 E F0 (randomness.)2.5 E 1.521(Most implementations of)128 382.8 R F1(srand) 4.021 E F0(tak)4.021 E 4.021(ea)-.1 G 4.021(ni)-4.021 G(nte)-4.021 E 1.522(ger and will silently truncate decimal numbers.)-.15 F(This)6.522 E(means)128 394.8 Q F1(srand\(42\))3.974 E F0 1.474 (will usually produce the same results as)3.974 F F1(srand\(42.1\))3.974 E F0 6.474(.T)C 3.974(ob)-7.274 G 3.973(es)-3.974 G 1.473(afe, al)-3.973 F -.1(wa)-.1 G(ys).1 E(pass)128 406.8 Q F1(srand)2.5 E F0(an inte)2.5 E (ger)-.15 E(.)-.55 E .461(In v)128 424.8 R .461 (ersions of Perl prior to 5.004 the def)-.15 F .462(ault seed w)-.1 F .462(as just the current)-.1 F F1(time)2.962 E F0 5.462(.T)C .462 (his isn')-5.462 F 2.962(tap)-.18 G(articularly)-2.962 E .437 (good seed, so man)128 436.8 R 2.937(yo)-.15 G .437 (ld programs supply their o)-2.937 F .437(wn seed v)-.25 F .437 (alue \(often)-.25 F F1 .436(time ^ $$)2.937 F F0(or)2.936 E F1 .436 (time ^ \($$)2.936 F 6(+\()128 448.8 S($$ << 15\)\))-6 E F0(\), b)A (ut that isn')-.2 E 2.5(tn)-.18 G(ecessary an)-2.5 E 2.5(ym)-.15 G(ore.) -2.5 E -.15(Fo)128 466.8 S 3.272(rc).15 G .772 (ryptographic purposes, ho)-3.272 F(we)-.25 E -.15(ve)-.25 G 1.572 -.4 (r, y).15 H .772(ou need something much more random than the def).4 F .773(ault seed.)-.1 F 2.438(Checksumming the compressed output of one o\ r more rapidly changing operating system status)128 478.8 R (programs is the usual method.)128 490.8 Q -.15(Fo)5 G 2.5(re).15 G (xample:)-2.65 E F1 (srand \(time ^ $$ ^ unpack "%L*", \222ps axww | gzip \255f\222\);)152 508.8 Q F0 1.536(If you')128 526.8 R 1.536 (re particularly concerned with this, search the)-.5 F F2(CP)4.037 E(AN) -.828 E F0 1.537(for random number generator modules)4.037 F (instead of rolling out your o)128 538.8 Q(wn.)-.25 E (Frequently called programs \(lik)128 556.8 Q(e)-.1 E F2(CGI)2.5 E F0 (scripts\) that simply use)2.5 E F1(time ^ $$)152 574.8 Q F0 (for a seed can f)128 592.8 Q(all pre)-.1 E 2.5(yt)-.15 G 2.5(ot)-2.5 G (he mathematical property that)-2.5 E F1(a^b == \(a+1\)^\(b+1\))152 610.8 Q F0(one-third of the time.)128 628.8 Q(So don')5 E 2.5(td)-.18 G 2.5(ot)-2.5 G(hat.)-2.5 E 4.104(At)128 646.8 S 1.604(ypical use of the \ returned seed is for a test program which has too man)-4.104 F 4.104(yc) -.15 G 1.603(ombinations to test)-4.104 F(comprehensi)128 658.8 Q -.15 (ve)-.25 G .115(ly in the time a).15 F -.25(va)-.2 G .115 (ilable to it each run.).25 F .116 (It can test a random subset each time, and should)5.116 F 1.269 (there be a f)128 670.8 R 1.269(ailure, log the seed used for that run \ so that it can later be used to reproduce the same)-.1 F(results.)128 682.8 Q(stat)108 699.6 Q F2(FILEHANDLE)2.5 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 82)162.62 F 0 Cg EP %%Page: 83 83 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(stat)108 84 Q/F1 9 /Times-Roman@0 SF(EXPR)2.5 E F0(stat)108 96 Q F1(DIRHANDLE)2.5 E F0 (stat)108 108 Q .79(Returns a 13\255element list gi)128 108 R .79 (ving the status info for a \214le, either the \214le opened via)-.25 F F1(FILEHANDLE)3.29 E F0(or)3.291 E F1(DIRHANDLE)128 120 Q F0 3.27(,o)C 3.27(rn)-3.27 G .769(amed by)-3.27 F F1(EXPR)3.269 E F0 5.769(.I)C(f) -5.769 E F1(EXPR)3.269 E F0 .769(is omitted, it stats)3.269 F/F2 10 /Courier@0 SF($_)3.269 E F0(\(not)3.269 E F2(_)3.269 E F0 3.269 (!\). Returns)B .769(the empty list if)3.269 F F2(stat)128 132 Q F0 -.1 (fa)2.5 G 2.5(ils. T).1 F(ypically used as follo)-.8 E(ws:)-.25 E F2 (\($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,)152 150 Q ($atime,$mtime,$ctime,$blksize,$blocks\))170 162 Q 6(=s)194 174 S (tat\($filename\);)-6 E F0 (Not all \214elds are supported on all \214lesystem types.)128 192 Q (Here are the meanings of the \214elds:)5 E F2 6(0d)140 210 S 30 (ev device)-6 F(number of filesystem)6 E 6(1i)140 222 S 30(no inode)-6 F (number)6 E 6(2m)140 234 S 24(ode file)-6 F 6(mode \(type)6 F (and permissions\))6 E 6(3n)140 246 S 18(link number)-6 F (of \(hard\) links to the file)6 E 6(4u)140 258 S 30(id numeric)-6 F (user ID of file\010s owner)6 E 6(5g)140 270 S 30(id numeric)-6 F (group ID of file\010s owner)6 E 6(6r)140 282 S 24(dev the)-6 F (device identifier \(special files only\))6 E 6(7s)140 294 S 24 (ize total)-6 F(size of file, in bytes)6 E 6(8a)140 306 S 18(time last) -6 F(access time in seconds since the epoch)6 E 6(9m)140 318 S 18 (time last)-6 F(modify time in seconds since the epoch)6 E(10 ctime)134 330 Q(inode change time in seconds since the epoch \(*\))24 E (11 blksize)134 342 Q(preferred block size for file system I/O)12 E (12 blocks)134 354 Q(actual number of blocks allocated)18 E F0 (\(The epoch w)128 372 Q(as at 00:00 January 1, 1970)-.1 E F1(GMT)2.5 E F0(.\))A 1.279(\(*\) Not all \214elds are supported on all \214lesystem\ types. Notably)128 390 R 3.779(,t)-.65 G 1.279 (he ctime \214eld is non-portable.)-3.779 F(In)6.279 E(particular)128 402 Q 3.457(,y)-.4 G .957(ou cannot e)-3.457 F .957(xpect it to be a `) -.15 F .957(`creation time')-.74 F .957('; see `)-.74 F .957 (`Files and Filesystems')-.74 F 3.457('i)-.74 G 3.456(np)-3.457 G .956 (erlport for)-3.456 F(details.)128 414 Q(If)128 432 Q F2(stat)3.785 E F0 1.286(is passed the special \214lehandle consisting of an underline, no\ stat is done, b)3.785 F 1.286(ut the current)-.2 F (contents of the stat structure from the last)128 444 Q F2(stat)2.5 E F0 (,)A F2(lstat)2.5 E F0 2.5(,o)C 2.5<728c>-2.5 G(letest are returned.) -2.5 E(Example:)5 E F2 (if \(\255x $file && \(\($d\) = stat\(_\)\) && $d < 0\) {)152 462 Q (print "$file is executable NFS file\\n";)176 474 Q(})152 486 Q F0 (\(This w)128 504 Q(orks on machines only for which the de)-.1 E (vice number is ne)-.25 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve u)-.25 H (nder).15 E F1(NFS)2.5 E F0(.\))A 1.049(Because the mode contains both \ the \214le type and its permissions, you should mask of)128 522 R 3.548 (ft)-.25 G 1.048(he \214le type)-3.548 F (portion and \(s\)printf using a)128 534 Q F2("%o")2.5 E F0(if you w)2.5 E(ant to see the real permissions.)-.1 E F2 ($mode = \(stat\($filename\)\)[2];)152 552 Q (printf "Permissions are %04o\\n", $mode & 07777;)152 564 Q F0 .887 (In scalar conte)128 582 R(xt,)-.15 E F2(stat)3.387 E F0 .887 (returns a boolean v)3.387 F .887(alue indicating success or f)-.25 F .888(ailure, and, if successful, sets)-.1 F (the information associated with the special \214lehandle)128 594 Q F2 (_)2.5 E F0(.)A(The File::stat module pro)128 612 Q(vides a con)-.15 E -.15(ve)-.4 G(nient, by-name access mechanism:).15 E F2(use File::stat;) 152 630 Q($sb = stat\($filename\);)152 642 Q (printf "File is %s, size is %s, perm %04o, mtime %s\\n",)152 654 Q ($filename, $sb\255>size, $sb\255>mode & 07777,)194 666 Q (scalar localtime $sb\255>mtime;)194 678 Q F0 -1.1(Yo)128 696 S 2.5(uc) 1.1 G(an import symbolic mode constants \()-2.5 E F2(S_IF*)A F0 2.5(\)a) C(nd functions \()-2.5 E F2(S_IS*)A F0 2.5(\)f)C(rom the Fcntl module:) -2.5 E F2(use Fcntl \010:mode\010;)152 714 Q F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 83)162.62 F 0 Cg EP %%Page: 84 84 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($mode = \(stat\($filename\)\)[2];)152 84 Q 30($user_rwx =)152 108 R (\($mode & S_IRWXU\) >> 6;)6 E 18($group_read =)152 120 R (\($mode & S_IRGRP\) >> 3;)6 E($other_execute =)152 132 Q ($mode & S_IXOTH;)12 E (printf "Permissions are %04o\\n", S_IMODE\($mode\), "\\n";)152 156 Q 24 ($is_setuid =)152 180 R($mode & S_ISUID;)12 E 6 ($is_directory = S_ISDIR\($mode\);)152 192 R F0 -1.1(Yo)128 210 S 3.312 (uc)1.1 G .812(ould write the last tw)-3.312 F 3.312(ou)-.1 G .812 (sing the)-3.312 F F13.312 E F0(and)3.312 E F13.312 E F0 3.312(operators. Commonly)3.312 F -.2(av)3.312 G(ailable)-.05 E F1 (S_IF*)3.312 E F0(constants)3.312 E(are:)128 222 Q F1 6(#P)152 240 S (ermissions: read, write, execute, for user, group, others.)-6 E (S_IRWXU S_IRUSR S_IWUSR S_IXUSR)152 264 Q (S_IRWXG S_IRGRP S_IWGRP S_IXGRP)152 276 Q (S_IRWXO S_IROTH S_IWOTH S_IXOTH)152 288 Q 6(#S)152 312 S (etuid/Setgid/Stickiness/SaveText.)-6 E 6(#N)152 324 S (ote that the exact meaning of these is system dependent.)-6 E (S_ISUID S_ISGID S_ISVTX S_ISTXT)152 348 Q 6(#F)152 372 S(ile types.)-6 E(Not necessarily all are available on your system.)12 E(S_IFREG S_IFDI\ R S_IFLNK S_IFBLK S_IFCHR S_IFIFO S_IFSOCK S_IFWHT S_ENFMT)152 396 Q 6 (#T)152 420 S (he following are compatibility aliases for S_IRUSR, S_IWUSR, S_IXUSR.) -6 E(S_IREAD S_IWRITE S_IEXEC)152 444 Q F0(and the)128 462 Q F1(S_IF*) 2.5 E F0(functions are)2.5 E F1 18(S_IMODE\($mode\) the)152 480 R (part of $mode containing the permission bits)6 E (and the setuid/setgid/sticky bits)200 492 Q 18(S_IFMT\($mode\) the)152 516 R(part of $mode containing the file type)6 E (which can be bit\255anded with \(for example\) S_IFREG)200 528 Q (or with the following functions)272 540 Q 6(#T)152 564 S (he operators \255f, \255d, \255l, \255b, \255c, \255p, and \255S.)-6 E (S_ISREG\($mode\) S_ISDIR\($mode\) S_ISLNK\($mode\))152 588 Q (S_ISBLK\($mode\) S_ISCHR\($mode\) S_ISFIFO\($mode\) S_ISSOCK\($mode\)) 152 600 Q 6(#N)152 624 S 6(od)-6 G (irect \255X operator counterpart, but for the first one)-6 E 6(#t)152 636 S(he \255g operator is often equivalent.)-6 E(The ENFMT stands for) 12 E 6(#r)152 648 S (ecord flocking enforcement, a platform\255dependent feature.)-6 E (S_ISENFMT\($mode\) S_ISWHT\($mode\))152 672 Q F0 .045(See your nati)128 690 R -.15(ve)-.25 G/F2 10/Times-Italic@0 SF -.15(ch)2.696 G(mod).15 E F0 .046(\(2\) and)1.666 F F2(stat)2.546 E F0 .046 (\(2\) documentation for more details about the)1.666 F F1(S_*)2.546 E F0 2.546(constants. T)2.546 F 2.546(og)-.8 G(et)-2.546 E (status info for a symbolic link instead of the tar)128 702 Q (get \214le behind the link, use the)-.18 E F1(lstat)2.5 E F0(function.) 2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 84)162.62 F 0 Cg EP %%Page: 85 85 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(state)108 84 Q/F1 9/Times-Roman@0 SF(EXPR)2.5 E F0(state)108 96 Q F1 .25(TYPE EXPR)2.5 F F0(state)108 108 Q F1(EXPR)2.5 E F0(:)2.5 E F1 -.999(AT)2.5 G(TRS).999 E F0(state)108 120 Q F1 .25(TYPE EXPR)2.5 F F0(:)2.5 E F1 -.999(AT)2.5 G (TRS).999 E/F2 10/Courier@0 SF(state)128 132 Q F0 .282(declares a le) 2.782 F .282(xically scoped v)-.15 F .282(ariable, just lik)-.25 F(e)-.1 E F2(my)2.782 E F0 2.782(does. Ho)2.782 F(we)-.25 E -.15(ve)-.25 G 1.082 -.4(r, t).15 H .282(hose v).4 F .282(ariables will ne)-.25 F -.15(ve) -.25 G 2.782(rb).15 G(e)-2.782 E 2.241(reinitialized, contrary to le)128 144 R 2.241(xical v)-.15 F 2.242 (ariables that are reinitialized each time their enclosing block is)-.25 F(entered.)128 156 Q F2(state)128 174 Q F0 -.25(va)3.985 G 1.485 (riables are enabled only when the).25 F F2 1.485(use feature "state") 3.985 F F0 1.485(pragma is in ef)3.985 F 3.985(fect. See)-.25 F (feature.)128 186 Q(study)108 202.8 Q F1(SCALAR)2.5 E F0(study)108 214.8 Q -.8(Ta)128 226.8 S -.1(ke).8 G 3.16(se).1 G .66(xtra time to study) -3.31 F F1(SCALAR)3.16 E F0(\()3.16 E F2($_)A F0 .66 (if unspeci\214ed\) in anticipation of doing man)3.16 F 3.161(yp)-.15 G .661(attern matches)-3.161 F .514(on the string before it is ne)128 238.8 R .514(xt modi\214ed.)-.15 F .514(This may or may not sa)5.514 F .813 -.15(ve t)-.2 H .513(ime, depending on the nature and).15 F .768 (number of patterns you are searching and the distrib)128 250.8 R .768 (ution of character frequencies in the string to be)-.2 F .803 (searched; you probably w)128 262.8 R .802 (ant to compare run times with and without it to see which is f)-.1 F (aster)-.1 E 5.802(.T)-.55 G(hose)-5.802 E .138(loops that scan for man) 128 274.8 R 2.638(ys)-.15 G .138 (hort constant strings \(including the constant parts of more comple) -2.638 F 2.638(xp)-.15 G(atterns\))-2.638 E .555(will bene\214t most.) 128 286.8 R -1.1(Yo)5.555 G 3.055(um)1.1 G .555(ay ha)-3.055 F .855 -.15 (ve o)-.2 H .555(nly one).15 F F2(study)3.055 E F0(acti)3.055 E .855 -.15(ve a)-.25 H 3.055(tat).15 G .554(ime: if you study a dif)-3.055 F .554(ferent scalar the)-.25 F .237(\214rst is `)128 298.8 R(`unstudied') -.74 E 2.737('. \(The)-.74 F -.1(wa)2.737 G(y).1 E F2(study)2.737 E F0 -.1(wo)2.737 G .237(rks is this: a link).1 F .237(ed list of e)-.1 F -.15(ve)-.25 G .238(ry character in the string to be).15 F 1.626 (searched is made, so we kno)128 310.8 R 2.926 -.65(w, f)-.25 H 1.626 (or e).65 F 1.626(xample, where all the)-.15 F F2<086b08>4.125 E F0 1.625(characters are.)4.125 F 1.625(From each search)6.625 F .353(strin\ g, the rarest character is selected, based on some static frequenc)128 322.8 R 2.854(yt)-.15 G .354(ables constructed from some C)-2.854 F (programs and English te)128 334.8 Q 2.5(xt. Only)-.15 F (those places that contain this `)2.5 E(`rarest')-.74 E 2.5('c)-.74 G (haracter are e)-2.5 E(xamined.\))-.15 E -.15(Fo)128 352.8 S 3.553(re) .15 G 1.053(xample, here is a loop that inserts inde)-3.703 F 3.552(xp) -.15 G 1.052(roducing entries before an)-3.552 F 3.552(yl)-.15 G 1.052 (ine containing a certain)-3.552 F(pattern:)128 364.8 Q F2 (while \(<>\) {)152 382.8 Q(study;)176 394.8 Q(print ".IX foo\\n")176 406.8 Q(if /\\bfoo\\b/;)24 E(print ".IX bar\\n")176 418.8 Q (if /\\bbar\\b/;)24 E(print ".IX blurfl\\n" if /\\bblurfl\\b/;)176 430.8 Q 6(#.)176 442.8 S(..)-6 E(print;)176 454.8 Q(})152 466.8 Q F0 .169 (In searching for)128 484.8 R F2(/\\bfoo\\b/)2.669 E F0 2.669(,o)C .169 (nly locations in)-2.669 F F2($_)2.669 E F0 .169(that contain)2.669 F F2 (f)2.669 E F0 .17(will be look)2.67 F .17(ed at, because)-.1 F F2(f)2.67 E F0 .17(is rarer)2.67 F(than)128 496.8 Q F2(o)2.524 E F0 5.024(.I)C 2.524(ng)-5.024 G .023(eneral, this is a big win e)-2.524 F .023 (xcept in pathological cases.)-.15 F .023 (The only question is whether it sa)5.023 F -.15(ve)-.2 G(s).15 E (you more time than it took to b)128 508.8 Q(uild the link)-.2 E (ed list in the \214rst place.)-.1 E .358(Note that if you ha)128 526.8 R .658 -.15(ve t)-.2 H 2.858(ol).15 G .358 (ook for strings that you don')-2.858 F 2.859(tk)-.18 G(no)-2.859 E 2.859(wt)-.25 G .359(ill runtime, you can b)-2.859 F .359 (uild an entire loop)-.2 F .102(as a string and)128 538.8 R F2(eval) 2.602 E F0 .102(that to a)2.602 F -.2(vo)-.2 G .102 (id recompiling all your patterns all the time.).2 F -.8(To)5.101 G .101 (gether with unde\214ning).8 F F2($/)128 550.8 Q F0 .268 (to input entire \214les as one record, this can be quite f)2.767 F .268 (ast, often f)-.1 F .268(aster than specialized programs lik)-.1 F(e)-.1 E/F3 10/Times-Italic@0 SF(fgr)128 562.8 Q(ep)-.37 E F0 3.33(\(1\). The) 1.666 F(follo)3.329 E .829(wing scans a list of \214les \()-.25 F F2 (@files)A F0 3.329(\)f)C .829(or a list of w)-3.329 F .829(ords \()-.1 F F2(@words)A F0 .829(\), and prints out)B (the names of those \214les that contain a match:)128 574.8 Q (perl v5.14.2)72 768 Q 198.17(2011-10-01 85)162.62 F 0 Cg EP %%Page: 86 86 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF ($search = \010while \(<>\) { study;\010;)152 84 Q (foreach $word \(@words\) {)152 96 Q ($search .= "++\\$seen{\\$ARGV} if /\\\\b$word\\\\b/;\\n";)176 108 Q(}) 152 120 Q($search .= "}";)152 132 Q(@ARGV = @files;)152 144 Q(undef $/;) 152 156 Q(eval $search;)152 168 Q 6(#t)48 G(his screams)-6 E ($/ = "\\n";)152 180 Q 6(#p)48 G(ut back to normal input delimiter)-6 E (foreach $file \(sort keys\(%seen\)\) {)152 192 Q(print $file, "\\n";) 176 204 Q(})152 216 Q F0(sub)108 232.8 Q/F2 9/Times-Roman@0 SF -.315(NA) 2.5 G .25(ME BLOCK).315 F F0(sub)108 244.8 Q F2 -.315(NA)2.5 G(ME).315 E F0(\()2.5 E F2(PR)A -1.692 -.36(OT O)-.36 H F0(\)).36 E F2(BLOCK)2.5 E F0(sub)108 256.8 Q F2 -.315(NA)2.5 G(ME).315 E F0(:)2.5 E F2 -.999(AT) 2.5 G .25(TRS BLOCK).999 F F0(sub)108 268.8 Q F2 -.315(NA)2.5 G(ME).315 E F0(\()2.5 E F2(PR)A -1.692 -.36(OT O)-.36 H F0 2.5(\):).36 G F2 -.999 (AT)C .25(TRS BLOCK).999 F F0 2.643 (This is subroutine de\214nition, not a real function)128 280.8 R/F3 10 /Times-Italic@0 SF 2.644(per se)5.144 F F0 7.644(.W)C 2.644(ithout a) -8.044 F F2(BLOCK)5.144 E F0(it')5.144 E 5.144(sj)-.55 G 2.644 (ust a forw)-5.144 F(ard)-.1 E 4.088(declaration. W)128 292.8 R 1.588 (ithout a)-.4 F F2 -.315(NA)4.088 G(ME).315 E F0 4.088(,i)C(t')-4.088 E 4.088(sa)-.55 G 4.088(na)-4.088 G(non)-4.088 E 1.588 (ymous function declaration, so does return a v)-.15 F 1.587(alue: the) -.25 F F2(CODE)128 304.8 Q F0(ref of the closure just created.)2.5 E 5.7 (See perlsub and perlref for details about subroutines and references; \ see attrib)128 322.8 R 5.7(utes and)-.2 F(Attrib)128 334.8 Q (ute::Handlers for more information about attrib)-.2 E(utes.)-.2 E (substr)108 351.6 Q F2(EXPR)2.5 E F0(,OFFSET)A(,LENGTH,REPLA)-.74 E (CEMENT)-.4 E(substr)108 363.6 Q F2(EXPR)2.5 E F0(,OFFSET)A(,LENGTH)-.74 E(substr)108 375.6 Q F2(EXPR)2.5 E F0(,OFFSET)A .706 (Extracts a substring out of)128 387.6 R F2(EXPR)3.206 E F0 .706 (and returns it.)3.206 F .706(First character is at of)5.706 F(fset)-.25 E F1(0)3.206 E F0 .706(\(or whate)3.206 F -.15(ve)-.25 G 3.205(ry).15 G (ou')-3.205 E 1.005 -.15(ve s)-.5 H(et).15 E F1($[)128 399.6 Q F0 .941 (to \(b)3.441 F(ut)-.2 E/F4 10/Times-Bold@0 SF .941(-.25 G .786(lename symbolically link)-3.286 F .786(ed to the old \214lename.)-.1 F(Returns)5.786 E F1(1)3.286 E F0 .786(for success,)3.286 F F1(0)3.286 E F0(otherwise.)3.286 E (On systems that don')128 286.8 Q 2.5(ts)-.18 G (upport symbolic links, raises an e)-2.5 E 2.5(xception. T)-.15 F 2.5 (oc)-.8 G(heck for that, use e)-2.5 E -.25(va)-.25 G(l:).25 E F1 ($symlink_exists = eval { symlink\("",""\); 1 };)152 304.8 Q F0(syscall) 108 321.6 Q F3(NUMBER)2.5 E F0(,)A F3(LIST)2.5 E F0 1.984(Calls the sys\ tem call speci\214ed as the \214rst element of the list, passing the re\ maining elements as)128 333.6 R(ar)128 345.6 Q .007 (guments to the system call.)-.18 F .006(If unimplemented, raises an e) 5.007 F 2.506(xception. The)-.15 F(ar)2.506 E .006 (guments are interpreted as)-.18 F(follo)128 357.6 Q 1.111(ws: if a gi) -.25 F -.15(ve)-.25 G 3.611(na).15 G -.18(rg)-3.611 G 1.111 (ument is numeric, the ar).18 F 1.111(gument is passed as an int.)-.18 F 1.111(If not, the pointer to the)6.111 F 1.792(string v)128 369.6 R 1.792(alue is passed.)-.25 F -1.1(Yo)6.792 G 4.291(ua)1.1 G 1.791 (re responsible to mak)-4.291 F 4.291(es)-.1 G 1.791 (ure a string is pre-e)-4.291 F 1.791(xtended long enough to)-.15 F (recei)128 381.6 Q .732 -.15(ve a)-.25 H .732 -.15(ny r).15 H .433 (esult that might be written into a string.).15 F -1.1(Yo)5.433 G 2.933 (uc)1.1 G(an')-2.933 E 2.933(tu)-.18 G .433 (se a string literal \(or other read-only)-2.933 F 1.829 (string\) as an ar)128 393.6 R 1.829(gument to)-.18 F F1(syscall)4.329 E F0 1.829(because Perl has to assume that an)4.329 F 4.328(ys)-.15 G 1.828(tring pointer might be)-4.328 F 2.304(written through.)128 405.6 R 2.304(If your inte)7.304 F 2.304(ger ar)-.15 F 2.304 (guments are not literals and ha)-.18 F 2.604 -.15(ve n)-.2 H -2.15 -.25 (ev e).15 H 4.804(rb).25 G 2.304(een interpreted in a)-4.804 F .767 (numeric conte)128 417.6 R .766(xt, you may need to add)-.15 F F1(0) 3.266 E F0 .766(to them to force them to look lik)3.266 F 3.266(en)-.1 G 3.266(umbers. This)-3.266 F(emulates)3.266 E(the)128 429.6 Q F1 (syswrite)2.5 E F0(function \(or vice v)2.5 E(ersa\):)-.15 E F1 (require \010syscall.ph\010;)152 447.6 Q 6(#m)48 G(ay need to run h2ph) -6 E($s = "hi there\\n";)152 459.6 Q (syscall\(&SYS_write, fileno\(STDOUT\), $s, length $s\);)152 471.6 Q F0 .783(Note that Perl supports passing of up to only 14 ar)128 489.6 R .784(guments to your syscall, which in practice should)-.18 F (\(usually\) suf)128 501.6 Q(\214ce.)-.25 E .52(Syscall returns whate) 128 519.6 R -.15(ve)-.25 G 3.02(rv).15 G .519 (alue returned by the system call it calls.)-3.27 F .519 (If the system call f)5.519 F(ails,)-.1 E F1(syscall)3.019 E F0(returns) 128 531.6 Q F13.235 E F0 .735(and sets)3.235 F F1($!)3.235 E F0 3.235(\(errno\). Note)3.235 F .736(that some system calls)3.236 F F2 (can)3.236 E F0(le)3.236 E .736(gitimately return)-.15 F F13.236 E F0 5.736(.T)C .736(he proper)-5.736 F -.1(wa)128 543.6 S 3.347(yt).1 G 3.347(oh)-3.347 G .847(andle such calls is to assign)-3.347 F F1($!=0) 3.346 E F0 .846(before the call, then check the v)3.346 F .846(alue of) -.25 F F1($!)3.346 E F0(if)3.346 E F1(syscall)3.346 E F0(returns)128 555.6 Q F12.5 E F0(.)A(There')128 573.6 Q 3.603(sap)-.55 G 1.103 (roblem with)-3.603 F F1(syscall\(&SYS_pipe\))3.603 E F0 3.603(:i)C 3.603(tr)-3.603 G 1.104(eturns the \214le number of the read end of the) -3.603 F 1.144(pipe it creates, b)128 585.6 R 1.144(ut there is no w)-.2 F 1.144(ay to retrie)-.1 F 1.444 -.15(ve t)-.25 H 1.144 (he \214le number of the other end.).15 F -1.1(Yo)6.144 G 3.644(uc)1.1 G 1.144(an a)-3.644 F -.2(vo)-.2 G 1.144(id this).2 F(problem by using)128 597.6 Q F1(pipe)2.5 E F0(instead.)2.5 E(sysopen)108 614.4 Q F3 (FILEHANDLE)2.5 E F0(,FILEN)A(AME,MODE)-.35 E(sysopen)108 626.4 Q F3 (FILEHANDLE)2.5 E F0(,FILEN)A(AME,MODE,PERMS)-.35 E 2.49 (Opens the \214le whose \214lename is gi)128 638.4 R -.15(ve)-.25 G 4.991(nb).15 G(y)-4.991 E F3(FILEN)4.991 E(AME)-.315 E F0 4.991(,a)C 2.491(nd associates it with)-4.991 F F3(FILEHANDLE)4.991 E F0 7.491(.I)C (f)-7.491 E F3(FILEHANDLE)128 650.4 Q F0 .289(is an e)2.789 F .289 (xpression, its v)-.15 F .289(alue is used as the real \214lehandle w) -.25 F .288(anted; an unde\214ned scalar will)-.1 F .965 (be suitably auto)128 662.4 R(vi)-.15 E .966 (vi\214ed. This function calls the underlying operating system')-.25 F (s)-.55 E F2(open)3.466 E F0 .966(\(2\) function with)B(the parameters) 128 674.4 Q F3(FILEN)2.5 E(AME)-.315 E F0(,)A F3(MODE)2.5 E F0 2.5(,a)C (nd)-2.5 E F3(PERMS)2.5 E F0(.)A .374(The possible v)128 692.4 R .374 (alues and \215ag bits of the)-.25 F F3(MODE)2.874 E F0 .373 (parameter are system-dependent; the)2.874 F 2.873(ya)-.15 G .373(re a) -2.873 F -.25(va)-.2 G .373(ilable via).25 F .146(the standard module) 128 704.4 R F1(Fcntl)2.646 E F0 5.146(.S)C .146 (ee the documentation of your operating system')-5.146 F(s)-.55 E F2 (open)2.647 E F0 .147(\(2\) syscall to see)B(which v)128 716.4 Q (alues and \215ag bits are a)-.25 E -.25(va)-.2 G 2.5(ilable. Y).25 F (ou may combine se)-1.1 E -.15(ve)-.25 G(ral \215ags using the).15 E F1 (|)2.5 E F0(\255operator)A(.)-.55 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 87)162.62 F 0 Cg EP %%Page: 88 88 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .234 (Some of the most common v)128 84 R .234(alues are)-.25 F/F1 10 /Courier@0 SF(O_RDONLY)2.734 E F0 .234 (for opening the \214le in read-only mode,)2.734 F F1(O_WRONLY)2.734 E F0(for opening the \214le in write-only mode, and)128 96 Q F1(O_RDWR)2.5 E F0(for opening the \214le in read-write mode.)2.5 E -.15(Fo)128 114 S 3.734(rh).15 G 1.234(istorical reasons, some v)-3.734 F 1.234(alues w) -.25 F 1.234(ork on almost e)-.1 F -.15(ve)-.25 G 1.234 (ry system supported by Perl: 0 means read-).15 F(only)128 126 Q 4.118 (,1m)-.65 G 1.618(eans write-only)-4.118 F 4.118(,a)-.65 G 1.618 (nd 2 means read/write.)-4.118 F 3.217 -.8(We k)6.618 H(no).8 E 4.117 (wt)-.25 G 1.617(hat these v)-4.117 F 1.617(alues do)-.25 F/F2 10 /Times-Italic@0 SF(not)4.117 E F0 -.1(wo)4.117 G 1.617(rk under).1 F/F3 9/Times-Roman@0 SF(OS/390)128 138 Q F0(&)2.5 E F3(VM/ESA)2.5 E F0 (Unix and on the Macintosh; you probably don')2.5 E 2.5(tw)-.18 G (ant to use them in ne)-2.6 E 2.5(wc)-.25 G(ode.)-2.5 E .662 (If the \214le named by)128 156 R F3(FILEN)3.162 E(AME)-.315 E F0 .662 (does not e)3.162 F .662(xist and the)-.15 F F1(open)3.162 E F0 .662 (call creates it \(typically because)3.162 F F3(MODE)3.162 E F0 .626 (includes the)128 168 R F1(O_CREAT)3.126 E F0 .625(\215ag\), then the v) 3.126 F .625(alue of)-.25 F F3(PERMS)3.125 E F0 .625 (speci\214es the permissions of the ne)3.125 F .625(wly created)-.25 F 5.555(\214le. If)128 180 R 3.056(you omit the)5.556 F F3(PERMS)5.556 E F0(ar)5.556 E 3.056(gument to)-.18 F F1(sysopen)5.556 E F0 5.556(,P)C 3.056(erl uses the octal v)-5.556 F(alue)-.25 E F1(0666)5.556 E F0 8.056 (.T)C(hese)-8.056 E(permission v)128 192 Q (alues need to be in octal, and are modi\214ed by your process')-.25 E 2.5(sc)-.55 G(urrent)-2.5 E F1(umask)2.5 E F0(.)A 2.08(In man)128 210 R 4.58(ys)-.15 G 2.08(ystems the)-4.58 F F1(O_EXCL)4.58 E F0 2.08 (\215ag is a)4.58 F -.25(va)-.2 G 2.08(ilable for opening \214les in e) .25 F(xclusi)-.15 E 2.38 -.15(ve m)-.25 H 4.58(ode. This).15 F(is)4.58 E /F4 10/Times-Bold@0 SF(not)4.58 E F0 1.422(locking: e)128 222 R(xclusi) -.15 E -.15(ve)-.25 G 1.422 (ness means here that if the \214le already e).15 F(xists,)-.15 E F2 (sysopen\(\))3.922 E F0 -.1(fa)3.922 G(ils.).1 E F1(O_EXCL)6.422 E F0 1.423(may not)3.923 F -.1(wo)128 234 S 1.923(rk on netw).1 F 1.923 (ork \214lesystems, and has no ef)-.1 F 1.923(fect unless the)-.25 F F1 (O_CREAT)4.422 E F0 1.922(\215ag is set as well.)4.422 F(Setting)6.922 E F1(O_CREAT|O_EXCL)128 246 Q F0(pre)3.373 E -.15(ve)-.25 G .874 (nts the \214le from being opened if it is a symbolic link.).15 F .874 (It does not protect)5.874 F(ag)128 258 Q (ainst symbolic links in the \214le')-.05 E 2.5(sp)-.55 G(ath.)-2.5 E .705(Sometimes you may w)128 276 R .705(ant to truncate an already-e)-.1 F .705(xisting \214le.)-.15 F .704(This can be done using the)5.705 F F1 (O_TRUNC)3.204 E F0 2.5(\215ag. The)128 288 R(beha)2.5 E(vior of)-.2 E F1(O_TRUNC)2.5 E F0(with)2.5 E F1(O_RDONLY)2.5 E F0(is unde\214ned.)2.5 E -1.1(Yo)128 306 S 3.648(us)1.1 G 1.148(hould seldom if e)-3.648 F -.15 (ve)-.25 G 3.648(ru).15 G(se)-3.648 E F1(0644)3.648 E F0 1.148(as ar) 3.648 F 1.148(gument to)-.18 F F1(sysopen)3.648 E F0 3.648(,b)C 1.148 (ecause that tak)-3.648 F 1.148(es a)-.1 F -.1(wa)-.15 G 3.649(yt).1 G 1.149(he user')-3.649 F(s)-.55 E .704(option to ha)128 318 R 1.004 -.15 (ve a m)-.2 H .703(ore permissi).15 F 1.003 -.15(ve u)-.25 H 3.203 (mask. Better).15 F .703(to omit it.)3.203 F .703(See the)5.703 F F2 (perlfunc)3.203 E F0 .703(\(1\) entry on)1.666 F F1(umask)3.203 E F0 (for)3.203 E(more on this.)128 330 Q .568(Note that)128 348 R F1 (sysopen)3.068 E F0 .568(depends on the)3.068 F F2(fdopen\(\))3.068 E F0 3.068(Cl)3.068 G .568(ibrary function.)-3.068 F .568(On man)5.568 F 3.068(yU)-.15 G .568(nix systems,)-3.068 F F2(fdopen\(\))3.068 E F0(is) 3.068 E(kno)128 360 Q 2.26(wn to f)-.25 F 2.26 (ail when \214le descriptors e)-.1 F 2.26(xceed a certain v)-.15 F 2.26 (alue, typically 255. If you need more \214le)-.25 F 3.452 (descriptors than that, consider reb)128 372 R 3.453 (uilding Perl to use the)-.2 F F1(sfio)5.953 E F0(library)5.953 E 5.953 (,o)-.65 G 5.953(rp)-5.953 G 3.453(erhaps using the)-5.953 F F2 (POSIX::open\(\))128 384 Q F0(function.)2.5 E (See perlopentut for a kinder)128 402 Q 2.5(,g)-.4 G(entler e)-2.5 E (xplanation of opening \214les.)-.15 E(sysread)108 418.8 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH,OFFSET)A(sysread)108 430.8 Q F3 (FILEHANDLE)2.5 E F0(,SCALAR,LENGTH)A .204(Attempts to read)128 442.8 R F3(LENGTH)2.704 E F0 .204(bytes of data into v)2.704 F(ariable)-.25 E F3 (SCALAR)2.704 E F0 .204(from the speci\214ed)2.704 F F3(FILEHANDLE)2.704 E F0 2.703(,u)C(sing)-2.703 E(the)128 454.8 Q F2 -.37(re)2.581 G(ad).37 E F0 2.581(\(2\). It)1.666 F .082(bypasses b)2.581 F(uf)-.2 E(fered)-.25 E F3(IO)2.582 E F0 2.582(,s)C 2.582(om)-2.582 G .082 (ixing this with other kinds of reads,)-2.582 F F1(print)2.582 E F0(,)A F1(write)2.582 E F0(,)A F1(seek)2.582 E F0(,)A F1(tell)128 466.8 Q F0 2.69(,o)C(r)-2.69 E F1(eof)2.69 E F0 .189 (can cause confusion because the perlio or stdio layers usually b)2.69 F (uf)-.2 E .189(fers data.)-.25 F .189(Returns the)5.189 F .595 (number of bytes actually read,)128 478.8 R F1(0)3.095 E F0 .595 (at end of \214le, or undef if there w)3.095 F .595 (as an error \(in the latter case)-.1 F F1($!)3.095 E F0(is)3.095 E .923 (also set\).)128 490.8 R F3(SCALAR)5.923 E F0 .923(will be gro)3.423 F .923(wn or shrunk so that the last byte actually read is the last byte \ of the)-.25 F(scalar after the read.)128 502.8 Q(An)128 520.8 Q F3 (OFFSET)4.882 E F0 2.383(may be speci\214ed to place the read data at s\ ome place in the string other than the)4.882 F(be)128 532.8 Q 3.057 (ginning. A)-.15 F(ne)3.057 E -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G F3 (OFFSET)3.207 E F0 .557(speci\214es placement at that man)3.057 F 3.057 (yc)-.15 G .557(haracters counting backw)-3.057 F .556(ards from)-.1 F .214(the end of the string.)128 544.8 R 2.715(Ap)5.215 G(ositi)-2.715 E -.15(ve)-.25 G F3(OFFSET)2.865 E F0 .215(greater than the length of) 2.715 F F3(SCALAR)2.715 E F0 .215(results in the string being)2.715 F (padded to the required size with)128 556.8 Q F1("\\0")2.5 E F0 (bytes before the result of the read is appended.)2.5 E 1.417 (There is no)128 574.8 R F2(syseof\(\))3.917 E F0 1.417 (function, which is ok, since)3.917 F F2(eof\(\))3.916 E F0(doesn')3.916 E 3.916(tw)-.18 G 1.416(ork well on de)-4.016 F 1.416 (vice \214les \(lik)-.25 F 3.916(et)-.1 G(tys\))-3.916 E(an)128 586.8 Q (yw)-.15 E(ay)-.1 E 5(.U)-.65 G(se)-5 E F2(sysr)2.5 E(ead\(\))-.37 E F0 (and check for a return v)2.5 E(alue for 0 to decide whether you')-.25 E (re done.)-.5 E 1.11(Note that if the \214lehandle has been mark)128 604.8 R 1.11(ed as)-.1 F F1(:utf8)3.61 E F0 1.11 (Unicode characters are read instead of bytes)3.61 F(\(the)128 616.8 Q F3(LENGTH)6.735 E F0(,)A F3(OFFSET)6.735 E F0 6.735(,a)C 4.235 (nd the return v)-6.735 F 4.235(alue of)-.25 F F2(sysr)6.735 E(ead\(\)) -.37 E F0 4.234(are in Unicode characters\).)6.735 F(The)9.234 E F1 (:encoding\(...\))128 628.8 Q F0 .824(layer implicitly introduces the) 3.324 F F1(:utf8)3.324 E F0(layer)3.325 E 5.825(.S)-.55 G .825(ee `) -5.825 F(`binmode')-.74 E .825(', `)-.74 F(`open')-.74 E .825 (', and the)-.74 F F1(open)128 640.8 Q F0(pragma, open.)2.5 E(sysseek) 108 657.6 Q F3(FILEHANDLE)2.5 E F0(,POSITION,WHENCE)A(Sets)128 669.6 Q F3(FILEHANDLE)4.09 E F0 2.69 -.55('s s)D 1.59 (ystem position in bytes using).55 F F2(lseek)4.09 E F0(\(2\).)1.666 E F3(FILEHANDLE)6.59 E F0 1.589(may be an e)4.089 F(xpression)-.15 E .064 (whose v)128 681.6 R .064(alue gi)-.25 F -.15(ve)-.25 G 2.564(st).15 G .064(he name of the \214lehandle.)-2.564 F .064(The v)5.064 F .064 (alues for)-.25 F F3(WHENCE)2.564 E F0(are)2.564 E F1(0)2.564 E F0 .064 (to set the ne)2.564 F 2.564(wp)-.25 G .065(osition to)-2.564 F F3 (POSITION)128 693.6 Q F0(;)A F1(1)2.737 E F0 .236 (to set the it to the current position plus)2.737 F F3(POSITION)2.736 E F0 2.736(;a)C(nd)-2.736 E F1(2)2.736 E F0 .236(to set it to)2.736 F F3 (EOF)2.736 E F0(plus)2.736 E F3(POSITION)2.736 E F0(,)A(typically ne)128 705.6 Q -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G(.).15 E .095(Note the)128 723.6 R F2 .095(in bytes)2.595 F F0 2.595(:e)C -.15(ve)-2.845 G 2.595 (ni).15 G 2.595(ft)-2.595 G .095 (he \214lehandle has been set to operate on characters \(for e)-2.595 F .096(xample by using the)-.15 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 88)162.62 F 0 Cg EP %%Page: 89 89 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (:encoding\(utf8\))128 84 Q F0 3.594(I/O layer\),)6.094 F/F2 10 /Times-Italic@0 SF(tell\(\))6.094 E F0 3.594(will return byte of)6.094 F 3.593(fsets, not character of)-.25 F 3.593(fsets \(because)-.25 F (implementing that w)128 96 Q(ould render)-.1 E F2(sysseek\(\))2.5 E F0 (unacceptably slo)2.5 E(w\).)-.25 E F2(sysseek\(\))128 114 Q F0 .463 (bypasses normal b)2.963 F(uf)-.2 E(fered)-.25 E/F3 9/Times-Roman@0 SF (IO)2.963 E F0 2.963(,s)C 2.964(om)-2.963 G .464 (ixing it with reads other than)-2.964 F F1(sysread)2.964 E F0 .464 (\(for e)2.964 F(xample)-.15 E F1(<>)2.964 E F0(or)128 126 Q F2 -.37(re) 2.5 G(ad\(\)).37 E F0(\))A F1(print)2.5 E F0(,)A F1(write)2.5 E F0(,)A F1(seek)2.5 E F0(,)A F1(tell)2.5 E F0 2.5(,o)C(r)-2.5 E F1(eof)2.5 E F0 (may cause confusion.)2.5 E -.15(Fo)128 144 S(r).15 E F3(WHENCE)2.974 E F0 2.974(,y)C .474(ou may also use the constants)-2.974 F F1(SEEK_SET) 2.973 E F0(,)A F1(SEEK_CUR)2.973 E F0 2.973(,a)C(nd)-2.973 E F1 (SEEK_END)2.973 E F0 .473(\(start of the)2.973 F .051 (\214le, current position, end of the \214le\) from the Fcntl module.) 128 156 R .052(Use of the constants is also more portable)5.052 F (than relying on 0, 1, and 2.)128 168 Q -.15(Fo)5 G 2.5(re).15 G (xample to de\214ne a `)-2.65 E(`systell')-.74 E 2.5('f)-.74 G(unction:) -2.5 E F1(use Fcntl \010SEEK_CUR\010;)152 186 Q (sub systell { sysseek\($_[0], 0, SEEK_CUR\) })152 198 Q F0 .102 (Returns the ne)128 216 R 2.601(wp)-.25 G .101 (osition, or the unde\214ned v)-2.601 F .101(alue on f)-.25 F 2.601 (ailure. A)-.1 F .101(position of zero is returned as the string)2.601 F F1 .387("0 but true")128 228 R F0 2.887(;t)C(hus)-2.887 E F1(sysseek) 2.887 E F0 .387(returns true on success and f)2.887 F .387(alse on f)-.1 F .387(ailure, yet you can still easily)-.1 F(determine the ne)128 240 Q 2.5(wp)-.25 G(osition.)-2.5 E(system)108 256.8 Q F3(LIST)2.5 E F0 (system)108 268.8 Q F3(PR)2.5 E .25(OGRAM LIST)-.36 F F0 .928(Does e)128 280.8 R .928(xactly the same thing as)-.15 F F1 .928(exec LIST)3.428 F F0 3.428(,e)C .928 (xcept that a fork is done \214rst and the parent process)-3.578 F -.1 (wa)128 292.8 S .518(its for the child process to e).1 F 3.019 (xit. Note)-.15 F .519(that ar)3.019 F .519(gument processing v)-.18 F .519(aries depending on the number of)-.25 F(ar)128 304.8 Q 3.845 (guments. If)-.18 F 1.345(there is more than one ar)3.845 F 1.344 (gument in)-.18 F F3(LIST)3.844 E F0 3.844(,o)C 3.844(ri)-3.844 G(f) -3.844 E F3(LIST)3.844 E F0 1.344(is an array with more than one)3.844 F -.25(va)128 316.8 S .581(lue, starts the program gi).25 F -.15(ve)-.25 G 3.081(nb).15 G 3.081(yt)-3.081 G .582 (he \214rst element of the list with ar)-3.081 F .582(guments gi)-.18 F -.15(ve)-.25 G 3.082(nb).15 G 3.082(yt)-3.082 G .582(he rest of the) -3.082 F 2.537(list. If)128 328.8 R .037(there is only one scalar ar) 2.537 F .037(gument, the ar)-.18 F .036(gument is check)-.18 F .036 (ed for shell metacharacters, and if there)-.1 F 1.088(are an)128 340.8 R 2.388 -.65(y, t)-.15 H 1.088(he entire ar).65 F 1.088 (gument is passed to the system')-.18 F 3.588(sc)-.55 G 1.088 (ommand shell for parsing \(this is)-3.588 F F1(/bin/sh)3.589 E128 352.8 Q F0 1.752(on Unix platforms, b)4.252 F 1.752(ut v)-.2 F 1.752 (aries on other platforms\).)-.25 F 1.752 (If there are no shell metacharacters in the)6.752 F(ar)128 364.8 Q (gument, it is split into w)-.18 E(ords and passed directly to)-.1 E F1 (execvp)2.5 E F0 2.5(,w)C(hich is more ef)-2.5 E(\214cient.)-.25 E(Be) 128 382.8 Q .683(ginning with v5.6.0, Perl will attempt to \215ush all \ \214les opened for output before an)-.15 F 3.184(yo)-.15 G .684 (peration that)-3.184 F .615(may do a fork, b)128 394.8 R .614 (ut this may not be supported on some platforms \(see perlport\).)-.2 F 2.214 -.8(To b)5.614 H 3.114(es).8 G .614(afe, you may)-3.114 F .657 (need to set)128 406.8 R F1($|)3.157 E F0(\($A)3.157 E(UT)-.55 E .657 (OFLUSH in English\) or call the)-.18 F F1(autoflush\(\))3.157 E F0 .657 (method of)3.157 F F1(IO::Handle)3.158 E F0(on)3.158 E(an)128 418.8 Q 2.5(yo)-.15 G(pen handles.)-2.5 E .471(The return v)128 436.8 R .471 (alue is the e)-.25 F .471(xit status of the program as returned by the) -.15 F F1(wait)2.971 E F0 2.971(call. T)2.971 F 2.971(og)-.8 G .471 (et the actual e)-2.971 F(xit)-.15 E -.25(va)128 448.8 S .687 (lue, shift right by eight \(see belo).25 F .687(w\). See also `)-.25 F (`e)-.74 E -.15(xe)-.15 G(c').15 E 3.187('. This)-.74 F(is)3.187 E F2 (not)3.187 E F0 .688(what you w)3.188 F .688(ant to use to capture)-.1 F 1.979 (the output from a command; for that you should use merely backticks or) 128 460.8 R F1(qx//)4.478 E F0 4.478(,a)C 4.478(sd)-4.478 G 1.978 (escribed in)-4.478 F -.74(```)128 472.8 S(STRING`').74 E 3.186('i)-.74 G 3.186(np)-3.186 G 3.186(erlop. Return)-3.186 F -.25(va)3.186 G .687 (lue of \2551 indicates a f).25 F .687 (ailure to start the program or an error of the)-.1 F F2(wait)128 484.8 Q F0(\(2\) system call \(inspect $! for the reason\).)1.666 E .814 (If you')128 502.8 R 3.314(dl)-.5 G(ik)-3.314 E 3.314(et)-.1 G 3.314(om) -3.314 G(ak)-3.314 E(e)-.1 E F1(system)3.314 E F0 .814(\(and man)3.314 F 3.314(yo)-.15 G .814(ther bits of Perl\) die on error)-3.314 F 3.314(,h) -.4 G -2.25 -.2(av e)-3.314 H 3.314(al)3.514 G .814(ook at the autodie) -3.314 F(pragma.)128 514.8 Q(Lik)128 532.8 Q(e)-.1 E F1(exec)2.502 E F0 (,)A F1(system)2.502 E F0(allo)2.502 E .002 (ws you to lie to a program about its name if you use the)-.25 F F1 .003 (system PROGRAM)2.503 F(LIST)128 544.8 Q F0 2.5(syntax. Ag)2.5 F (ain, see `)-.05 E(`e)-.74 E -.15(xe)-.15 G(c').15 E('.)-.74 E(Since)128 562.8 Q F1(SIGINT)4.675 E F0(and)4.675 E F1(SIGQUIT)4.675 E F0 2.175 (are ignored during the e)4.675 F -.15(xe)-.15 G 2.175(cution of).15 F F1(system)4.675 E F0 4.675(,i)C 4.675(fy)-4.675 G 2.175(ou e)-4.675 F 2.175(xpect your)-.15 F .794(program to terminate on receipt of these s\ ignals you will need to arrange to do so yourself based on)128 574.8 R (the return v)128 586.8 Q(alue.)-.25 E F1 (@args = \("command", "arg1", "arg2"\);)152 604.8 Q (system\(@args\) == 0)152 616.8 Q(or die "system @args failed: $?")176 628.8 Q F0 1.902(If you')128 646.8 R 4.402(dl)-.5 G(ik)-4.402 E 4.402 (et)-.1 G 4.402(om)-4.402 G 1.902(anually inspect)-4.402 F F1(system) 4.401 E F0 3.001 -.55('s f)D 1.901(ailure, you can check all possible f) .45 F 1.901(ailure modes by)-.1 F(inspecting)128 658.8 Q F1($?)2.5 E F0 (lik)2.5 E 2.5(et)-.1 G(his:)-2.5 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 89)162.62 F 0 Cg EP %%Page: 90 90 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (if \($? == \2551\) {)152 84 Q(print "failed to execute: $!\\n";)176 96 Q(})152 108 Q(elsif \($? & 127\) {)152 120 Q (printf "child died with signal %d, %s coredump\\n",)176 132 Q (\($? & 127\),)200 144 Q(\($? & 128\) ? \010with\010 : \010without\010;) 12 E(})152 156 Q(else {)152 168 Q (printf "child exited with value %d\\n", $? >> 8;)176 180 Q(})152 192 Q F0(Alternati)128 210 Q -.15(ve)-.25 G(ly).15 E 2.625(,y)-.65 G .125 (ou may inspect the v)-2.625 F .125(alue of)-.25 F F1 (${^CHILD_ERROR_NATIVE})2.625 E F0 .125(with the)2.625 F F1(W*\(\))2.625 E F0 .125(calls from)2.625 F(the)128 222 Q/F2 9/Times-Roman@0 SF(POSIX) 2.5 E F0(module.)2.5 E(When)128 240 Q F1(system)2.604 E F0 1.204 -.55 ('s a)D -.18(rg).55 G .104(uments are e).18 F -.15(xe)-.15 G .104 (cuted indirectly by the shell, results and return codes are subject to) .15 F(its quirks.)128 252 Q(See `)5 E -.74(``)-.74 G(STRING`').74 E 2.5 ('i)-.74 G 2.5(np)-2.5 G(erlop and `)-2.5 E(`e)-.74 E -.15(xe)-.15 G(c') .15 E 2.5('f)-.74 G(or details.)-2.5 E(Since)128 270 Q F1(system)2.5 E F0(does a)2.5 E F1(fork)2.5 E F0(and)2.5 E F1(wait)2.5 E F0(it may af) 2.5 E(fect a)-.25 E F1(SIGCHLD)2.5 E F0(handler)2.5 E 2.5(.S)-.55 G (ee perlipc for details.)-2.5 E(syswrite)108 286.8 Q F2(FILEHANDLE)2.5 E F0(,SCALAR,LENGTH,OFFSET)A(syswrite)108 298.8 Q F2(FILEHANDLE)2.5 E F0 (,SCALAR,LENGTH)A(syswrite)108 310.8 Q F2(FILEHANDLE)2.5 E F0(,SCALAR)A .521(Attempts to write)128 322.8 R F2(LENGTH)3.021 E F0 .521 (bytes of data from v)3.021 F(ariable)-.25 E F2(SCALAR)3.021 E F0 .521 (to the speci\214ed)3.021 F F2(FILEHANDLE)3.021 E F0 3.022(,u)C(sing) -3.022 E/F3 10/Times-Italic@0 SF(write)128 334.8 Q F0 2.989(\(2\). If) 1.666 F F2(LENGTH)2.989 E F0 .488(is not speci\214ed, writes whole)2.989 F F2(SCALAR)2.988 E F0 5.488(.I)C 2.988(tb)-5.488 G .488(ypasses b) -2.988 F(uf)-.2 E(fered)-.25 E F2(IO)2.988 E F0 2.988(,s)C 2.988(om) -2.988 G .488(ixing this)-2.988 F 1.063(with reads \(other than)128 346.8 R F1(sysread\(\)\))3.563 E F0(,)A F1(print)3.563 E F0(,)A F1 (write)3.563 E F0(,)A F1(seek)3.563 E F0(,)A F1(tell)3.563 E F0 3.563 (,o)C(r)-3.563 E F1(eof)3.563 E F0 1.063(may cause confusion)3.563 F .613(because the perlio and stdio layers usually b)128 358.8 R(uf)-.2 E .613(fer data.)-.25 F .612 (Returns the number of bytes actually written,)5.613 F(or)128 370.8 Q F1 (undef)3.971 E F0 1.472(if there w)3.972 F 1.472 (as an error \(in this case the errno v)-.1 F(ariable)-.25 E F1($!)3.972 E F0 1.472(is also set\).)3.972 F 1.472(If the)6.472 F F2(LENGTH)3.972 E F0(is)3.972 E .291(greater than the data a)128 382.8 R -.25(va)-.2 G .291(ilable in the).25 F F2(SCALAR)2.791 E F0 .291(after the)2.791 F F2 (OFFSET)2.791 E F0 2.791(,o)C .291(nly as much data as is a)-2.791 F -.25(va)-.2 G .29(ilable will).25 F(be written.)128 394.8 Q(An)128 412.8 Q F2(OFFSET)3.115 E F0 .616(may be speci\214ed to write the data from s\ ome part of the string other than the be)3.115 F(ginning.)-.15 E 3.84 (An)128 424.8 S -2.25 -.15(eg a)-3.84 H(ti).15 E -.15(ve)-.25 G F2 (OFFSET)3.99 E F0 1.34(speci\214es writing that man)3.84 F 3.839(yc)-.15 G 1.339(haracters counting backw)-3.839 F 1.339 (ards from the end of the)-.1 F 2.5(string. If)128 436.8 R F2(SCALAR)2.5 E F0(is of length zero, you can only use an)2.5 E F2(OFFSET)2.5 E F0 (of 0.)2.5 E/F4 9/Times-Bold@0 SF -1.08(WA)128 454.8 S(RNING)1.08 E F0 4.215(:I)C 4.215(ft)-4.215 G 1.715(he \214lehandle is mark)-4.215 F(ed) -.1 E F1(:utf8)4.215 E F0 4.215(,U)C 1.715(nicode characters encoded in) -4.215 F F2(UTF\2558)4.216 E F0 1.716(are written)4.216 F 1.636 (instead of bytes, and the)128 466.8 R F2(LENGTH)4.136 E F0(,)A F2 (OFFSET)4.136 E F0 4.136(,a)C 1.636(nd return v)-4.136 F 1.636(alue of) -.25 F F3(syswrite\(\))4.136 E F0 1.635(are in \(UTF8\255encoded)4.135 F 4.722(Unicode\) characters.)128 478.8 R(The)9.722 E F1(:encoding\(...\)) 7.222 E F0 4.722(layer implicitly introduces the)7.222 F F1(:utf8)7.223 E F0(layer)7.223 E(.)-.55 E(Alternately)128 490.8 Q 2.58(,i)-.65 G 2.58 (ft)-2.58 G .08(he handle is not mark)-2.58 F .079 (ed with an encoding b)-.1 F .079 (ut you attempt to write characters with code)-.2 F(points o)128 502.8 Q -.15(ve)-.15 G 2.5(r2).15 G(55, raises an e)-2.5 E 2.5(xception. See) -.15 F -.74(``)2.5 G(binmode').74 E(', `)-.74 E(`open')-.74 E (', and the)-.74 E F1(open)2.5 E F0(pragma, open.)2.5 E(tell)108 519.6 Q F2(FILEHANDLE)2.5 E F0(tell)108 531.6 Q 1.813 (Returns the current position)128 531.6 R F3 1.813(in bytes)4.313 F F0 (for)4.313 E F2(FILEHANDLE)4.313 E F0 4.313(,o)C 4.314<72ad>-4.313 G 4.314(1o)-4.314 G 4.314(ne)-4.314 G(rror)-4.314 E(.)-.55 E F2 (FILEHANDLE)6.814 E F0 1.814(may be an)4.314 F -.15(ex)128 543.6 S .59 (pression whose v).15 F .59(alue gi)-.25 F -.15(ve)-.25 G 3.09(st).15 G .589(he name of the actual \214lehandle.)-3.09 F(If)5.589 E F2 (FILEHANDLE)3.089 E F0 .589(is omitted, assumes)3.089 F (the \214le last read.)128 555.6 Q .095(Note the)128 573.6 R F3 .095 (in bytes)2.595 F F0 2.595(:e)C -.15(ve)-2.845 G 2.595(ni).15 G 2.595 (ft)-2.595 G .095 (he \214lehandle has been set to operate on characters \(for e)-2.595 F .096(xample by using the)-.15 F F1(:encoding\(utf8\))128 585.6 Q F0 1.327(open layer\),)3.827 F F3(tell\(\))3.827 E F0 1.327 (will return byte of)3.827 F 1.326(fsets, not character of)-.25 F 1.326 (fsets \(because that)-.25 F -.1(wo)128 597.6 S(uld render).1 E F3 (seek\(\))2.5 E F0(and)2.5 E F3(tell\(\))2.5 E F0(rather slo)2.5 E(w\).) -.25 E .593(The return v)128 615.6 R .593(alue of)-.25 F F3(tell\(\)) 3.093 E F0 .593(for the standard streams lik)3.093 F 3.093(et)-.1 G(he) -3.093 E F2(STDIN)3.093 E F0 .594(depends on the operating system: it) 3.093 F(may return \2551 or something else.)128 627.6 Q F3(tell\(\))5 E F0(on pipes, \214fos, and sock)2.5 E(ets usually returns \2551.)-.1 E (There is no)128 645.6 Q F1(systell)2.5 E F0 2.5(function. Use)2.5 F F1 (sysseek\(FH, 0, 1\))2.5 E F0(for that.)2.5 E 1.86(Do not use)128 663.6 R F3(tell\(\))4.36 E F0 1.86(\(or other b)4.36 F(uf)-.2 E 1.859 (fered I/O operations\) on a \214lehandle that has been manipulated by) -.25 F F3(sysr)128 675.6 Q(ead\(\))-.37 E F0(,)A F3(syswrite\(\))2.5 E F0 2.5(,o)C(r)-2.5 E F3(sysseek\(\))2.5 E F0 5(.T)C (hose functions ignore the b)-5 E(uf)-.2 E(fering, while)-.25 E F3 (tell\(\))2.5 E F0(does not.)2.5 E(telldir)108 692.4 Q F2(DIRHANDLE)2.5 E F0 2.273(Returns the current position of the)128 704.4 R F1(readdir) 4.774 E F0 2.274(routines on)4.774 F F2(DIRHANDLE)4.774 E F0 7.274(.V)C 2.274(alue may be gi)-8.384 F -.15(ve)-.25 G 4.774(nt).15 G(o)-4.774 E F1(seekdir)128 716.4 Q F0 2.474 (to access a particular location in a directory)4.974 F(.)-.65 E F1 (telldir)7.473 E F0 2.473(has the same ca)4.973 F -.15(ve)-.2 G 2.473 (ats about).15 F(possible directory compaction as the corresponding sys\ tem library routine.)128 728.4 Q(perl v5.14.2)72 768 Q 198.17 (2011-10-01 90)162.62 F 0 Cg EP %%Page: 91 91 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(tie)108 84 Q/F1 9 /Times-Roman@0 SF -1.215(VA)2.5 G(RIABLE)1.215 E F0(,CLASSN)A(AME,LIST) -.35 E .256(This function binds a v)128 96 R .256 (ariable to a package class that will pro)-.25 F .257 (vide the implementation for the v)-.15 F(ariable.)-.25 E F1 -1.215(VA) 128 108 S(RIABLE)1.215 E F0 2.81(is the name of the v)5.31 F 2.809 (ariable to be enchanted.)-.25 F F1(CLASSN)7.809 E(AME)-.315 E F0 2.809 (is the name of a class)5.309 F .422 (implementing objects of correct type.)128 120 R(An)5.422 E 2.922(ya) -.15 G .422(dditional ar)-2.922 F .422(guments are passed to the)-.18 F /F2 10/Courier@0 SF(new)2.922 E F0 .422(method of the)2.922 F 4.427 (class \(meaning)128 132 R F2(TIESCALAR)6.927 E F0(,)A F2(TIEHANDLE) 6.927 E F0(,)A F2(TIEARRAY)6.927 E F0 6.927(,o)C(r)-6.927 E F2(TIEHASH) 6.927 E F0 6.926(\). T)B 4.426(ypically these are)-.8 F(ar)128 144 Q .972(guments such as might be passed to the)-.18 F F2(dbm_open\(\))3.472 E F0 .973(function of C.)3.473 F .973(The object returned by the)5.973 F F2(new)128 156 Q F0 .518(method is also returned by the)3.018 F F2(tie) 3.017 E F0 .517(function, which w)3.017 F .517(ould be useful if you w) -.1 F .517(ant to access other)-.1 F(methods in)128 168 Q F1(CLASSN)2.5 E(AME)-.315 E F0(.)A .267(Note that functions such as)128 186 R F2(keys) 2.767 E F0(and)2.767 E F2(values)2.768 E F0 .268 (may return huge lists when used on lar)2.768 F .268(ge objects, lik) -.18 F(e)-.1 E F1(DBM)128 198 Q F0 2.5(\214les. Y)2.5 F (ou may prefer to use the)-1.1 E F2(each)2.5 E F0(function to iterate o) 2.5 E -.15(ve)-.15 G 2.5(rs).15 G 2.5(uch. Example:)-2.5 F F2 6(#p)152 216 S(rint out history file offsets)-6 E(use NDBM_File;)152 228 Q (tie\(%HIST, \010NDBM_File\010, \010/usr/lib/news/history\010, 1, 0\);) 152 240 Q(while \(\($key,$val\) = each %HIST\) {)152 252 Q (print $key, \010 = \010, unpack\(\010L\010,$val\), "\\n";)176 264 Q(}) 152 276 Q(untie\(%HIST\);)152 288 Q F0 2.5(Ac)128 306 S (lass implementing a hash should ha)-2.5 E .3 -.15(ve t)-.2 H(he follo) .15 E(wing methods:)-.25 E F2(TIEHASH classname, LIST)152 324 Q (FETCH this, key)152 336 Q(STORE this, key, value)152 348 Q (DELETE this, key)152 360 Q(CLEAR this)152 372 Q(EXISTS this, key)152 384 Q(FIRSTKEY this)152 396 Q(NEXTKEY this, lastkey)152 408 Q (SCALAR this)152 420 Q(DESTROY this)152 432 Q(UNTIE this)152 444 Q F0 2.5(Ac)128 462 S(lass implementing an ordinary array should ha)-2.5 E .3 -.15(ve t)-.2 H(he follo).15 E(wing methods:)-.25 E F2 (TIEARRAY classname, LIST)152 480 Q(FETCH this, key)152 492 Q (STORE this, key, value)152 504 Q(FETCHSIZE this)152 516 Q (STORESIZE this, count)152 528 Q(CLEAR this)152 540 Q(PUSH this, LIST) 152 552 Q(POP this)152 564 Q(SHIFT this)152 576 Q(UNSHIFT this, LIST)152 588 Q(SPLICE this, offset, length, LIST)152 600 Q(EXTEND this, count)152 612 Q(DESTROY this)152 624 Q(UNTIE this)152 636 Q F0 2.5(Ac)128 654 S (lass implementing a \214lehandle should ha)-2.5 E .3 -.15(ve t)-.2 H (he follo).15 E(wing methods:)-.25 E(perl v5.14.2)72 768 Q 198.17 (2011-10-01 91)162.62 F 0 Cg EP %%Page: 92 92 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (TIEHANDLE classname, LIST)152 84 Q(READ this, scalar, length, offset) 152 96 Q(READLINE this)152 108 Q(GETC this)152 120 Q (WRITE this, scalar, length, offset)152 132 Q(PRINT this, LIST)152 144 Q (PRINTF this, format, LIST)152 156 Q(BINMODE this)152 168 Q(EOF this)152 180 Q(FILENO this)152 192 Q(SEEK this, position, whence)152 204 Q (TELL this)152 216 Q(OPEN this, mode, LIST)152 228 Q(CLOSE this)152 240 Q(DESTROY this)152 252 Q(UNTIE this)152 264 Q F0 2.5(Ac)128 282 S (lass implementing a scalar should ha)-2.5 E .3 -.15(ve t)-.2 H (he follo).15 E(wing methods:)-.25 E F1(TIESCALAR classname, LIST)152 300 Q(FETCH this,)152 312 Q(STORE this, value)152 324 Q(DESTROY this)152 336 Q(UNTIE this)152 348 Q F0 .326(Not all methods indicated abo)128 366 R .626 -.15(ve n)-.15 H .326(eed be implemented.).15 F .326 (See perltie, T)5.326 F .325(ie::Hash, T)-.35 F(ie::Array)-.35 E 2.825 (,T)-.65 G(ie::Scalar)-3.175 E(,)-.4 E(and T)128 378 Q(ie::Handle.)-.35 E(Unlik)128 396 Q(e)-.1 E F1(dbmopen)2.756 E F0 2.756(,t)C(he)-2.756 E F1(tie)2.756 E F0 .256(function will not)2.756 F F1(use)2.757 E F0(or) 2.757 E F1(require)2.757 E F0 2.757(am)2.757 G .257 (odule for you; you need to do that)-2.757 F -.15(ex)128 408 S (plicitly yourself.).15 E(See DB_File or the)5 E/F2 10/Times-Italic@0 SF (Con\214g)2.5 E F0(module for interesting)2.5 E F1(tie)2.5 E F0 (implementations.)2.5 E -.15(Fo)128 426 S 2.5(rf).15 G (urther details see perltie, `)-2.5 E(`tied)-.74 E/F3 9/Times-Roman@0 SF -1.215(VA)2.5 G(RIABLE)1.215 E F0 -.74('')C(.).74 E(tied)108 442.8 Q F3 -1.215(VA)2.5 G(RIABLE)1.215 E F0 .86 (Returns a reference to the object underlying)128 454.8 R F3 -1.215(VA) 3.36 G(RIABLE)1.215 E F0 .86(\(the same v)3.36 F .86(alue that w)-.25 F .86(as originally returned)-.1 F .304(by the)128 466.8 R F1(tie)2.804 E F0 .304(call that bound the v)2.804 F .305(ariable to a package.\))-.25 F .305(Returns the unde\214ned v)5.305 F .305(alue if)-.25 F F3 -1.215 (VA)2.805 G(RIABLE)1.215 E F0(isn')2.805 E(t)-.18 E(tied to a package.) 128 478.8 Q(time)108 495.6 Q 1.165 (Returns the number of non-leap seconds since whate)128 507.6 R -.15(ve) -.25 G 3.665(rt).15 G 1.164(ime the system considers to be the epoch,) -3.665 F 1.953(suitable for feeding to)128 519.6 R F1(gmtime)4.453 E F0 (and)4.453 E F1(localtime)4.453 E F0 4.454(.O)C 4.454(nm)-4.454 G 1.954 (ost systems the epoch is 00:00:00)-4.454 F F3(UTC)4.454 E F0(,)A .676 (January 1, 1970; a prominent e)128 531.6 R .676(xception being Mac)-.15 F F3(OS)3.176 E F0 .676(Classic which uses 00:00:00, January 1, 1904) 3.176 F(in the current local time zone for its epoch.)128 543.6 Q -.15 (Fo)128 561.6 S 3.169(rm).15 G .669 (easuring time in better granularity than one second, use the T)-3.169 F .67(ime::HiRes module from Perl 5.8)-.35 F(onw)128 573.6 Q 1.397 (ards \(or from)-.1 F F3(CP)3.897 E(AN)-.828 E F0 1.397 (before then\), or)3.897 F 3.897(,i)-.4 G 3.897(fy)-3.897 G 1.397(ou ha) -3.897 F -.15(ve)-.2 G F2 -.1(ge)4.047 G(ttimeofday).1 E F0 1.397 (\(2\), you may be able to use the)1.666 F F1(syscall)128 585.6 Q F0 (interf)2.5 E(ace of Perl.)-.1 E(See perlf)5 E(aq8 for details.)-.1 E -.15(Fo)128 603.6 S 3.316(rd).15 G .816 (ate and time processing look at the man)-3.316 F 3.317(yr)-.15 G .817 (elated modules on)-3.317 F F3(CP)3.317 E(AN)-.828 E F0 5.817(.F)C .817 (or a comprehensi)-5.967 F 1.117 -.15(ve d)-.25 H(ate).15 E (and time representation look at the DateT)128 615.6 Q(ime module.)-.35 E(times)108 632.4 Q .214(Returns a four)128 644.4 R .214 (-element list gi)-.2 F .213 (ving the user and system times in seconds for this process and an)-.25 F 2.713(ye)-.15 G(xited)-2.863 E(children of this process.)128 656.4 Q F1(\($user,$system,$cuser,$csystem\) = times;)152 674.4 Q F0 (In scalar conte)128 692.4 Q(xt,)-.15 E F1(times)2.5 E F0(returns)2.5 E F1($user)2.5 E F0(.)A(Children')128 710.4 Q 2.5(st)-.55 G (imes are only included for terminated children.)-2.5 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 92)162.62 F 0 Cg EP %%Page: 93 93 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(tr///)108 84 Q (The transliteration operator)128 84 Q 5(.S)-.55 G(ame as)-5 E/F1 10 /Courier@0 SF(y///)2.5 E F0 5(.S)C(ee `)-5 E(`Quote and Quote-lik)-.74 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E (truncate)108 100.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(,LENGTH) A(truncate)108 112.8 Q F2(EXPR)2.5 E F0(,LENGTH)A -.35(Tr)128 124.8 S 1.43(uncates the \214le opened on).35 F F2(FILEHANDLE)3.93 E F0 3.93(,o) C 3.93(rn)-3.93 G 1.43(amed by)-3.93 F F2(EXPR)3.931 E F0 3.931(,t)C 3.931(ot)-3.931 G 1.431(he speci\214ed length.)-3.931 F 1.431(Raises an) 6.431 F -.15(ex)128 136.8 S(ception if truncate isn').15 E 2.5(ti)-.18 G (mplemented on your system.)-2.5 E(Returns true if successful,)5 E F1 (undef)2.5 E F0(on error)2.5 E(.)-.55 E(The beha)128 154.8 Q (vior is unde\214ned if)-.2 E F2(LENGTH)2.5 E F0 (is greater than the length of the \214le.)2.5 E .542 (The position in the \214le of)128 172.8 R F2(FILEHANDLE)3.041 E F0 .541 (is left unchanged.)3.041 F -1.1(Yo)5.541 G 3.041(um)1.1 G .541(ay w) -3.041 F .541(ant to call seek before writing)-.1 F(to the \214le.)128 184.8 Q(uc)108 201.6 Q F2(EXPR)2.5 E F0(uc)108 213.6 Q .572 (Returns an uppercased v)128 213.6 R .572(ersion of)-.15 F F2(EXPR)3.072 E F0 5.572(.T)C .572(his is the internal function implementing the) -5.572 F F1(\\U)3.073 E F0 .573(escape in)3.073 F .438 (double-quoted strings.)128 225.6 R .438 (It does not attempt to do titlecase mapping on initial letters.)5.438 F .438(See `)5.438 F(`uc\214rst')-.74 E 2.938('f)-.74 G(or)-2.938 E(that.) 128 237.6 Q(If)128 255.6 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1 ($_)2.5 E F0(.)A(This function beha)128 273.6 Q -.15(ve)-.2 G 2.5(st).15 G(he same w)-2.5 E(ay under v)-.1 E (arious pragma, such as in a locale, as `)-.25 E(`lc')-.74 E 2.5('d)-.74 G(oes.)-2.5 E(uc\214rst)108 290.4 Q F2(EXPR)2.5 E F0(uc\214rst)108 302.4 Q 1.45(Returns the v)128 314.4 R 1.45(alue of)-.25 F F2(EXPR)3.95 E F0 1.45(with the \214rst character in uppercase \(titlecase in Unicode\).) 3.95 F 1.451(This is the)6.451 F(internal function implementing the)128 326.4 Q F1(\\u)2.5 E F0(escape in double-quoted strings.)2.5 E(If)128 344.4 Q F2(EXPR)2.5 E F0(is omitted, uses)2.5 E F1($_)2.5 E F0(.)A (This function beha)128 362.4 Q -.15(ve)-.2 G 2.5(st).15 G(he same w) -2.5 E(ay under v)-.1 E(arious pragma, such as in a locale, as `)-.25 E (`lc')-.74 E 2.5('d)-.74 G(oes.)-2.5 E(umask)108 379.2 Q F2(EXPR)2.5 E F0(umask)108 391.2 Q 1.039(Sets the umask for the process to)128 403.2 R F2(EXPR)3.538 E F0 1.038(and returns the pre)3.538 F 1.038(vious v)-.25 F 3.538(alue. If)-.25 F F2(EXPR)3.538 E F0 1.038(is omitted, merely) 3.538 F(returns the current umask.)128 415.2 Q .027(The Unix permission) 128 433.2 R F1<72777872ad78adadad>2.527 E F0 .028 (is represented as three sets of three bits, or three octal digits:) 2.527 F F1(0750)2.528 E F0 2.352 (\(the leading 0 indicates octal and isn')128 445.2 R 4.852(to)-.18 G 2.352(ne of the digits\).)-4.852 F(The)7.352 E F1(umask)4.852 E F0 -.25 (va)4.852 G 2.351(lue is such a number).25 F 2.305 (representing disabled permissions bits.)128 457.2 R 2.306 (The permission \(or `)7.306 F(`mode')-.74 E 2.306('\) v)-.74 F 2.306 (alues you pass)-.25 F F1(mkdir)4.806 E F0(or)4.806 E F1(sysopen)128 469.2 Q F0 .3(are modi\214ed by your umask, so e)2.8 F -.15(ve)-.25 G 2.8(ni).15 G 2.8(fy)-2.8 G .3(ou tell)-2.8 F F1(sysopen)2.8 E F0 .3 (to create a \214le with permissions)2.8 F F1(0777)128 481.2 Q F0 3.204 (,i)C 3.204(fy)-3.204 G .704(our umask is)-3.204 F F1(0022)3.204 E F0 3.205(,t)C .705 (hen the \214le will actually be created with permissions)-3.205 F F1 (0755)3.205 E F0 5.705(.I)C 3.205(fy)-5.705 G(our)-3.205 E F1(umask)128 493.2 Q F0(were)3.439 E F1(0027)3.439 E F0 .939(\(group can')3.439 F 3.439(tw)-.18 G .939(rite; others can')-3.439 F 3.439(tr)-.18 G .938 (ead, write, or e)-3.439 F -.15(xe)-.15 G .938(cute\), then passing).15 F F1(sysopen)3.438 E(0666)128 505.2 Q F0 -.1(wo)2.5 G (uld create a \214le with mode).1 E F1(0640)2.5 E F0(\(because)2.5 E F1 (0666 &~ 027)2.5 E F0(is)2.5 E F1(0640)2.5 E F0(\).)A(Here')128 523.2 Q 2.581(ss)-.55 G .081(ome advice: supply a creation mode of)-2.581 F F1 (0666)2.582 E F0 .082(for re)2.582 F .082(gular \214les \(in)-.15 F F1 (sysopen)2.582 E F0 2.582(\)a)C .082(nd one of)-2.582 F F1(0777)2.582 E F0 .676(for directories \(in)128 535.2 R F1(mkdir)3.176 E F0 3.176(\)a)C .676(nd e)-3.176 F -.15(xe)-.15 G .676(cutable \214les.).15 F .676 (This gi)5.676 F -.15(ve)-.25 G 3.176(su).15 G .675 (sers the freedom of choice: if the)-3.176 F 3.175(yw)-.15 G(ant)-3.275 E 1.404(protected \214les, the)128 547.2 R 3.904(ym)-.15 G 1.404 (ight choose process umasks of)-3.904 F F1(022)3.904 E F0(,)A F1(027) 3.904 E F0 3.904(,o)C 3.905(re)-3.904 G -.15(ve)-4.155 G 3.905(nt).15 G 1.405(he particularly antisocial)-3.905 F 1.996(mask of)128 559.2 R F1 (077)4.496 E F0 6.996(.P)C 1.996(rograms should rarely if e)-6.996 F -.15(ve)-.25 G 4.496(rm).15 G(ak)-4.496 E 4.496(ep)-.1 G(olic)-4.496 E 4.496(yd)-.15 G 1.995(ecisions better left to the user)-4.496 F 6.995 (.T)-.55 G(he)-6.995 E -.15(ex)128 571.2 S 1.265 (ception to this is when writing \214les that should be k).15 F 1.266 (ept pri)-.1 F -.25(va)-.25 G 1.266(te: mail \214les, web bro).25 F 1.266(wser cookies,)-.25 F/F3 10/Times-Italic@0 SF(.rhosts)128 583.2 Q F0(\214les, and so on.)2.5 E(If)128 601.2 Q F3(umask)2.955 E F0 .454(\(\ 2\) is not implemented on your system and you are trying to restrict ac\ cess for)1.666 F F3(your)2.954 E(self)-.1 E F0(\(i.e.,)2.954 E F1 .012 (\(EXPR & 0700\) > 0)128 613.2 R F0 .012(\), raises an e)B 2.512 (xception. If)-.15 F F3(umask)2.512 E F0 .012 (\(2\) is not implemented and you are not trying)1.666 F (to restrict access for yourself, returns)128 625.2 Q F1(undef)2.5 E F0 (.)A .516(Remember that a umask is a number)128 643.2 R 3.016(,u)-.4 G .516(sually gi)-3.016 F -.15(ve)-.25 G 3.016(ni).15 G 3.016(no)-3.016 G .516(ctal; it is)-3.016 F F3(not)3.016 E F0 3.016(as)3.016 G .516 (tring of octal digits.)-3.016 F .516(See also)5.516 F -.74(``)128 655.2 S(oct').74 E(', if all you ha)-.74 E .3 -.15(ve i)-.2 H 2.5(sas).15 G (tring.)-2.5 E(undef)108 672 Q F2(EXPR)2.5 E F0(undef)108 684 Q .142 (Unde\214nes the v)128 696 R .143(alue of)-.25 F F2(EXPR)2.643 E F0 2.643(,w)C .143(hich must be an lv)-2.643 F 2.643(alue. Use)-.25 F .143 (only on a scalar v)2.643 F .143(alue, an array \(using)-.25 F F1(@) 2.643 E F0(\),)A 3.646(ah)128 708 S 1.146(ash \(using)-3.646 F F1(%) 3.646 E F0 1.146(\), a subroutine \(using)B F1(&)3.645 E F0 1.145 (\), or a type)B 1.145(glob \(using)-.15 F F1(*)3.645 E F0 3.645 (\). Saying)B F1 1.145(undef $hash{$key})3.645 F F0 1.119 (will probably not do what you e)128 720 R 1.119 (xpect on most prede\214ned v)-.15 F 1.119(ariables or)-.25 F F2(DBM) 3.619 E F0 1.12(list v)3.62 F 1.12(alues, so don')-.25 F 3.62(td)-.18 G (o)-3.62 E(perl v5.14.2)72 768 Q 198.17(2011-10-01 93)162.62 F 0 Cg EP %%Page: 94 94 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .068 (that; see delete.)128 84 R(Al)5.068 E -.1(wa)-.1 G .068 (ys returns the unde\214ned v).1 F 2.568(alue. Y)-.25 F .068 (ou can omit the)-1.1 F/F1 9/Times-Roman@0 SF(EXPR)2.568 E F0 2.568(,i)C 2.568(nw)-2.568 G .068(hich case nothing is)-2.568 F .676 (unde\214ned, b)128 96 R .677(ut you still get an unde\214ned v)-.2 F .677(alue that you could, for instance, return from a subroutine,)-.25 F (assign to a v)128 108 Q(ariable, or pass as a parameter)-.25 E 5(.E) -.55 G(xamples:)-5 E/F2 10/Courier@0 SF(undef $foo;)152 126 Q (undef $bar{\010blurfl\010};)152 138 Q 6(#C)36 G (ompare to: delete $bar{\010blurfl\010};)-6 E(undef @ary;)152 150 Q (undef %hash;)152 162 Q(undef &mysub;)152 174 Q(undef *xyz;)152 186 Q 6 (#d)42 G(estroys $xyz, @xyz, %xyz, &xyz, etc.)-6 E (return \(wantarray ? \(undef, $errmsg\) : undef\) if $they_blew_it;)152 198 Q(select undef, undef, undef, 0.25;)152 210 Q (\($a, $b, undef, $c\) = &foo;)152 222 Q 6(#I)42 G (gnore third value returned)-6 E F0(Note that this is a unary operator) 128 240 Q 2.5(,n)-.4 G(ot a list operator)-2.5 E(.)-.55 E(unlink)108 256.8 Q F1(LIST)2.5 E F0(unlink)108 268.8 Q .829(Deletes a list of \214\ les. On success, it returns the number of \214les it successfully delet\ ed. On f)128 280.8 R .829(ailure, it)-.1 F(returns f)128 292.8 Q (alse and sets)-.1 E F2($!)2.5 E F0(\(errno\):)5 E F2 (my $unlinked = unlink \010a\010, \010b\010, \010c\010;)152 310.8 Q (unlink @goners;)152 322.8 Q(unlink glob "*.bak";)152 334.8 Q F0 .547 (On error)128 352.8 R(,)-.4 E F2(unlink)3.047 E F0 .548 (will not tell you which \214les it could not remo)3.048 F -.15(ve)-.15 G 5.548(.I).15 G 3.048(fy)-5.548 G .548(ou w)-3.048 F .548(ant to kno) -.1 F 3.048(ww)-.25 G .548(hich \214les)-3.048 F(you could not remo)128 364.8 Q -.15(ve)-.15 G 2.5(,t).15 G(ry them one at a time:)-2.5 E F2 (foreach my $file \( @goners \) {)158 382.8 Q (unlink $file or warn "Could not unlink $file: $!";)182 394.8 Q(})158 406.8 Q F0(Note:)128 424.8 Q F2(unlink)4.362 E F0 1.862(will not attemp\ t to delete directories unless you are superuser and the)4.362 F/F3 10 /Times-Bold@0 SF4.362 E F0 1.861(\215ag is)4.361 F 1.463 (supplied to Perl. Ev)128 436.8 R 1.463 (en if these conditions are met, be w)-.15 F 1.463 (arned that unlinking a directory can in\215ict)-.1 F .23 (damage on your \214lesystem.)128 448.8 R(Finally)5.23 E 2.729(,u)-.65 G (sing)-2.729 E F2(unlink)2.729 E F0 .229 (on directories is not supported on man)2.729 F 2.729(yo)-.15 G (perating)-2.729 E 2.5(systems. Use)128 460.8 R F2(rmdir)2.5 E F0 (instead.)2.5 E(If)128 478.8 Q F1(LIST)2.5 E F0(is omitted,)2.5 E F2 (unlink)2.5 E F0(uses)2.5 E F2($_)2.5 E F0(.)A(unpack)108 495.6 Q F1 (TEMPLA)2.5 E(TE)-.999 E F0(,EXPR)A(unpack)108 507.6 Q F1(TEMPLA)2.5 E (TE)-.999 E F2(unpack)128 519.6 Q F0 .37(does the re)2.87 F -.15(ve)-.25 G .37(rse of).15 F F2(pack)2.87 E F0 2.87(:i)C 2.87(tt)-2.87 G(ak)-2.87 E .37(es a string and e)-.1 F .37(xpands it out into a list of v)-.15 F 2.87(alues. \(In)-.25 F(scalar)2.87 E(conte)128 531.6 Q (xt, it returns merely the \214rst v)-.15 E(alue produced.\))-.25 E(If) 128 549.6 Q F1(EXPR)2.5 E F0(is omitted, unpacks the)2.5 E F2($_)2.5 E F0 2.5(string. See)2.5 F (perlpacktut for an introduction to this function.)2.5 E .073 (The string is brok)128 567.6 R .073(en into chunks described by the)-.1 F F1(TEMPLA)2.573 E(TE)-.999 E F0 5.072(.E)C .072(ach chunk is con) -5.072 F -.15(ve)-.4 G .072(rted separately to a).15 F -.25(va)128 579.6 S 3.783(lue. T).25 F(ypically)-.8 E 3.783(,e)-.65 G 1.284 (ither the string is a result of)-3.783 F F2(pack)3.784 E F0 3.784(,o)C 3.784(rt)-3.784 G 1.284(he characters of the string represent a C)-3.784 F(structure of some kind.)128 591.6 Q(The)128 609.6 Q F1(TEMPLA)2.5 E (TE)-.999 E F0(has the same format as in the)2.5 E F2(pack)2.5 E F0 2.5 (function. Here')2.5 F 2.5(sas)-.55 G(ubroutine that does substring:) -2.5 E F2(sub substr {)152 627.6 Q(my\($what,$where,$howmuch\) = @_;)176 639.6 Q(unpack\("x$where a$howmuch", $what\);)176 651.6 Q(})152 663.6 Q F0(and then there')128 681.6 Q(s)-.55 E F2 (sub ordinal { unpack\("W",$_[0]\); } # same as ord\(\))152 699.6 Q F0 .546(In addition to \214elds allo)128 717.6 R .546(wed in)-.25 F/F4 10 /Times-Italic@0 SF(pac)3.046 E(k\(\))-.2 E F0 3.046(,y)C .545 (ou may pre\214x a \214eld with a % to indicate that you)-3.046 F -.1(wa)128 729.6 S 1.563(nt a \255bit checksum of the items i\ nstead of the items themselv).1 F 4.063(es. Def)-.15 F 1.563 (ault is a 16\255bit)-.1 F(perl v5.14.2)72 768 Q 198.17(2011-10-01 94) 162.62 F 0 Cg EP %%Page: 95 95 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E 3.157 (checksum. Checksum)128 84 R .657(is calculated by summing numeric v) 3.157 F .657(alues of e)-.25 F .657(xpanded v)-.15 F .657 (alues \(for string \214elds)-.25 F(the sum of)128 96 Q/F1 10/Courier@0 SF(ord\($char\))2.5 E F0(is tak)2.5 E (en; for bit \214elds the sum of zeroes and ones\).)-.1 E -.15(Fo)128 114 S 2.5(re).15 G(xample, the follo)-2.65 E (wing computes the same number as the System V sum program:)-.25 E F1 ($checksum = do {)152 132 Q(local $/;)176 144 Q 6(#s)12 G(lurp!)-6 E (unpack\("%32W*",<>\) % 65535;)176 156 Q(};)152 168 Q F0(The follo)128 186 Q(wing ef)-.25 E (\214ciently counts the number of set bits in a bit v)-.25 E(ector:)-.15 E F1($setbits = unpack\("%32b*", $selectmask\);)152 204 Q F0(The)128 222 Q F1(p)3.005 E F0(and)3.005 E F1(P)3.005 E F0 .505 (formats should be used with care.)3.005 F .505(Since Perl has no w) 5.505 F .506(ay of checking whether the v)-.1 F(alue)-.25 E 1.971 (passed to)128 234 R F1(unpack\(\))4.471 E F0 1.971(corresponds to a v) 4.471 F 1.971(alid memory location, passing a pointer v)-.25 F 1.97 (alue that')-.25 F 4.47(sn)-.55 G(ot)-4.47 E(kno)128 246 Q(wn to be v) -.25 E(alid is lik)-.25 E(ely to ha)-.1 E .3 -.15(ve d)-.2 H (isastrous consequences.).15 E 1.895(If there are more pack codes or if\ the repeat count of a \214eld or a group is lar)128 264 R 1.895 (ger than what the)-.18 F .349(remainder of the input string allo)128 276 R .349(ws, the result is not well de\214ned: the repeat count may b\ e decreased,)-.25 F(or)128 288 Q F1(unpack\(\))2.81 E F0 .31 (may produce empty strings or zeros, or it may raise an e)2.81 F 2.811 (xception. If)-.15 F .311(the input string is)2.811 F (longer than one described by the)128 300 Q/F2 9/Times-Roman@0 SF (TEMPLA)2.5 E(TE)-.999 E F0 2.5(,t)C (he remainder of that input string is ignored.)-2.5 E(See `)128 318 Q (`pack')-.74 E 2.5('f)-.74 G(or more e)-2.5 E(xamples and notes.)-.15 E (untie)108 334.8 Q F2 -1.215(VA)2.5 G(RIABLE)1.215 E F0 .455 (Breaks the binding between a v)128 346.8 R .455(ariable and a package.) -.25 F(\(See)5.455 E F1(tie)2.955 E F0 2.955(.\) Has)B .455(no ef)2.955 F .455(fect if the v)-.25 F .455(ariable is not)-.25 F(tied.)128 358.8 Q (unshift)108 375.6 Q F2(ARRA)2.5 E(Y)-.945 E F0(,LIST)A(unshift)108 387.6 Q F2(EXPR)2.5 E F0(,LIST)A 2.219(Does the opposite of a)128 399.6 R F1(shift)4.719 E F0 7.219(.O)C 4.719(rt)-7.219 G 2.219 (he opposite of a)-4.719 F F1(push)4.72 E F0 4.72(,d)C 2.22 (epending on ho)-4.72 F 4.72(wy)-.25 G 2.22(ou look at it.)-4.72 F (Prepends list to the front of the array and returns the ne)128 411.6 Q 2.5(wn)-.25 G(umber of elements in the array)-2.5 E(.)-.65 E F1 (unshift\(@ARGV, \010\255e\010\) unless $ARGV[0] =~ /^\255/;)152 429.6 Q F0 .881(Note the)128 447.6 R F2(LIST)3.38 E F0 .88(is prepended whole, \ not one element at a time, so the prepended elements stay in the)3.38 F (same order)128 459.6 Q 5(.U)-.55 G(se)-5 E F1(reverse)2.5 E F0 (to do the re)2.5 E -.15(ve)-.25 G(rse.).15 E 2.513 (Starting with Perl 5.14,)128 477.6 R F1(unshift)5.013 E F0 2.513 (can tak)5.013 F 5.013(eas)-.1 G(calar)-5.013 E F2(EXPR)5.014 E F0 5.014 (,w)C 2.514(hich must hold a reference to an)-5.014 F 2.445 (unblessed array)128 489.6 R 7.445(.T)-.65 G 2.445(he ar)-7.445 F 2.445 (gument will be dereferenced automatically)-.18 F 7.445(.T)-.65 G 2.445 (his aspect of)-7.445 F F1(unshift)4.945 E F0(is)4.945 E (considered highly e)128 501.6 Q 2.5(xperimental. The)-.15 F -.15(ex)2.5 G(act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E(use Module)108 518.4 Q F2 .25(VERSION LIST)2.5 F F0(use Module) 108 530.4 Q F2(VERSION)2.5 E F0(use Module)108 542.4 Q F2(LIST)2.5 E F0 (use Module)108 554.4 Q(use)108 566.4 Q F2(VERSION)2.5 E F0 .009(Import\ s some semantics into the current package from the named module, genera\ lly by aliasing certain)128 578.4 R(subroutine or v)128 590.4 Q (ariable names into your package.)-.25 E(It is e)5 E(xactly equi)-.15 E -.25(va)-.25 G(lent to).25 E F1 (BEGIN { require Module; Module\255>import\( LIST \); })152 608.4 Q F0 -.15(ex)128 626.4 S(cept that Module).15 E/F3 10/Times-Italic@0 SF(must) 2.5 E F0(be a bare)2.5 E -.1(wo)-.25 G 2.5(rd. The).1 F (importation can be made conditional; see if.)2.5 E 1.517 (In the peculiar)128 644.4 R F1 1.516(use VERSION)4.017 F F0(form,)4.016 E F2(VERSION)4.016 E F0 1.516(may be either a positi)4.016 F 1.816 -.15 (ve d)-.25 H 1.516(ecimal fraction such as).15 F .001 (5.006, which will be compared to)128 656.4 R F1($])2.501 E F0 2.501(,o) C 2.501(rav)-2.501 G .001 (\255string of the form v5.6.1, which will be compared to)-2.501 F F1 ($^V)2.502 E F0(\(aka)128 668.4 Q F1($PERL_VERSION)2.655 E F0 2.655 (\). An)B -.15(ex)2.655 G .155(ception is raised if).15 F F2(VERSION) 2.655 E F0 .155(is greater than the v)2.655 F .154 (ersion of the current)-.15 F .307(Perl interpreter; Perl will not atte\ mpt to parse the rest of the \214le.)128 680.4 R .307(Compare with `) 5.307 F(`require')-.74 E .307(', which can)-.74 F .653 (do a similar check at run time.)128 692.4 R(Symmetrically)5.652 E(,) -.65 E F1 .652(no VERSION)3.152 F F0(allo)3.152 E .652 (ws you to specify that you w)-.25 F .652(ant a)-.1 F -.15(ve)128 704.4 S(rsion of Perl older than the speci\214ed one.).15 E(Specifying)128 722.4 Q F2(VERSION)3.497 E F0 .998 (as a literal of the form v5.6.1 should generally be a)3.497 F -.2(vo) -.2 G .998(ided, because it leads to).2 F(perl v5.14.2)72 768 Q 198.17 (2011-10-01 95)162.62 F 0 Cg EP %%Page: 96 96 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E .13 (misleading error messages under earlier v)128 84 R .129 (ersions of Perl \(that is, prior to 5.6.0\) that do not support this) -.15 F 2.5(syntax. The)128 96 R(equi)2.5 E -.25(va)-.25 G (lent numeric v).25 E(ersion should be used instead.)-.15 E/F1 10 /Courier@0 SF(use v5.6.1;)152 114 Q 6(#c)30 G(ompile time version check) -6 E(use 5.6.1;)152 126 Q 6(#d)36 G(itto)-6 E(use 5.006_001;)152 138 Q 6 (#d)12 G(itto; preferred for backwards compatibility)-6 E F0 .656 (This is often useful if you need to check the current Perl v)128 156 R .657(ersion before)-.15 F F1(use)3.157 E F0 .657 (ing library modules that)B -.1(wo)128 168 S(n').1 E 2.5(tw)-.18 G (ork with older v)-2.6 E(ersions of Perl.)-.15 E(\(W)5 E 2.5(et)-.8 G (ry not to do this more than we ha)-2.5 E .3 -.15(ve t)-.2 H(o.\)).15 E .545(Also, if the speci\214ed Perl v)128 186 R .544 (ersion is greater than or equal to 5.9.5,)-.15 F F1 .544(use VERSION) 3.044 F F0 .544(will also load the)3.044 F F1(feature)128 198 Q F0 .155 (pragma and enable all features a)2.655 F -.25(va)-.2 G .155 (ilable in the requested v).25 F 2.655(ersion. See)-.15 F 2.655 (feature. Similarly)2.655 F 2.655(,i)-.65 G(f)-2.655 E .062 (the speci\214ed Perl v)128 210 R .061 (ersion is greater than or equal to 5.11.0, strictures are enabled le) -.15 F .061(xically as with)-.15 F F1(use)2.561 E(strict)128 222 Q F0 (\(e)2.5 E(xcept that the)-.15 E/F2 10/Times-Italic@0 SF(strict.pm)2.5 E F0(\214le is not actually loaded\).)2.5 E(The)128 240 Q F1(BEGIN)2.588 E F0 .088(forces the)2.588 F F1(require)2.588 E F0(and)2.588 E F1(import) 2.588 E F0 .088(to happen at compile time.)2.588 F(The)5.088 E F1 (require)2.588 E F0(mak)2.588 E .088(es sure)-.1 F 1.462 (the module is loaded into memory if it hasn')128 252 R 3.962(tb)-.18 G 1.462(een yet.)-3.962 F(The)6.462 E F1(import)3.961 E F0 1.461 (is not a b)3.961 F 1.461(uiltin; it')-.2 F 3.961(sj)-.55 G 1.461 (ust an)-3.961 F .698(ordinary static method call into the)128 264 R F1 (Module)3.198 E F0 .698 (package to tell the module to import the list of features)3.198 F 1.76 (back into the current package.)128 276 R 1.76 (The module can implement its)6.76 F F1(import)4.26 E F0 1.76(method an) 4.26 F 4.26(yw)-.15 G 1.76(ay it lik)-4.36 F(es,)-.1 E .046 (though most modules just choose to deri)128 288 R .346 -.15(ve t)-.25 H (heir).15 E F1(import)2.546 E F0 .047(method via inheritance from the) 2.547 F F1(Exporter)2.547 E F0 .954(class that is de\214ned in the)128 300 R F1(Exporter)3.454 E F0 3.454(module. See)3.454 F(Exporter)3.454 E 5.954(.I)-.55 G 3.454(fn)-5.954 G(o)-3.454 E F1(import)3.454 E F0 .953 (method can be found)3.453 F(then the call is skipped, e)128 312 Q -.15 (ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(here is an)-2.5 E/F3 9 /Times-Roman@0 SF -.495(AU)2.5 G -.162(TO).495 G(LO).162 E(AD)-.315 E F0 (method.)2.5 E .558(If you do not w)128 330 R .559 (ant to call the package')-.1 F(s)-.55 E F1(import)3.059 E F0 .559 (method \(for instance, to stop your namespace from)3.059 F (being altered\), e)128 342 Q(xplicitly supply the empty list:)-.15 E F1 (use Module \(\);)152 360 Q F0(That is e)128 378 Q(xactly equi)-.15 E -.25(va)-.25 G(lent to).25 E F1(BEGIN { require Module })152 396 Q F0 .748(If the)128 414 R F3(VERSION)3.248 E F0(ar)3.248 E .747 (gument is present between Module and)-.18 F F3(LIST)3.247 E F0 3.247 (,t)C .747(hen the)-3.247 F F1(use)3.247 E F0 .747(will call the)3.247 F F3(VERSION)3.247 E F0 2.32(method in class Module with the gi)128 426 R -.15(ve)-.25 G 4.82(nv).15 G 2.32(ersion as an ar)-4.97 F 4.82 (gument. The)-.18 F(def)4.821 E(ault)-.1 E F3(VERSION)4.821 E F0 (method,)4.821 E .038(inherited from the)128 438 R F3(UNIVERSAL)2.538 E F0 .038(class, croaks if the gi)2.538 F -.15(ve)-.25 G 2.538(nv).15 G .038(ersion is lar)-2.688 F .038(ger than the v)-.18 F .038 (alue of the v)-.25 F(ariable)-.25 E F1($Module::VERSION)128 450 Q F0(.) A(Ag)128 468 Q 2.205(ain, there is a distinction between omitting)-.05 F F3(LIST)4.706 E F0(\()4.706 E F1(import)A F0 2.206(called with no ar) 4.706 F 2.206(guments\) and an)-.18 F -.15(ex)128 480 S(plicit empty).15 E F3(LIST)2.5 E F1(\(\))2.5 E F0(\()2.5 E F1(import)A F0(not called\).) 2.5 E(Note that there is no comma after)5 E F3(VERSION)2.5 E F0(!)A 1.005(Because this is a wide-open interf)128 498 R 1.005 (ace, pragmas \(compiler directi)-.1 F -.15(ve)-.25 G 1.004 (s\) are also implemented this w).15 F(ay)-.1 E(.)-.65 E (Currently implemented pragmas are:)128 510 Q F1(use constant;)152 528 Q (use diagnostics;)152 540 Q(use integer;)152 552 Q(use sigtrap)152 564 Q (qw\(SEGV BUS\);)12 E(use strict)152 576 Q(qw\(subs vars refs\);)18 E (use subs)152 588 Q(qw\(afunc blurfl\);)30 E(use warnings qw\(all\);)152 600 Q(use sort)152 612 Q(qw\(stable _quicksort _mergesort\);)30 E F0 2.502(Some of these pseudo-modules import semantics into the current bl\ ock scope \(lik)128 630 R(e)-.1 E F1(strict)5.003 E F0(or)5.003 E F1 (integer)128 642 Q F0 4.92(,u)C(nlik)-4.92 E 4.92(eo)-.1 G 2.42(rdinary\ modules, which import symbols into the current package \(which are) -4.92 F(ef)128 654 Q(fecti)-.25 E .3 -.15(ve t)-.25 H (hrough the end of the \214le\).).15 E(Because)128 672 Q F1(use)3.966 E F0(tak)3.966 E 1.467(es ef)-.1 F 1.467(fect at compile time, it doesn') -.25 F 3.967(tr)-.18 G 1.467(espect the ordinary \215o)-3.967 F 3.967 (wc)-.25 G 1.467(ontrol of the code)-3.967 F .235(being compiled.)128 684 R .235(In particular)5.235 F 2.735(,p)-.4 G .235(utting a)-2.735 F F1(use)2.735 E F0 .234(inside the f)2.734 F .234 (alse branch of a conditional doesn')-.1 F 2.734(tp)-.18 G(re)-2.734 E -.15(ve)-.25 G .234(nt it).15 F .454(from being processed.)128 696 R .454(If a module or pragma only needs to be loaded conditionally)5.454 F 2.954(,t)-.65 G .455(his can be done)-2.954 F(using the if pragma:)128 708 Q(perl v5.14.2)72 768 Q 198.17(2011-10-01 96)162.62 F 0 Cg EP %%Page: 97 97 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use if $] < 5.008, "utf8";)152 84 Q (use if WANT_WARNINGS, warnings => qw\(all\);)152 96 Q F0(There')128 114 Q 4.987(sac)-.55 G(orresponding)-4.987 E F1(no)4.986 E F0 2.486 (declaration that unimports meanings imported by)4.986 F F1(use)4.986 E F0 4.986(,i)C 2.486(.e., it calls)-4.986 F F1 .038(unimport Module LIST) 128 126 R F0 .039(instead of)2.538 F F1(import)2.539 E F0 5.039(.I)C 2.539(tb)-5.039 G(eha)-2.539 E -.15(ve)-.2 G 2.539(sj).15 G .039(ust as) -2.539 F F1(import)2.539 E F0 .039(does with)2.539 F/F2 9/Times-Roman@0 SF(VERSION)2.539 E F0 2.539(,a)C(n)-2.539 E(omitted or empty)128 138 Q F2(LIST)2.5 E F0 2.5(,o)C 2.5(rn)-2.5 G 2.5(ou)-2.5 G (nimport method being found.)-2.5 E F1(no integer;)152 156 Q (no strict \010refs\010;)152 168 Q(no warnings;)152 180 Q F0 .355 (Care should be tak)128 198 R .355(en when using the)-.1 F F1 .355 (no VERSION)2.855 F F0 .355(form of)2.855 F F1(no)2.854 E F0 5.354(.I)C 2.854(ti)-5.354 G(s)-2.854 E/F3 10/Times-Italic@0 SF(only)2.854 E F0 .354(meant to be used to assert)2.854 F .287 (that the running Perl is of a earlier v)128 210 R .287 (ersion than its ar)-.15 F .287(gument and)-.18 F F3(not)2.787 E F0 .288 (to undo the feature-enabling side)2.787 F(ef)128 222 Q(fects of)-.25 E F1(use VERSION)2.5 E F0(.)A .295 (See perlmodlib for a list of standard modules and pragmas.)128 240 R .295(See perlrun for the)5.295 F F12.794 E F0(and)2.794 E F1 2.794 E F0(command-)2.794 E(line options to Perl that gi)128 252 Q -.15 (ve)-.25 G F1(use)2.65 E F0(functionality from the command-line.)2.5 E (utime)108 268.8 Q F2(LIST)2.5 E F0 .39(Changes the access and modi\214\ cation times on each \214le of a list of \214les.)128 280.8 R .391 (The \214rst tw)5.391 F 2.891(oe)-.1 G .391(lements of the)-2.891 F .953 (list must be the)128 292.8 R F2(NUMERIC)3.453 E F0 .953 (access and modi\214cation times, in that order)3.453 F 5.952(.R)-.55 G .952(eturns the number of \214les)-5.952 F .335(successfully changed.) 128 304.8 R .335 (The inode change time of each \214le is set to the current time.)5.335 F -.15(Fo)5.336 G 2.836(re).15 G .336(xample, this)-2.986 F .201 (code has the same ef)128 316.8 R .2(fect as the Unix)-.25 F F3(touc)2.7 E(h)-.15 E F0 .2(\(1\) command when the \214les)1.666 F F3(alr)2.7 E .2 (eady e)-.37 F(xist)-.2 E F0 .2(and belong to the)2.7 F (user running the program:)128 328.8 Q F1(#!/usr/bin/perl)152 346.8 Q ($atime = $mtime = time;)152 358.8 Q(utime $atime, $mtime, @ARGV;)152 370.8 Q F0 1.384(Since Perl 5.7.2, if the \214rst tw)128 388.8 R 3.884 (oe)-.1 G 1.384(lements of the list are)-3.884 F F1(undef)3.884 E F0 3.884(,t)C(he)-3.884 E F3(utime)3.884 E F0 1.384 (\(2\) syscall from your C)1.666 F 1.65 (library is called with a null second ar)128 400.8 R 1.649 (gument. On most systems, this will set the \214le')-.18 F 4.149(sa)-.55 G 1.649(ccess and)-4.149 F .93 (modi\214cation times to the current time \(i.e., equi)128 412.8 R -.25 (va)-.25 G .931(lent to the e).25 F .931(xample abo)-.15 F -.15(ve)-.15 G 3.431(\)a).15 G .931(nd will w)-3.431 F .931(ork e)-.1 F -.15(ve)-.25 G 3.431(no).15 G(n)-3.431 E(\214les you don')128 424.8 Q 2.5(to)-.18 G (wn pro)-2.75 E(vided you ha)-.15 E .3 -.15(ve w)-.2 H(rite permission:) .15 E F1(for $file \(@ARGV\) {)152 442.8 Q(utime\(undef, undef, $file\)) 176 454.8 Q(|| warn "couldn\010t touch $file: $!";)200 466.8 Q(})152 478.8 Q F0(Under)128 496.8 Q F2(NFS)2.57 E F0 .07 (this will use the time of the)2.57 F F2(NFS)2.57 E F0(serv)2.57 E(er) -.15 E 2.57(,n)-.4 G .07(ot the time of the local machine.)-2.57 F .07 (If there is a time)5.07 F 2.194(synchronization problem, the)128 508.8 R F2(NFS)4.695 E F0(serv)4.695 E 2.195(er and local machine will ha)-.15 F 2.495 -.15(ve d)-.2 H(if).15 E 2.195(ferent times.)-.25 F 2.195 (The Unix)7.195 F F3(touc)128 520.8 Q(h)-.15 E F0 (\(1\) command will in f)1.666 E (act normally use this form instead of the one sho)-.1 E (wn in the \214rst e)-.25 E(xample.)-.15 E -.15(Pa)128 538.8 S .295 (ssing only one of the \214rst tw).15 F 2.795(oe)-.1 G .295(lements as) -2.795 F F1(undef)2.795 E F0 .295(is equi)2.795 F -.25(va)-.25 G .295 (lent to passing a 0 and will not ha).25 F .595 -.15(ve t)-.2 H(he).15 E (ef)128 550.8 Q(fect described when both are)-.25 E F1(undef)2.5 E F0 5 (.T)C(his also triggers an uninitialized w)-5 E(arning.)-.1 E .479 (On systems that support)128 568.8 R F3(futimes)2.979 E F0 .48 (\(2\), you may pass \214lehandles among the \214les.)1.666 F .48 (On systems that don')5.48 F(t)-.18 E(support)128 580.8 Q F3(futimes) 3.695 E F0 1.194(\(2\), passing \214lehandles raises an e)1.666 F 3.694 (xception. Filehandles)-.15 F 1.194(must be passed as globs or)3.694 F (glob references to be recognized; bare)128 592.8 Q -.1(wo)-.25 G (rds are considered \214lenames.).1 E -.25(va)108 609.6 S(lues).25 E F2 (HASH)2.5 E F0 -.25(va)108 621.6 S(lues).25 E F2(ARRA)2.5 E(Y)-.945 E F0 -.25(va)108 633.6 S(lues).25 E F2(EXPR)2.5 E F0 1.646 (Returns a list consisting of all the v)128 645.6 R 1.646 (alues of the named hash, or the v)-.25 F 1.647(alues of an array)-.25 F 4.147(.\()-.65 G 1.647(In scalar)-4.147 F(conte)128 657.6 Q (xt, returns the number of v)-.15 E(alues.\))-.25 E .495(The v)128 675.6 R .495(alues are returned in an apparently random order)-.25 F 5.494(.T) -.55 G .494(he actual random order is subject to change)-5.494 F 1.752 (in future v)128 687.6 R 1.752(ersions of Perl, b)-.15 F 1.753 (ut it is guaranteed to be the same order as either the)-.2 F F1(keys) 4.253 E F0(or)4.253 E F1(each)4.253 E F0 .132(function w)128 699.6 R .132(ould produce on the same \(unmodi\214ed\) hash.)-.1 F .132 (Since Perl 5.8.1 the ordering is dif)5.132 F .132(ferent e)-.25 F -.15 (ve)-.25 G(n).15 E(between dif)128 711.6 Q (ferent runs of Perl for security reasons \(see `)-.25 E -.8(`A)-.74 G (lgorithmic Comple).8 E(xity Attacks')-.15 E 2.5('i)-.74 G 2.5(np)-2.5 G (erlsec\).)-2.5 E 2.27(As a side ef)128 729.6 R 2.27(fect, calling)-.25 F F3(values\(\))4.77 E F0 2.27(resets the)4.77 F F2(HASH)4.77 E F0(or) 4.771 E F2(ARRA)4.771 E(Y)-.945 E F0 3.371 -.55('s i)D 2.271 (nternal iterator; see `).55 F(`each')-.74 E 2.271('. \(In)-.74 F (perl v5.14.2)72 768 Q 198.17(2011-10-01 97)162.62 F 0 Cg EP %%Page: 98 98 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E(particular)128 84 Q 4.589(,c)-.4 G(alling)-4.589 E/F1 10/Times-Italic@0 SF(values\(\)) 4.589 E F0 2.089(in v)4.589 F 2.089(oid conte)-.2 F 2.088 (xt resets the iterator with no other o)-.15 F -.15(ve)-.15 G 2.088 (rhead. Apart from).15 F .2(resetting the iterator)128 96 R(,)-.4 E/F2 10/Courier@0 SF .2(values @array)2.7 F F0 .2(in list conte)2.7 F .2 (xt is the same as plain)-.15 F F2(@array)2.7 E F0 5.2(.W)C 2.7(er)-6 G (ecommend)-2.7 E .484(that you use v)128 108 R .483(oid conte)-.2 F(xt) -.15 E F2 .483(keys @array)2.983 F F0 .483(for this, b)2.983 F .483 (ut reasoned that it taking)-.2 F F2 .483(values @array)2.983 F F0(out) 2.983 E -.1(wo)128 120 S(uld require more documentation than lea).1 E (ving it in.\))-.2 E(Note that the v)128 138 Q(alues are not copied, wh\ ich means modifying them will modify the contents of the hash:)-.25 E F2 (for \(values %hash\))152 156 Q 6({s)36 G(/foo/bar/g })-6 E 6(#m)18 G (odifies %hash values)-6 E(for \(@hash{keys %hash}\) { s/foo/bar/g })152 168 Q 6(#s)18 G(ame)-6 E F0 .251(Starting with Perl 5.14,)128 186 R F2 (values)2.751 E F0 .251(can tak)2.751 F 2.751(eas)-.1 G(calar)-2.751 E /F3 9/Times-Roman@0 SF(EXPR)2.752 E F0 2.752(,w)C .252 (hich must hold a reference to an unblessed)-2.752 F 3.51(hash or array) 128 198 R 8.51(.T)-.65 G 3.509(he ar)-8.51 F 3.509 (gument will be dereferenced automatically)-.18 F 8.509(.T)-.65 G 3.509 (his aspect of)-8.509 F F2(values)6.009 E F0(is)6.009 E (considered highly e)128 210 Q 2.5(xperimental. The)-.15 F -.15(ex)2.5 G (act beha).15 E(viour may change in a future v)-.2 E(ersion of Perl.) -.15 E F2(for \(values $hashref\) { ... })152 228 Q (for \(values $obj\255>get_arrayref\) { ... })152 240 Q F0(See also)128 258 Q F2(keys)2.5 E F0(,)A F2(each)2.5 E F0 2.5(,a)C(nd)-2.5 E F2(sort) 2.5 E F0(.)A -.15(ve)108 274.8 S(c).15 E F3(EXPR)2.5 E F0(,OFFSET)A (,BITS)-.74 E -.35(Tr)128 286.8 S .654(eats the string in).35 F F3(EXPR) 3.154 E F0 .654(as a bit v)3.154 F .654 (ector made up of elements of width)-.15 F F3(BITS)3.154 E F0 .655 (and returns the v)3.154 F .655(alue of)-.25 F .736 (the element speci\214ed by)128 298.8 R F3(OFFSET)3.236 E F0 .735 (as an unsigned inte)3.235 F(ger)-.15 E(.)-.55 E F3(BITS)5.735 E F0 .735 (therefore speci\214es the number of bits)3.235 F .022(that are reserv) 128 310.8 R .022(ed for each element in the bit v)-.15 F(ector)-.15 E 5.022(.T)-.55 G .022(his must be a po)-5.022 F .022(wer of tw)-.25 F 2.522(of)-.1 G .023(rom 1 to 32 \(or 64, if)-2.522 F (your platform supports that\).)128 322.8 Q(If)128 340.8 Q F3(BITS)2.5 E F0(is 8, `)2.5 E(`elements')-.74 E 2.5('c)-.74 G (oincide with bytes of the input string.)-2.5 E(If)128 358.8 Q F3(BITS) 2.748 E F0 .247(is 16 or more, bytes of the input string are grouped in\ to chunks of size)2.748 F F3(BITS/8)2.747 E F0 2.747(,a)C .247 (nd each group)-2.747 F 1.105(is con)128 370.8 R -.15(ve)-.4 G 1.105 (rted to a number as with).15 F F1(pac)3.605 E(k\(\))-.2 E F0(/)A F1 (unpac)A(k\(\))-.2 E F0 1.105(with big-endian formats)3.605 F F2(n)3.605 E F0(/)A F2(N)A F0 1.105(\(and analogously for)3.605 F 2.5 (BITS==64\). See)128 382.8 R -.74(``)2.5 G(pack').74 E 2.5('f)-.74 G (or details.)-2.5 E .94(If bits is 4 or less, the string is brok)128 400.8 R .939(en into bytes, then the bits of each byte are brok)-.1 F .939(en into 8/BITS)-.1 F 4.087(groups. Bits)128 412.8 R 1.587 (of a byte are numbered in a little-endian-ish w)4.087 F(ay)-.1 E 4.088 (,a)-.65 G 4.088(si)-4.088 G(n)-4.088 E F2(0x01)4.088 E F0(,)A F2(0x02) 4.088 E F0(,)A F2(0x04)4.088 E F0(,)A F2(0x08)4.088 E F0(,)A F2(0x10)128 424.8 Q F0(,)A F2(0x20)4.63 E F0(,)A F2(0x40)4.63 E F0(,)A F2(0x80)4.63 E F0 7.13(.F)C 2.13(or e)-7.28 F 2.13 (xample, breaking the single input byte)-.15 F F2(chr\(0x36\))4.63 E F0 2.13(into tw)4.63 F(o)-.1 E(groups gi)128 436.8 Q -.15(ve)-.25 G 2.5 (sal).15 G(ist)-2.5 E F2(\(0x6, 0x3\))2.5 E F0 2.5(;b)C (reaking it into 4 groups gi)-2.5 E -.15(ve)-.25 G(s).15 E F2 (\(0x2, 0x1, 0x3, 0x0\))2.5 E F0(.)A F2(vec)128 454.8 Q F0 .469 (may also be assigned to, in which case parentheses are needed to gi) 2.969 F .77 -.15(ve t)-.25 H .47(he e).15 F .47(xpression the correct) -.15 F(precedence as in)128 466.8 Q F2 (vec\($image, $max_x * $x + $y, 8\) = 3;)152 484.8 Q F0 .81 (If the selected element is outside the string, the v)128 502.8 R .809 (alue 0 is returned.)-.25 F .809(If an element of)5.809 F 3.309(ft)-.25 G .809(he end of the)-3.309 F .413 (string is written to, Perl will \214rst e)128 514.8 R .413 (xtend the string with suf)-.15 F .413(\214ciently man)-.25 F 2.913(yz) -.15 G .413(ero bytes.)-2.913 F .414(It is an error to)7.913 F (try to write of)128 526.8 Q 2.5(ft)-.25 G(he be)-2.5 E (ginning of the string \(i.e., ne)-.15 E -.05(ga)-.15 G(ti).05 E -.15 (ve)-.25 G F3(OFFSET)2.65 E F0(\).)A .063 (If the string happens to be encoded as)128 544.8 R F3(UTF\2558)2.563 E F0 .063(internally \(and thus has the)2.563 F F3(UTF8)2.563 E F0 .062 (\215ag set\), this is ignored)2.562 F(by)128 556.8 Q F2(vec)2.516 E F0 2.516(,a)C .017(nd it operates on the internal byte string, not the con\ ceptual character string, e)-2.516 F -.15(ve)-.25 G 2.517(ni).15 G 2.517 (fy)-2.517 G .017(ou only)-2.517 F(ha)128 568.8 Q .3 -.15(ve c)-.2 H (haracters with v).15 E(alues less than 256.)-.25 E 1.082 (Strings created with)128 586.8 R F2(vec)3.582 E F0 1.082 (can also be manipulated with the logical operators)3.582 F F2(|)3.582 E F0(,)A F2(&)3.582 E F0(,)A F2(^)3.581 E F0 3.581(,a)C(nd)-3.581 E F2(~) 3.581 E F0 6.081(.T)C(hese)-6.081 E .586(operators will assume a bit v) 128 598.8 R .586 (ector operation is desired when both operands are strings.)-.15 F .586 (See `)5.586 F(`Bitwise)-.74 E(String Operators')128 610.8 Q 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E .936(The follo)128 628.8 R .936 (wing code will b)-.25 F .936(uild up an)-.2 F F3(ASCII)3.435 E F0 .935 (string saying)3.435 F F2(\010PerlPerlPerl\010)3.435 E F0 5.935(.T)C .935(he comments sho)-5.935 F(w)-.25 E 1.064 (the string after each step.)128 640.8 R 1.065(Note that this code w) 6.064 F 1.065(orks in the same w)-.1 F 1.065 (ay on big-endian or little-endian)-.1 F(machines.)128 652.8 Q F2 (my $foo = \010\010;)152 670.8 Q 6(vec\($foo, 0,)152 682.8 R (32\) = 0x5065726C; # \010Perl\010)6 E 6(#$)152 706.8 S (foo eq "Perl" eq "\\x50\\x65\\x72\\x6C", 32 bits)-6 E (print vec\($foo, 0, 8\);)152 718.8 Q 6(#p)12 G (rints 80 == 0x50 == ord\(\010P\010\))-6 E F0(perl v5.14.2)72 768 Q 198.17(2011-10-01 98)162.62 F 0 Cg EP %%Page: 99 99 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 6(vec\($foo, 2,)152 84 R(16\) = 0x5065; # \010PerlPe\010)6 E 6 (vec\($foo, 3,)152 96 R(16\) = 0x726C; # \010PerlPerl\010)6 E 6 (vec\($foo, 8, 8\))152 108 R 6(=0)6 G 12(x50; #)-6 F(\010PerlPerlP\010)6 E 6(vec\($foo, 9, 8\))152 120 R 6(=0)6 G 12(x65; #)-6 F (\010PerlPerlPe\010)6 E(vec\($foo, 20,)152 132 Q(4\) = 2;)12 E 6<2308>36 G 12(PerlPerlPe\010 .)-6 F("\\x02")6 E(vec\($foo, 21,)152 144 Q (4\) = 7;)12 E 6<2308>36 G(PerlPerlPer\010)-6 E 6<2308>338 156 S (r\010 is "\\x72")-6 E(vec\($foo, 45,)152 168 Q(2\) = 3;)12 E 6<2308>36 G 6(PerlPerlPer\010 .)-6 F("\\x0c")6 E(vec\($foo, 93,)152 180 Q (1\) = 1;)12 E 6<2308>36 G 6(PerlPerlPer\010 .)-6 F("\\x2c")6 E (vec\($foo, 94,)152 192 Q(1\) = 1;)12 E 6<2308>36 G(PerlPerlPerl\010)-6 E 6<2308>338 204 S(l\010 is "\\x6c")-6 E F0 1.6 -.8(To t)128 222 T (ransform a bit v).8 E(ector into a string or list of 0')-.15 E 2.5(sa) -.55 G(nd 1')-2.5 E(s, use these:)-.55 E F1 ($bits = unpack\("b*", $vector\);)152 240 Q (@bits = split\(//, unpack\("b*", $vector\)\);)152 252 Q F0(If you kno) 128 270 Q 2.5(wt)-.25 G(he e)-2.5 E (xact length in bits, it can be used in place of the)-.15 E F1(*)2.5 E F0(.)A(Here is an e)128 288 Q(xample to illustrate ho)-.15 E 2.5(wt)-.25 G(he bits actually f)-2.5 E(all in place:)-.1 E F1 (#!/usr/bin/perl \255wl)152 306 Q(print <<\010EOT\010;)152 330 Q 54 (0123)356 342 S(unpack\("V",$_\) 01234567890123456789012345678901)266 354 Q152 366 Q(EOT)152 378 Q(for $w \(0..3\) {)152 402 Q($width = 2**$w;)176 414 Q(for \($shift=0; $shift < $width; ++$shift\) {)176 426 Q (for \($off=0; $off < 32/$width; ++$off\) {)200 438 Q ($str = pack\("B*", "0"x32\);)224 450 Q($bits = \(1<<$shift\);)224 462 Q (vec\($str, $off, $width\) = $bits;)224 474 Q ($res = unpack\("b*",$str\);)224 486 Q($val = unpack\("V", $str\);)224 498 Q(write;)224 510 Q(})200 522 Q(})176 534 Q(})152 546 Q (format STDOUT =)152 570 Q (vec\($_,@#,@#\) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>) 152 582 Q($off, $width, $bits, $val, $res)152 594 Q(.)152 606 Q 1.666 (__)152 618 S -4.334(END_ _)-1.666 F F0(Re)128 636 Q -.05(ga)-.15 G .235 (rdless of the machine architecture on which it runs, the e).05 F .234 (xample abo)-.15 F .534 -.15(ve s)-.15 H .234(hould print the follo).15 F(wing)-.25 E(table:)128 648 Q(perl v5.14.2)72 768 Q 198.17 (2011-10-01 99)162.62 F 0 Cg EP %%Page: 100 100 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF 54(0123)356 84 S(unpack\("V",$_\) 01234567890123456789012345678901)266 96 Q152 108 Q(vec\($_, 0, 1\) = 1)152 120 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 1\) = 1)152 132 Q 54 (== 2)18 F(01000000000000000000000000000000)6 E(vec\($_, 2, 1\) = 1)152 144 Q 54(== 4)18 F(00100000000000000000000000000000)6 E (vec\($_, 3, 1\) = 1)152 156 Q 54(== 8)18 F (00010000000000000000000000000000)6 E(vec\($_, 4, 1\) = 1)152 168 Q 48 (== 16)18 F(00001000000000000000000000000000)6 E(vec\($_, 5, 1\) = 1)152 180 Q 48(== 32)18 F(00000100000000000000000000000000)6 E (vec\($_, 6, 1\) = 1)152 192 Q 48(== 64)18 F (00000010000000000000000000000000)6 E(vec\($_, 7, 1\) = 1)152 204 Q 42 (== 128)18 F(00000001000000000000000000000000)6 E(vec\($_, 8, 1\) = 1) 152 216 Q 42(== 256)18 F(00000000100000000000000000000000)6 E (vec\($_, 9, 1\) = 1)152 228 Q 42(== 512)18 F (00000000010000000000000000000000)6 E(vec\($_,10, 1\) = 1)152 240 Q 36 (== 1024)18 F(00000000001000000000000000000000)6 E(vec\($_,11, 1\) = 1) 152 252 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_,12, 1\) = 1)152 264 Q 36(== 4096)18 F (00000000000010000000000000000000)6 E(vec\($_,13, 1\) = 1)152 276 Q 36 (== 8192)18 F(00000000000001000000000000000000)6 E(vec\($_,14, 1\) = 1) 152 288 Q 30(== 16384)18 F(00000000000000100000000000000000)6 E (vec\($_,15, 1\) = 1)152 300 Q 30(== 32768)18 F (00000000000000010000000000000000)6 E(vec\($_,16, 1\) = 1)152 312 Q 30 (== 65536)18 F(00000000000000001000000000000000)6 E(vec\($_,17, 1\) = 1) 152 324 Q 24(== 131072)18 F(00000000000000000100000000000000)6 E (vec\($_,18, 1\) = 1)152 336 Q 24(== 262144)18 F (00000000000000000010000000000000)6 E(vec\($_,19, 1\) = 1)152 348 Q 24 (== 524288)18 F(00000000000000000001000000000000)6 E (vec\($_,20, 1\) = 1)152 360 Q 18(== 1048576)18 F (00000000000000000000100000000000)6 E(vec\($_,21, 1\) = 1)152 372 Q 18 (== 2097152)18 F(00000000000000000000010000000000)6 E (vec\($_,22, 1\) = 1)152 384 Q 18(== 4194304)18 F (00000000000000000000001000000000)6 E(vec\($_,23, 1\) = 1)152 396 Q 18 (== 8388608)18 F(00000000000000000000000100000000)6 E (vec\($_,24, 1\) = 1)152 408 Q 12(== 16777216)18 F (00000000000000000000000010000000)6 E(vec\($_,25, 1\) = 1)152 420 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_,26, 1\) = 1)152 432 Q 12(== 67108864)18 F (00000000000000000000000000100000)6 E(vec\($_,27, 1\) = 1)152 444 Q 6 (== 134217728)18 F(00000000000000000000000000010000)6 E (vec\($_,28, 1\) = 1)152 456 Q 6(== 268435456)18 F (00000000000000000000000000001000)6 E(vec\($_,29, 1\) = 1)152 468 Q 6 (== 536870912)18 F(00000000000000000000000000000100)6 E (vec\($_,30, 1\) = 1)152 480 Q (== 1073741824 00000000000000000000000000000010)18 E (vec\($_,31, 1\) = 1)152 492 Q (== 2147483648 00000000000000000000000000000001)18 E (vec\($_, 0, 2\) = 1)152 504 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 2\) = 1)152 516 Q 54 (== 4)18 F(00100000000000000000000000000000)6 E(vec\($_, 2, 2\) = 1)152 528 Q 48(== 16)18 F(00001000000000000000000000000000)6 E (vec\($_, 3, 2\) = 1)152 540 Q 48(== 64)18 F (00000010000000000000000000000000)6 E(vec\($_, 4, 2\) = 1)152 552 Q 42 (== 256)18 F(00000000100000000000000000000000)6 E(vec\($_, 5, 2\) = 1) 152 564 Q 36(== 1024)18 F(00000000001000000000000000000000)6 E (vec\($_, 6, 2\) = 1)152 576 Q 36(== 4096)18 F (00000000000010000000000000000000)6 E(vec\($_, 7, 2\) = 1)152 588 Q 30 (== 16384)18 F(00000000000000100000000000000000)6 E(vec\($_, 8, 2\) = 1) 152 600 Q 30(== 65536)18 F(00000000000000001000000000000000)6 E (vec\($_, 9, 2\) = 1)152 612 Q 24(== 262144)18 F (00000000000000000010000000000000)6 E(vec\($_,10, 2\) = 1)152 624 Q 18 (== 1048576)18 F(00000000000000000000100000000000)6 E (vec\($_,11, 2\) = 1)152 636 Q 18(== 4194304)18 F (00000000000000000000001000000000)6 E(vec\($_,12, 2\) = 1)152 648 Q 12 (== 16777216)18 F(00000000000000000000000010000000)6 E (vec\($_,13, 2\) = 1)152 660 Q 12(== 67108864)18 F (00000000000000000000000000100000)6 E(vec\($_,14, 2\) = 1)152 672 Q 6 (== 268435456)18 F(00000000000000000000000000001000)6 E (vec\($_,15, 2\) = 1)152 684 Q (== 1073741824 00000000000000000000000000000010)18 E (vec\($_, 0, 2\) = 2)152 696 Q 54(== 2)18 F (01000000000000000000000000000000)6 E(vec\($_, 1, 2\) = 2)152 708 Q 54 (== 8)18 F(00010000000000000000000000000000)6 E(vec\($_, 2, 2\) = 2)152 720 Q 48(== 32)18 F(00000100000000000000000000000000)6 E F0 (perl v5.14.2)72 768 Q 193.17(2011-10-01 100)162.62 F 0 Cg EP %%Page: 101 101 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (vec\($_, 3, 2\) = 2)152 84 Q 42(== 128)18 F (00000001000000000000000000000000)6 E(vec\($_, 4, 2\) = 2)152 96 Q 42 (== 512)18 F(00000000010000000000000000000000)6 E(vec\($_, 5, 2\) = 2) 152 108 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_, 6, 2\) = 2)152 120 Q 36(== 8192)18 F (00000000000001000000000000000000)6 E(vec\($_, 7, 2\) = 2)152 132 Q 30 (== 32768)18 F(00000000000000010000000000000000)6 E(vec\($_, 8, 2\) = 2) 152 144 Q 24(== 131072)18 F(00000000000000000100000000000000)6 E (vec\($_, 9, 2\) = 2)152 156 Q 24(== 524288)18 F (00000000000000000001000000000000)6 E(vec\($_,10, 2\) = 2)152 168 Q 18 (== 2097152)18 F(00000000000000000000010000000000)6 E (vec\($_,11, 2\) = 2)152 180 Q 18(== 8388608)18 F (00000000000000000000000100000000)6 E(vec\($_,12, 2\) = 2)152 192 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_,13, 2\) = 2)152 204 Q 6(== 134217728)18 F (00000000000000000000000000010000)6 E(vec\($_,14, 2\) = 2)152 216 Q 6 (== 536870912)18 F(00000000000000000000000000000100)6 E (vec\($_,15, 2\) = 2)152 228 Q (== 2147483648 00000000000000000000000000000001)18 E (vec\($_, 0, 4\) = 1)152 240 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 4\) = 1)152 252 Q 48 (== 16)18 F(00001000000000000000000000000000)6 E(vec\($_, 2, 4\) = 1)152 264 Q 42(== 256)18 F(00000000100000000000000000000000)6 E (vec\($_, 3, 4\) = 1)152 276 Q 36(== 4096)18 F (00000000000010000000000000000000)6 E(vec\($_, 4, 4\) = 1)152 288 Q 30 (== 65536)18 F(00000000000000001000000000000000)6 E(vec\($_, 5, 4\) = 1) 152 300 Q 18(== 1048576)18 F(00000000000000000000100000000000)6 E (vec\($_, 6, 4\) = 1)152 312 Q 12(== 16777216)18 F (00000000000000000000000010000000)6 E(vec\($_, 7, 4\) = 1)152 324 Q 6 (== 268435456)18 F(00000000000000000000000000001000)6 E (vec\($_, 0, 4\) = 2)152 336 Q 54(== 2)18 F (01000000000000000000000000000000)6 E(vec\($_, 1, 4\) = 2)152 348 Q 48 (== 32)18 F(00000100000000000000000000000000)6 E(vec\($_, 2, 4\) = 2)152 360 Q 42(== 512)18 F(00000000010000000000000000000000)6 E (vec\($_, 3, 4\) = 2)152 372 Q 36(== 8192)18 F (00000000000001000000000000000000)6 E(vec\($_, 4, 4\) = 2)152 384 Q 24 (== 131072)18 F(00000000000000000100000000000000)6 E (vec\($_, 5, 4\) = 2)152 396 Q 18(== 2097152)18 F (00000000000000000000010000000000)6 E(vec\($_, 6, 4\) = 2)152 408 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_, 7, 4\) = 2)152 420 Q 6(== 536870912)18 F (00000000000000000000000000000100)6 E(vec\($_, 0, 4\) = 4)152 432 Q 54 (== 4)18 F(00100000000000000000000000000000)6 E(vec\($_, 1, 4\) = 4)152 444 Q 48(== 64)18 F(00000010000000000000000000000000)6 E (vec\($_, 2, 4\) = 4)152 456 Q 36(== 1024)18 F (00000000001000000000000000000000)6 E(vec\($_, 3, 4\) = 4)152 468 Q 30 (== 16384)18 F(00000000000000100000000000000000)6 E(vec\($_, 4, 4\) = 4) 152 480 Q 24(== 262144)18 F(00000000000000000010000000000000)6 E (vec\($_, 5, 4\) = 4)152 492 Q 18(== 4194304)18 F (00000000000000000000001000000000)6 E(vec\($_, 6, 4\) = 4)152 504 Q 12 (== 67108864)18 F(00000000000000000000000000100000)6 E (vec\($_, 7, 4\) = 4)152 516 Q (== 1073741824 00000000000000000000000000000010)18 E (vec\($_, 0, 4\) = 8)152 528 Q 54(== 8)18 F (00010000000000000000000000000000)6 E(vec\($_, 1, 4\) = 8)152 540 Q 42 (== 128)18 F(00000001000000000000000000000000)6 E(vec\($_, 2, 4\) = 8) 152 552 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_, 3, 4\) = 8)152 564 Q 30(== 32768)18 F (00000000000000010000000000000000)6 E(vec\($_, 4, 4\) = 8)152 576 Q 24 (== 524288)18 F(00000000000000000001000000000000)6 E (vec\($_, 5, 4\) = 8)152 588 Q 18(== 8388608)18 F (00000000000000000000000100000000)6 E(vec\($_, 6, 4\) = 8)152 600 Q 6 (== 134217728)18 F(00000000000000000000000000010000)6 E (vec\($_, 7, 4\) = 8)152 612 Q (== 2147483648 00000000000000000000000000000001)18 E (vec\($_, 0, 8\) = 1)152 624 Q 54(== 1)18 F (10000000000000000000000000000000)6 E(vec\($_, 1, 8\) = 1)152 636 Q 42 (== 256)18 F(00000000100000000000000000000000)6 E(vec\($_, 2, 8\) = 1) 152 648 Q 30(== 65536)18 F(00000000000000001000000000000000)6 E (vec\($_, 3, 8\) = 1)152 660 Q 12(== 16777216)18 F (00000000000000000000000010000000)6 E(vec\($_, 0, 8\) = 2)152 672 Q 54 (== 2)18 F(01000000000000000000000000000000)6 E(vec\($_, 1, 8\) = 2)152 684 Q 42(== 512)18 F(00000000010000000000000000000000)6 E (vec\($_, 2, 8\) = 2)152 696 Q 24(== 131072)18 F (00000000000000000100000000000000)6 E(vec\($_, 3, 8\) = 2)152 708 Q 12 (== 33554432)18 F(00000000000000000000000001000000)6 E (vec\($_, 0, 8\) = 4)152 720 Q 54(== 4)18 F (00100000000000000000000000000000)6 E F0(perl v5.14.2)72 768 Q 193.17 (2011-10-01 101)162.62 F 0 Cg EP %%Page: 102 102 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (vec\($_, 1, 8\) = 4)152 84 Q 36(== 1024)18 F (00000000001000000000000000000000)6 E(vec\($_, 2, 8\) = 4)152 96 Q 24 (== 262144)18 F(00000000000000000010000000000000)6 E (vec\($_, 3, 8\) = 4)152 108 Q 12(== 67108864)18 F (00000000000000000000000000100000)6 E(vec\($_, 0, 8\) = 8)152 120 Q 54 (== 8)18 F(00010000000000000000000000000000)6 E(vec\($_, 1, 8\) = 8)152 132 Q 36(== 2048)18 F(00000000000100000000000000000000)6 E (vec\($_, 2, 8\) = 8)152 144 Q 24(== 524288)18 F (00000000000000000001000000000000)6 E(vec\($_, 3, 8\) = 8)152 156 Q 6 (== 134217728)18 F(00000000000000000000000000010000)6 E (vec\($_, 0, 8\) = 16)152 168 Q 48(== 16)12 F (00001000000000000000000000000000)6 E(vec\($_, 1, 8\) = 16)152 180 Q 36 (== 4096)12 F(00000000000010000000000000000000)6 E(vec\($_, 2, 8\) = 16) 152 192 Q 18(== 1048576)12 F(00000000000000000000100000000000)6 E (vec\($_, 3, 8\) = 16)152 204 Q 6(== 268435456)12 F (00000000000000000000000000001000)6 E(vec\($_, 0, 8\) = 32)152 216 Q 48 (== 32)12 F(00000100000000000000000000000000)6 E(vec\($_, 1, 8\) = 32) 152 228 Q 36(== 8192)12 F(00000000000001000000000000000000)6 E (vec\($_, 2, 8\) = 32)152 240 Q 18(== 2097152)12 F (00000000000000000000010000000000)6 E(vec\($_, 3, 8\) = 32)152 252 Q 6 (== 536870912)12 F(00000000000000000000000000000100)6 E (vec\($_, 0, 8\) = 64)152 264 Q 48(== 64)12 F (00000010000000000000000000000000)6 E(vec\($_, 1, 8\) = 64)152 276 Q 30 (== 16384)12 F(00000000000000100000000000000000)6 E (vec\($_, 2, 8\) = 64)152 288 Q 18(== 4194304)12 F (00000000000000000000001000000000)6 E(vec\($_, 3, 8\) = 64)152 300 Q (== 1073741824 00000000000000000000000000000010)12 E (vec\($_, 0, 8\) = 128 ==)152 312 Q (128 00000001000000000000000000000000)48 E(vec\($_, 1, 8\) = 128 ==)152 324 Q(32768 00000000000000010000000000000000)36 E (vec\($_, 2, 8\) = 128 ==)152 336 Q (8388608 00000000000000000000000100000000)24 E (vec\($_, 3, 8\) = 128 == 2147483648 00000000000000000000000000000001) 152 348 Q F0 -.1(wa)108 364.8 S(it).1 E(Beha)128 376.8 Q -.15(ve)-.2 G 2.534(sl).15 G(ik)-2.534 E(e)-.1 E/F2 10/Times-Italic@0 SF(wait)2.534 E F0 .034(\(2\) on your system: it w)1.666 F .035 (aits for a child process to terminate and returns the pid of the)-.1 F 3.527(deceased process, or)128 388.8 R F16.027 E F0 3.526 (if there are no child processes.)6.027 F 3.526 (The status is returned in)8.526 F F1($?)6.026 E F0(and)8.526 E F1 (${^CHILD_ERROR_NATIVE})128 400.8 Q F0 5.66(.N)C .66 (ote that a return v)-5.66 F .661(alue of)-.25 F F13.161 E F0 .661 (could mean that child processes are)3.161 F (being automatically reaped, as described in perlipc.)128 412.8 Q .598 (If you use w)128 430.8 R .598(ait in your handler for)-.1 F F1($SIG) 3.097 E F0({)A/F3 9/Times-Roman@0 SF(CHLD)A F0 3.097(}i)C 3.097(tm) -3.097 G .597(ay accidentally for the child created by)-3.097 F F2 (qx\(\))3.097 E F0(or)3.097 E F2(system\(\))128 442.8 Q F0 2.5(.S)C (ee perlipc for details.)-2.5 E -.1(wa)108 459.6 S(itpid).1 E F3(PID)2.5 E F0(,FLA)A(GS)-.4 E -.8(Wa)128 471.6 S .652(its for a particular child\ process to terminate and returns the pid of the deceased process, or).8 F F13.152 E F0(if)3.152 E .793(there is no such child process.)128 483.6 R .792(On some systems, a v)5.792 F .792 (alue of 0 indicates that there are processes still)-.25 F 2.5 (running. The)128 495.6 R(status is returned in)2.5 E F1($?)2.5 E F0 (and)2.5 E F1(${^CHILD_ERROR_NATIVE})2.5 E F0 5(.I)C 2.5(fy)-5 G(ou say) -2.5 E F1(use POSIX ":sys_wait_h";)152 513.6 Q(#...)152 525.6 Q(do {)152 537.6 Q($kid = waitpid\(\2551, WNOHANG\);)176 549.6 Q 6(}w)152 561.6 S (hile $kid > 0;)-6 E F0 .125(then you can do a non-blocking w)128 579.6 R .125(ait for all pending zombie processes.)-.1 F .126(Non-blocking w) 5.126 F .126(ait is a)-.1 F -.25(va)-.2 G(ilable).25 E .632 (on machines supporting either the)128 591.6 R F2(waitpid)3.132 E F0 .631(\(2\) or)1.666 F F2(wait4)3.131 E F0 .631(\(2\) syscalls.)1.666 F (Ho)5.631 E(we)-.25 E -.15(ve)-.25 G 1.431 -.4(r, w).15 H .631 (aiting for a particular).3 F .424(pid with)128 603.6 R F3(FLA)2.924 E (GS)-.36 E F0(of)2.924 E F1(0)2.924 E F0 .424(is implemented e)2.924 F -.15(ve)-.25 G 2.924(rywhere. \(Perl).15 F .425 (emulates the system call by remembering the)2.925 F(status v)128 615.6 Q(alues of processes that ha)-.25 E .3 -.15(ve ex)-.2 H(ited b).15 E (ut ha)-.2 E .3 -.15(ve n)-.2 H(ot been harv).15 E (ested by the Perl script yet.\))-.15 E 3.162 (Note that on some systems, a return v)128 633.6 R 3.162(alue of)-.25 F F15.662 E F0 3.162(could mean that child processes are being)5.662 F(automatically reaped.)128 645.6 Q (See perlipc for details, and for other e)5 E(xamples.)-.15 E -.1(wa)108 662.4 S(ntarray).1 E .939(Returns true if the conte)128 674.4 R .939 (xt of the currently e)-.15 F -.15(xe)-.15 G .939(cuting subroutine or) .15 F F1(eval)3.44 E F0 .94(is looking for a list v)3.44 F(alue.)-.25 E 1.908(Returns f)128 686.4 R 1.907(alse if the conte)-.1 F 1.907 (xt is looking for a scalar)-.15 F 6.907(.R)-.55 G 1.907 (eturns the unde\214ned v)-6.907 F 1.907(alue if the conte)-.25 F 1.907 (xt is)-.15 F(looking for no v)128 698.4 Q(alue \(v)-.25 E(oid conte)-.2 E(xt\).)-.15 E(perl v5.14.2)72 768 Q 193.17(2011-10-01 102)162.62 F 0 Cg EP %%Page: 103 103 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (return unless defined wantarray; # don\010t bother doing more)152 84 Q (my @a = complex_calculation\(\);)152 96 Q (return wantarray ? @a : "@a";)152 108 Q(wantarray\(\))128 126 Q F0 2.02 -.55('s r)D .92(esult is unspeci\214ed in the top le).55 F -.15(ve)-.25 G 3.42(lo).15 G 3.42(fa\214)-3.42 G .92(le, in a)-3.42 F F1(BEGIN)3.42 E F0(,)A F1(UNITCHECK)3.42 E F0(,)A F1(CHECK)3.42 E F0(,)A F1(INIT)128 138 Q F0(or)2.5 E F1(END)2.5 E F0(block, or in a)2.5 E F1(DESTROY)2.5 E F0 (method.)2.5 E(This function should ha)128 156 Q .3 -.15(ve b)-.2 H (een named).15 E/F2 10/Times-Italic@0 SF(wantlist\(\))2.5 E F0(instead.) 2.5 E -.1(wa)108 172.8 S(rn).1 E/F3 9/Times-Roman@0 SF(LIST)2.5 E F0 .433(Prints the v)128 184.8 R .433(alue of)-.25 F F3(LIST)2.933 E F0(to) 2.933 E F3(STDERR)2.933 E F0 5.432(.I)C 2.932(ft)-5.432 G .432 (he last element of)-2.932 F F3(LIST)2.932 E F0 .432 (does not end in a ne)2.932 F .432(wline, it appends)-.25 F (the same \214le/line number te)128 196.8 Q(xt as)-.15 E F1(die)2.5 E F0 (does.)2.5 E .937(If the output is empty and)128 214.8 R F1($@)3.437 E F0 .937(already contains a v)3.437 F .937(alue \(typically from a pre) -.25 F .938(vious e)-.25 F -.25(va)-.25 G .938(l\) that v).25 F .938 (alue is)-.25 F 1.528(used after appending)128 226.8 R F1 ("\\t...caught")4.028 E F0(to)4.028 E F1($@)4.028 E F0 6.528(.T)C 1.528 (his is useful for staying almost, b)-6.528 F 1.527(ut not entirely)-.2 F(similar to)128 238.8 Q F1(die)2.5 E F0(.)A(If)128 256.8 Q F1($@)2.5 E F0(is empty then the string)2.5 E F1("Warning: Something\010s wrong")2.5 E F0(is used.)2.5 E 2.915(No message is printed if there is a)128 274.8 R F1 -4.334($SIG{_ _WARN_ _})5.416 F F0 2.916(handler installed.)5.416 F 2.916(It is the handler')7.916 F(s)-.55 E .167 (responsibility to deal with the message as it sees \214t \(lik)128 286.8 R .167(e, for instance, con)-.1 F -.15(ve)-.4 G .167 (rting it into a).15 F F1(die)2.667 E F0 2.667(\). Most)B 1.434 (handlers must therefore arrange to actually display the w)128 298.8 R 1.434(arnings that the)-.1 F 3.934(ya)-.15 G 1.434 (re not prepared to deal)-3.934 F .075(with, by calling)128 310.8 R F1 (warn)2.575 E F0(ag)2.575 E .075(ain in the handler)-.05 F 5.075(.N)-.55 G .075(ote that this is quite safe and will not produce an endless) -5.075 F(loop, since)128 322.8 Q F1 1.666(__)2.5 G -4.334(WARN_ _)-1.666 F F0(hooks are not called from inside one.)2.5 E -1.1(Yo)128 340.8 S 2.712(uw)1.1 G .212(ill \214nd this beha)-2.712 F .213 (vior is slightly dif)-.2 F .213(ferent from that of)-.25 F F1 -4.334 ($SIG{_ _DIE_ _})2.713 F F0 .213(handlers \(which don')2.713 F(t)-.18 E (suppress the error te)128 352.8 Q(xt, b)-.15 E(ut can instead call)-.2 E F1(die)2.5 E F0(ag)2.5 E(ain to change it\).)-.05 E 1.712(Using a)128 370.8 R F1 1.666(__)4.212 G -4.334(WARN_ _)-1.666 F F0 1.712 (handler pro)4.212 F 1.712(vides a po)-.15 F 1.712(werful w)-.25 F 1.712 (ay to silence all w)-.1 F 1.712(arnings \(e)-.1 F -.15(ve)-.25 G 4.212 (nt).15 G 1.712(he so-called)-4.212 F(mandatory ones\).)128 382.8 Q (An e)5 E(xample:)-.15 E F1 6(#w)152 400.8 S (ipe out *all* compile\255time warnings)-6 E(BEGIN { $SIG{\010_)152 412.8 Q -4.334(_WARN_ _\010})1.666 F 6(=s)6 G (ub { warn $_[0] if $DOWARN } })-6 E(my $foo = 10;)152 424.8 Q (my $foo = 20;)152 436.8 Q 6(#n)60 G 6(ow)-6 G (arning about duplicate my $foo,)-6 E 6(#b)290 448.8 S (ut hey, you asked for it!)-6 E 6(#n)152 460.8 S 6(oc)-6 G (ompile\255time or run\255time warnings before here)-6 E($DOWARN = 1;) 152 472.8 Q 6(#r)152 496.8 S(un\255time warnings enabled after here)-6 E (warn "\\$foo is alive and $foo!";)152 508.8 Q 6(#d)30 G(oes show up)-6 E F0 .253(See perlv)128 526.8 R .253(ar for details on setting)-.25 F F1 (%SIG)2.753 E F0 .254(entries and for more e)2.753 F 2.754(xamples. See) -.15 F .254(the Carp module for other)2.754 F(kinds of w)128 538.8 Q (arnings using its)-.1 E F2(carp\(\))2.5 E F0(and)2.5 E F2(cluc)2.5 E (k\(\))-.2 E F0(functions.)2.5 E(when)108 555.6 Q F3 .25(EXPR BLOCK)2.5 F F0(when)108 567.6 Q F3(BLOCK)2.5 E F1(when)128 579.6 Q F0 1.764 (is analogous to the)4.264 F F1(case)4.264 E F0 -.1(ke)4.264 G(yw)-.05 E 1.764(ord in other languages. Used with a)-.1 F F1(foreach)4.263 E F0 1.763(loop or the)4.263 F -.15(ex)128 591.6 S(perimental).15 E F1(given) 3.286 E F0(block,)3.286 E F1(when)3.286 E F0 .786 (can be used in Perl to implement)3.286 F F1(switch)3.286 E F0(/)A F1 (case)A F0(lik)3.287 E 3.287(es)-.1 G(tatements.)-3.287 E -1.27 -.74 (Av a)128 603.6 T 2.45(ilable as a statement after Perl 5.10 and as a s\ tatement modi\214er after 5.14.).74 F 2.45(Here are three)7.45 F -.15 (ex)128 615.6 S(amples:).15 E(perl v5.14.2)72 768 Q 193.17 (2011-10-01 103)162.62 F 0 Cg EP %%Page: 104 104 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E/F1 10/Courier@0 SF (use v5.10;)152 84 Q(foreach \(@fruits\) {)152 96 Q (when \(/apples?/\) {)176 108 Q(say "I like apples.")200 120 Q(})176 132 Q(when \(/oranges?/\) {)176 144 Q(say "I don\010t like oranges.")200 156 Q(})176 168 Q(default {)176 180 Q(say "I don\010t like anything")200 192 Q(})176 204 Q(})152 216 Q 6(#r)152 240 S (equire 5.14 for when as statement modifier)-6 E(use v5.14;)152 252 Q (foreach \(@fruits\) {)152 264 Q(say "I like apples.")176 276 Q (when /apples?/;)48 E(say "I don\010t like oranges." when /oranges?;)176 288 Q(default { say "I don\010t like anything" })176 300 Q(})152 312 Q (use v5.10;)152 336 Q(given \($fruit\) {)152 348 Q(when \(/apples?/\) {) 176 360 Q(say "I like apples.")200 372 Q(})176 384 Q (when \(/oranges?/\) {)176 396 Q(say "I don\010t like oranges.")200 408 Q(})176 420 Q(default {)176 432 Q(say "I don\010t like anything")200 444 Q(})176 456 Q(})152 468 Q F0(See `)128 486 Q(`Switch statements')-.74 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlsyn for detailed information.)-2.5 E (write)108 502.8 Q/F2 9/Times-Roman@0 SF(FILEHANDLE)2.5 E F0(write)108 514.8 Q F2(EXPR)2.5 E F0(write)108 526.8 Q 2.703 (Writes a formatted record \(possibly multi-line\) to the speci\214ed) 128 538.8 R F2(FILEHANDLE)5.204 E F0 5.204(,u)C 2.704(sing the format) -5.204 F 1.601(associated with that \214le.)128 550.8 R 1.601(By def) 6.601 F 1.601(ault the format for a \214le is the one ha)-.1 F 1.6 (ving the same name as the)-.2 F 2.232(\214lehandle, b)128 562.8 R 2.233 (ut the format for the current output channel \(see the)-.2 F F1(select) 4.733 E F0 2.233(function\) may be set)4.733 F -.15(ex)128 574.8 S (plicitly by assigning the name of the format to the).15 E F1($~)2.5 E F0 -.25(va)2.5 G(riable.).25 E -.8(To)128 592.8 S 3.025(po).8 G 3.025 (ff)-3.025 G .525(orm processing is handled automatically:)-3.025 F .524 (if there is insuf)5.524 F .524(\214cient room on the current page for) -.25 F .122(the formatted record, the page is adv)128 604.8 R .123 (anced by writing a form feed, a special top-of-page format is used)-.25 F .667(to format the ne)128 616.8 R 3.167(wp)-.25 G .667 (age header before the record is written.)-3.167 F .667(By def)5.667 F .667(ault, the top-of-page format is the)-.1 F .023 (name of the \214lehandle with `)128 628.8 R(`_T)-.74 E(OP')-.18 E 2.523 ('a)-.74 G .023(ppended. This w)-2.523 F .023 (ould be a problem with auto)-.1 F(vi)-.15 E .023 (vi\214ed \214lehandles,)-.25 F -.2(bu)128 640.8 S 3.243(ti).2 G 3.243 (tm)-3.243 G .743(ay be dynamically set to the format of your choice by\ assigning the name to the)-3.243 F F1($^)3.242 E F0 -.25(va)3.242 G (riable).25 E .28(while that \214lehandle is selected.)128 652.8 R .28 (The number of lines remaining on the current page is in v)5.28 F (ariable)-.25 E F1<24ad>2.78 E F0(,)A(which can be set to)128 664.8 Q F1 (0)2.5 E F0(to force a ne)2.5 E 2.5(wp)-.25 G(age.)-2.5 E(If)128 682.8 Q F2(FILEHANDLE)3.263 E F0 .762 (is unspeci\214ed, output goes to the current def)3.262 F .762 (ault output channel, which starts out as)-.1 F F2(STDOUT)128 694.8 Q F0 -.2(bu)3.876 G 3.877(tm).2 G 1.377(ay be changed by the)-3.877 F F1 (select)3.877 E F0(operator)3.877 E 6.377(.I)-.55 G 3.877(ft)-6.377 G (he)-3.877 E F2(FILEHANDLE)3.877 E F0 1.377(is an)3.877 F F2(EXPR)3.877 E F0 3.877(,t)C 1.377(hen the)-3.877 F -.15(ex)128 706.8 S .218 (pression is e).15 F -.25(va)-.25 G .218 (luated and the resulting string is used to look up the name of the).25 F F2(FILEHANDLE)2.717 E F0 .217(at run)2.717 F 2.5(time. F)128 718.8 R (or more on formats, see perlform.)-.15 E(perl v5.14.2)72 768 Q 193.17 (2011-10-01 104)162.62 F 0 Cg EP %%Page: 105 105 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 92.855(PERLFUNC\(1\) User)72 48 R(Contrib)2.5 E (uted Perl Documentation)-.2 E(PERLFUNC\(1\))95.355 E (Note that write is)128 84 Q/F1 10/Times-Italic@0 SF(not)2.5 E F0 (the opposite of)2.5 E/F2 10/Courier@0 SF(read)2.5 E F0 5(.U)C (nfortunately)-5 E(.)-.65 E(y///)108 100.8 Q (The transliteration operator)128 100.8 Q 5(.S)-.55 G(ame as)-5 E F2 (tr///)2.5 E F0 5(.S)C(ee `)-5 E(`Quote and Quote-lik)-.74 E 2.5(eO)-.1 G(perators')-2.5 E 2.5('i)-.74 G 2.5(np)-2.5 G(erlop.)-2.5 E (perl v5.14.2)72 768 Q 193.17(2011-10-01 105)162.62 F 0 Cg EP %%Trailer end %%EOF