{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Perl语言入门和提高06

Perl语言入门和提高06

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

View Full Document Right Arrow Icon
Spring, 2009 1 Perl 入门和提高 Lesson 6 周晓方 [email protected] 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 ? 0xABCD ? 其实 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: binmode open close die warn print printf unlink rename read seek tell sysread syswrite etc …… Spring, 2009 5 Perlfunc 4 ——
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern