Chinaunix首页 | 论坛 | 博客
  • 博客访问: 481999
  • 博文数量: 401
  • 博客积分: 244
  • 博客等级: 入伍新兵
  • 技术积分: 2215
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-04 10:02
文章分类

全部博文(401)

文章存档

2013年(37)

2012年(364)

发布时间:2012-12-20 10:43:57

介绍:grep (EXPR, LIST) Perl grep函数从LIST中提取符合EXPR的值。grep函数是比较常用,也比较好用的一个函数。我在shell里是经常用grep的。Perl grep函数在标量环境中,返回为真的次数。在列表环境中,返回EXPR为真的元素的列表。   例子:#!/usr/bin/perl @list = (1,"Test", 0, "foo", 20 ); @has_digit = grep ( /\d/, @list ); print "@has_digit\n"; 结果如下: 1 0 20 再来,抓取非真的元素: #!/usr/bin/perl......【阅读全文】

阅读(485) | 评论(0) | 转发(0)

发布时间:2012-12-19 20:22:27

Perl 中的正则表达式 1 正则表达式的三种形式 首先我们应该知道 Perl 程序中,正则表达式有三种存在形式,他们分别是: 匹配:m/<regexp>/ (还可以简写为 /<regexp>/ ,略去 m) 替换:s/<pattern>/<replacement>/ 转化:tr/<pattern>/<replacemnt>/ 这三种形式一般都和 =~ 或 !~ 搭配使用(其中 "=~" 表示相匹配,在整条语句中读作 does,"!~" 表示不匹配,在整条语句中读作 ......【阅读全文】

阅读(300) | 评论(0) | 转发(0)

发布时间:2012-12-19 20:22:15

1,indexposition = index (string, substring, position)返回子串substring在字符串string中的位置,如果不存在则返回-1。参数position是可选项,表示匹配之前跳过的字符数,或者说从该位置开始匹配。例子如下:[root@localhost ~]# echo -n '/var/fap/test/123' | perl -ne '$rev=index($_, "a"); print $rev,"\n";'2[root@localhost ~]# echo -n '/var/fap/test/123' | perl -ne '......【阅读全文】

阅读(316) | 评论(0) | 转发(0)

发布时间:2012-12-19 20:21:50

XPath语法 [ 2006-9-21 15:41:00 | By: 翻云刀 ]   XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.XPath使用路径表达式来选择XML文档的节或是节集。顺着路径或步骤来选择节。 The XML Example DocumentXML实例文档 We will use the ......【阅读全文】

阅读(251) | 评论(0) | 转发(0)

发布时间:2012-12-19 20:21:44

一、打开、关闭文件    语法为open (filevar, filename),其中filevar为文件句柄,或者说是程序中用来代表某文件的代号,filename为文件名,其路径可为相对路径,亦可为绝对路径。     open(FILE1,"file1");     open(FILE1, "/u/jqpublic/file1");   打开文件时必须决定访问模式,在PERL中有三种访问模式:读、写和添加。后两种模式的区别在于写模式将原文件覆盖,原有内容丢失,形式为:ope......【阅读全文】

阅读(229) | 评论(0) | 转发(0)
给主人留下些什么吧!~~
留言热议
请登录后留言。

登录 注册