Based on the data you have shown. I wrote the code below. However, please be warned that I wrote this off the top of my head and it may not work or even do what I purport it to do.

use strict; use warnings; my @array; my @values; my $avg; while(my $line = <DATA>) { push @array, $line; } foreach my $line2 (@array) { my ($time, $val, $err) = split / /, $line2; push @values, $val; my $tot_val += $val; $avg = $tot_val / $#array; } my @sort_max = sort {$a <=> $b} @values; my @sort_min = soft {$b <=> $a} @values; my $max_val = pop @sort_max; my $min_val = pop @sort_min; foreach my $line3 (@array) { my ($time, $val, $err) = split / /, $line3; if($val == $max_val) { print "max: $line3" . "\n"; } elsif($val == $min_val) { print "min: $line3" . "\n"; } } print "avg: $avg" . "\m"; __DATA__ 04/26/04.16:15 3.088 N 04/26/04.16:15 5.994 N 04/26/04.16:15 4.391 N 04/26/04.16:15 3.616 N 04/26/04.16:20 3.997 N 04/26/04.16:20 4.151 N 04/26/04.16:20 3.751 N 04/26/04.16:20 2.887 N 04/26/04.16:25 3.657 N 04/26/04.16:25 4.712 N 04/26/04.16:25 4.346 N 04/26/04.16:30 3.628 N 04/26/04.16:30 5.636 N 04/26/04.16:30 4.593 N


In reply to Re: rearrange data to min, avg, max by cyocum
in thread rearrange data to min, avg, max 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.