预览加载中,请您耐心等待几秒...
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

perl随笔-20070706 变量 ID项目描述$ARGV传递进来的参数数组$0perl程序文件名$一般变量@数组%散列表$#var_name数组的最大下标STDIN,STDOUT,STDERR内置句柄,可以使用、关闭,重新open等$ARG $_缺省的输入/循环变量 Thedefaultinputandpattern-searchingspace.Thefollowingpairsareequivalent: while(<>){...} while(defined($_=<>)){...} /^Subject:/ $_=~/^Subject:/ tr/a-z/A-Z/ $_=~tr/a-z/A-Z/ chomp chomp($_)@_@_containstheparameterspassedtothatsubroutine.$<digits>Containsthesubpatternfromthecorrespondingsetofcapturingparenthesesfromthelastpatternmatch,notcountingpatternsmatchedinnestedblocksthathavebeenexitedalready.(Mnemonic:like\digits.)Thesevariablesareallread-onlyanddynamicallyscopedtothecurrentBLOCK.$MATCH $&local$_='abcdefghi'; /def/; print"$`:$&:$'\n";#printsabc:def:ghi$PREMATCH $`见上面例子$POSTMATCH $'见上面例子 流程控制 ID项目描述if(!-f$ARGV[0])判断文件是否存在 正则表达式 OPERATORS =~determinestowhichvariabletheregexisapplied. Initsabsence,$_isused. $var=~/foo/; !~determinestowhichvariabletheregexisapplied, andnegatestheresultofthematch;itreturns falseifthematchsucceeds,andtrueifitfails. $var!~/foo/; m/pattern/igmsoxcsearchesastringforapatternmatch, applyingthegivenoptions. icase-Insensitive gGlobal-alloccurrences mMultilinemode-^and$matchinternallines smatchasaSingleline-.matches\n ocompilepatternOnce xeXtendedlegibility-freewhitespaceandcomments cdon'tresetposonfailedmatcheswhenusing/g If'pattern'isanemptystring,thelastI<successfully>matched regexisused.Delimitersotherthan'/'maybeusedforboththis operatorandthefollowingones. qr/pattern/imsoxletsyoustorearegexinavariable, orpassonearound.Modifiersasform//andarestored withintheregex. s/pattern/replacement/igmsoxesubstitutesmatchesof 'pattern'with'replacement'.Modifiersasform// withoneaddition: eEvaluatereplacementasanexpression 'e'maybespecifiedmultipletimes.'replacement'isinterpreted asadoublequotedstringunlessasingle-quote(')isthedelimiter. ?pattern?islikem/pattern/butmatchesonlyonce.Noalternate delimiterscanbeused.MustberesetwithL<reset|HYPERLINK"file:///E:\\Perl\\html\\lib\\Pod\\perlfunc.html"perlfunc/reset>. SYN