0
我有一個文件數組。用的幾行文字的每個文件,在外面我試圖打通的regex幾個特定字符串在Perlperl:讀取文件時的正則表達式
use strict;
use warnings;
foreach my $myfile (@myFiles) {
open my $FILE, '<', $myfile or die $!;
while (my $line = <$FILE>) {
my ($project, $value1, $value2) = <Reg exp>, $line;
print "Project : $1 \n";
print "Value1 : $2 \n";
print "Value2 : $3 \n";
}
close(FILE);
}
*文件內容*
Checking Project foobar
<few more lines of text here>
Good Files excluding rules: 15 - 5%
Bad Files excluding rules: 270 - 95%
<one more line of text here>
Good Files including rules: 15 - 5%
Bad Files including rules: 272 - 95%
<few more lines of text here>
*所需的輸出*
Project:foobar
Value1 : Good Files excluding rules: 15 - 5%
Bad Files excluding rules: 270 - 95%
Value2 : Good Files including rules: 15 - 5%
Bad Files including rules: 272 - 95%
'打開我的$ FILE, '<',$ MYFILE死$';;缺少$ myfile'和'die'之間'一個'或'! – 2014-09-18 20:23:01
@JimDavis謝謝,更新 – Jill448 2014-09-18 20:48:08
這些行是嚴格的順序,如「好/壞排除」,然後「好/壞包括」,或者他們是否有序和可能交錯?另外,我還沒有跟上Perl,這是',$ line'一個新的構造? –
sln
2014-09-18 21:44:32