Perl语言入门和提高06

Perl语言入门和提高06

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Spring, 2009 1 Perl 入门和提高 Lesson 6 周晓方 courses@xfzhou.homeftp.org Spring, 2009 2 Perlfunc 1 --- Help file, ( ), Category Where to find perlfunc information: (console window) perldoc -f func_name (perl install dir) c:\perl \ html\index.htm click perlfunc Careful print 1+2+4 ; # 7 print (1+2+4); # 7 print (1+2)+4; # 3, not 7, print (1+2) is a func-call. Category (altogether, about 200 pre-defined functions) Scalar/string , Reg-exp , Number , Arrays, List data , Hashs , In/output , Record, Filehandle/Dir, Control , Scoping, Miscelleous, Process , Perl-module , Class/OO, Socket , Uid/Gid , Network , Time, etc. Spring, 2009 3 Perlfunc 2 --- String and numeric $/ the input record seperator chomp $V ; chomp @L ; remove trailing $/ only chop $V ; chop @L ; chop of the last char chr( 65 ) returns "A" <=> ord "A" == 65 crypt $plantext, $salt (one way) hex( "0xFA1E" ) returns 64030 / 八进制用 oct "175036" 二进制怎么办 ? 0b101010 L ? 0xABCD L ? 其实 oct 函数是百搭 ! $v = oct $v if $v =~ /^0/; Case convert: uc/lc/ucfirst/lcfirst $str index STR, SUBSTR, POS; rindex substr $str, $offset, $len, $replace sprintf format , LIST abs, cos, exp, int, sin, cos, etc …… Spring, 2009 4 Perlfunc 3 --- quick review rand $e # random fraction [0,$ e ), default [0,1) srand 种子 # automatic called after perl 5.004 随机整数 ? int rand 100 返回 0..99 的随机整数 Array : push pop shift unshift splice List : grep join map reverse sort Hash : delete each exists keys values Remove a pair from hash : delete $hash{$key}; Check existence of a pair : exists $hash{$key}; Misc: defined scalar undef wantarray File: binmod e open close die warn print print f unlink rename read seek tell sysread syswrite etc …… Spring, 2009
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Perl&egrave;&macr;&shy;&egrave;&uml;€&aring;…&yen;&eacute;—&uml;&aring;’Œ&aelig;&eacute;&laquo;˜06

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online