Accumulate the values into a hash where the keys are the 5 minute slots. Split every 3rd set of values between the 2 affected slots. Divide by 5 for the averages:

#! perl -slw use strict; use Data::Dumper; my $re_line = qr[ ( \d\d ): ( \d\d ) ( .* $ ) ]x; my %timeslots; my $counter = 0; while( <DATA> =~ $re_line ) { # Extract hrs, mins, data into $1, $2, $ +3 my @temp = split ' ', $3; for( 0 .. 4 ) { # split every 3rd line between 2 5-minute slots if( $counter++ % 3 == 2 ) { $timeslots{ int( ( $1 * 60 + $2 ) / 5 ) }->[ $_ ] += $ +temp[ $_ ] / 2; $timeslots{ int( 1 + ( $1 * 60 + $2 ) / 5 ) }->[ $_ ] += $ +temp[ $_ ] / 2; } else { $timeslots{ int( ( $1 * 60 + $2 ) / 5 ) }->[ $_ ] += $ +temp[ $_ ]; } } } for my $ts ( sort{ $a <=> $b } keys %timeslots ) { printf '%2d:%02d' . ' [%f]' x 5 . $/, ( $ts * 5 ) / 60, ( $ts * 5 ) % 60, map{ $_ / 5 } @{ $timeslots{ $ts } } ; } __DATA__ 08/07/03.22:55 1.029 1.172 1.03 0.086 0.382 08/07/03.22:57 0.829 2.284 1.219 0.087 0.439 08/07/03.22:59 2.437 0.792 0.809 0.087 0.305 08/07/03.23:01 0.653 1.089 0.541 0.116 0.351 08/07/03.23:03 0.823 2.407 0.826 0.04 0.23 08/07/03.23:05 0.797 1.016 0.619 0.195 0.274 08/07/03.23:07 1.742 0.901 1.078 0.087 0.328 08/07/03.23:09 0.897 1.218 0.512 0.096 0.252 08/07/03.23:11 1.146 1.281 0.521 0.086 0.276 08/07/03.23:13 0.924 1.129 0.891 0.4 0.456 08/07/03.23:15 1.103 1.383 1.645 0.09 0.387 08/07/03.23:17 0.86 2.078 1.098 0.635 0.36 08/07/03.23:19 3.832 1.911 0.808 0.086 0.309

Output

P:\test>282224 22:55 [0.776100] [0.770400] [0.508600] [0.043300] [0.194700] 23:00 [0.295800] [0.778400] [0.322300] [0.035900] [0.146700] 23:05 [0.679800] [0.525400] [0.388100] [0.070000] [0.143400] 23:10 [0.503700] [0.455500] [0.301100] [0.106800] [0.146200] 23:15 [1.048700] [0.994700] [0.718500] [0.153200] [0.202800] 23:20 [0.110300] [0.207800] [0.080800] [0.009000] [0.036000]

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.


In reply to Re: data manipulation by BrowserUk
in thread data manipulation by Earindil

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.