以下代码以每 5 分钟为增量打印最高繁忙值。如何打印增量(例如 02:19:09 的 2:15)而不是时间戳?
my @maxima;
for my $record (@lastArray) {
my @fields = $record =~ /([^,\s]+)/g;
next unless @fields;
my @range = @fields[1..4];
$range[2] =~ s|(\d+):\d\d$|5*int($1/5)|e;
my $range = join ' ', @range;
my $value = $fields[5];
if (@maxima == 0 or $range ne $maxima[-1][0]) {
push @maxima, [$range, $value, $record];
}
else {
@{$maxima[-1]}[1,2] = ($value, $record) if $maxima[-1][1] > $value;
}
}
print $_->[2] for @maxima;
电流输出:
Mon,Jun,25,02:19:09,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,02:21:09,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,02:25:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,02:56:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:00:10,2012,999,1,1,0,0,0,0,0,0,0,0
Mon,Jun,25,03:08:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:10:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:24:11,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:37:11,2012,999,1,0,0,0,0,0,1,0,0,0
Mon,Jun,25,03:40:11,2012,999,1,0,1,0,0,0,0,1,0,0