intrperl - courses@xfzhou.homeftp.org Jan 9, 2006 2003-2004:

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

View Full Document Right Arrow Icon
语言讲座 周晓方 courses@xfzhou.homeftp.org Jan 9, 2006 2003-2004 年老讲义在这里下载 : http://xfzhou.homeftp.org/courses/perl04/index.htm http://xfzhou.homeftp.org/courses/perladv/index.htm 2 的入门部分 的提高部分 Perl 语言简介、自学方法 标量、列表 / 数组、 Hash 表及其操作 控制结构,子程序, perl 程序 文件操作 正则表达式 Perl 的内部函数 Perl Perl Perl 的引用,表示复杂的数据结构 的引用,表示复杂的数据结构 的引用,表示复杂的数据结构 面向对象的 面向对象的 面向对象的 Perl Perl Perl 使用 Perl 模块, CPAN
Background image of page 1

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

View Full DocumentRight Arrow Icon
3 安装 版本 特色 参考书 Larry Wall www.perl.com, www.activestate.com www.CPAN.org http://courses.xfzhou.homedns.org/perl/ 参看版本信息 perl - v perl -V Books and references: –“ Learning Perl, 4 th ed ”“ Programming Perl Perl 编程 24 学时教程 "Perl CD book shelf ver1/2/3" "Perl Best Practices" 以及很多专题类的 Perl On-line documents (Windows) C:/perl/html/index.htm, Click perlfunc, perlfaq, perlxs, …… perldoc command (Windows and Linux, etc) perldoc -f print, perldoc -m benchmark, perldoc perldoc Sometimes use with "pod2text", "pod2html" 标量、数组 列表、
Background image of page 2
5 标量 -- 脚本语言,几乎不区分整数、实数 和字符串 $ Variable_Name, name is case-sensitive Value can be string, numeric value, or ref/obj 表示法 (What about arbitrary size numbers?) (What about arbitrary size numbers?) Decima l 123 4 Octa l 01234 Hexadecima l 0x123 4 Fraction/float 12.34 Scientific notation 0.00001234, 1.234e-5 字符串 表示法 " 有插值 " qq/ / qq( ) qq! ! ' 插值 ' q/ / qq( ) q! ! ` 执行系统命令 ` qx/ / 引用 \ 和解 引用 ${ } reference : $A = 12.34; $refA = \$A; dereference : print $$refA; # short for ${$refA} 6 File extenstion "pl", "hello.pl" (also .p .cgi) perl hello.pl #! "she-bang" "use strict" and "-w" String, "" and ' ', \n, \t, \\, \? \? \033, \x1b 注意 $@% 1 and 0 #!/usr/local/bin/perl -w use strict; my $A = "World"; my $B = 2; print 'Hello World!', "\n"; print "Hello $A for the ${B}nd time!\n"; 1 ; #program terminates successfully Hello World! Hello World for the 2nd time!
Background image of page 3

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

View Full DocumentRight Arrow Icon
7 函数 Undefined variable has the value undef Treat as 0 when used as a number Treat as zero length string when as a string The keyword undef has the value undef Funtion defined (EXPR) check if the value is defined or undefined. Funtion undef (LEXPR) clears the LEXPR and makes it undefined. Some function return undef for special meanings C 语言不 写条 判断 别小心 if ($A) 表示 $A!=0 and $A ne "" and defined $A if (defined $A) 判断 $A 是否有定 例如 buggy while ($num=shift @_){ …… } defined($num= ) 8 脚本语言,数组 空间无须申明 释放 大小可变 @ArrName , $ArrName[index], @ArrName[i1, i2, i3] (1, 2, 3,"oops", 5, 6), (5, 1 . . 6, 7) qw(aaa bbb ccc) 相当于 ("aaa", "bbb", "ccc")
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 72

intrperl - courses@xfzhou.homeftp.org Jan 9, 2006 2003-2004:

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

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