行我有一个文件的内容:是:从文件中读取视病情
Change sets:
(0345) ---$User1 "test12"
Component: (0465) "textfiles1"
Modified: 14-Sep-2014 02:17 PM
Changes:
---c- (0574) /<unresolved>/sha.txt
Work items:
(0466) 90516 "test defect
我想读“90516”即工作项的使用Perl和放置在数组中的ID。 注意:这是一个条目,文件中可以有多行。 我想捕获所有这样的工作项目标识符,并将其放置在perl中。 代码
$file = new IO::File;
$file->open("<sha.log") or die "Cannot open sha.log";
@file_list = <$file>;
$file->close;
my %seen;
foreach $line (@file_list) {
#clear the array
undef %seen;
while ($line =~ m/Work items:/g) {
@temp = split(/[:|,]/, $1);
#push the item to array only if no items in temp array i.e. if the occurance is for the first time
next if $seen{ $temp[0] }++;
push @work_items, $temp[0];
}
}
显示你的代码。 – edem 2014-09-19 10:17:49