摘要: 正则表达式。所谓正则表达式,是由斜杠圈起的一组字符集合。它们可用于在文本中匹配指定模 式,并进行相应替换操作。一直以来,Perl 都因为其优秀的模式匹配机制而闻名于世。 表2-2 一些正则表达式元字符 元字符 表达含义 ^ 匹配行首 ... 阅读全文
posted @ 2011-09-14 20:05 绿色的麦田 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1、读取某文件,如果该文件不存在,则报错,并提示出错原因 open (DB, "/home/ellie/myfile") or die "Can't open file: $!\n"; 运行后提示:Can't open file: No such file or director2、读写文件的方法: open(FH, "<filename"); # Opens "filena... 阅读全文
posted @ 2011-09-14 15:46 绿色的麦田 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 以下函数计算某年份是否为闰年 #!/usr/bin/perl$my_year = 2000;if ( is_leap_year( $my_year ) ){ # Call function with an argument print "$my_year is a leap year\n";}else{ print "$my_year is not a leap ye... 阅读全文
posted @ 2011-09-14 14:27 绿色的麦田 阅读(943) 评论(0) 推荐(0) 编辑