2010年8月17日星期二

[PerlChina] 求救 多行全部匹配问题

大家好!
         我有个文本,类似附件中的样子,我要的匹配项包括ip及<eid>标签中还有(B的内容知道</c>结束的这段日志。
以下是我的脚本,但是只能匹配到第1次的匹配项,以后的就匹配不到了,很是郁闷,各位帮我看看!
 
#!/usr/bin/perl -w
use strict;
open(L,'c:\\symbian.log') or die('Can not open this file!');
$/=undef;
my $a=<L>;
close(L);
$a=~/((\[ip =\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])\<c\>\n\<srqh\>\n[^\n]+\n[^\n]+\n[^\n]+\n\<\/srqh\>\n\<nd\>\n\<eid\>(.*?)\(B(.*?)\<\/eid\>\n\<whead\>(.*?)\<\/whead\>\n\<wbody\>(.*?)\<\/wbody\>(.*?)\<\/c\>)/sg;
print "============================================================\n";
print "$2\n";
print "----------------------------------\n";
print "$1\n";
print "============================================================\n";
 
 
不甚感激!
 
2010-08-17

zmf122333@126.com

没有评论: