我是一个perl菜鸟,不知道该怎么做......
我的输入文件:
random text 00:02 23
random text 00:04 25
random text 00:06 53
random text 00:07 56
random text 00:12 34
... etc until 23:59
我想要以下输出:
00:00
00:01
00:02 23
00:03
00:04
00:05
00:06 53
00:07 56
00:08
00:09
00:10
00:11
00:12 34
... etc until 23:59
因此,如果在输入文件中找到具有每分钟时间戳和相应值的输出文件。我的输入文件从 00:00 开始,到 23:59 结束
到目前为止我的代码:
use warnings;
use strict;
my $found;
my @event;
my $count2;
open (FILE, '<./input/input.txt');
open (OUTPUT, '>./output/output.txt');
while (<FILE>){
for ($count2=0; $count2<60; $count2++){
my($line) = $_;
if($line =~ m|.*(00:$count2).*|){
$found = "$1 \n";
push @event, $found;
}
if (@event){
}
else {
$found2 = "00:$count2,";
push @event, $found2;
}
}
}
print OUTPUT (@event);
close (FILE);
close (OUTPUT);