Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The following code prints the highest busy value in every 5 minute increment. How can I print the increment (ex. 2:15 for 02:19:09) instead of the timestamp?
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] > $v +alue; } } print $_->[2] for @maxima;
Current output
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print Interval Instead of Timestamp
by zentara (Cardinal) on Jul 06, 2012 at 16:01 UTC | |
by frozenwithjoy (Priest) on Jul 06, 2012 at 16:29 UTC | |
|
Re: Print Interval Instead of Timestamp
by frozenwithjoy (Priest) on Jul 06, 2012 at 16:14 UTC | |
|
Re: Print Interval Instead of Timestamp
by Anonymous Monk on Jul 06, 2012 at 15:56 UTC |