|
发表于 2004-6-14 02:05:49
|
显示全部楼层
回复: 怎样将一个while中第1个if中的反向引用变量$1的值带进第2个if里?
最初由 blackant 发表
在perl里,怎样将一个while中第1个if中的反向引用变量$1的值带进第2个if里?
#!/usr/bin/perl
open (FILE1,"dataaudit1.log") ||die "fail\n";
open (FILE2,">cem_slot.log") ||die "cem_slot.log don't open\n";
open (FILE3,">cem_pec.log") ||die "cem_pec.log don't open\n";
while (<FILE1>) {
my ($a, $b);
if (/MC800BTS\d{4}\s+1.+(XCEM|CCEM|UNKNOWN)\s+(000PNT|UNKNOWN)/) {
print FILE3 "$_";
$a=$1;
$b=$2;
}
elsif (/MC800BTS\d{4}.+\s+800\s+F/) {
print FILE2 "$_";
print $a;
print $b;}
}
close (FILE1);
close (FILE2);
close (FILE3); |
|