Hi all,
Sorta newbie here...
I have parsed log files and have an array of arrays that looks like this:
[...]
1 0.0 0.000 31.954 36.169 12.645 20:40
16 1048.0 16.196 15.825 52.502 5.150 20:40
8 1281.7 12.059 9.634 41.264 4.869 20:40
9 1157.7 19.094 16.889 52.218 4.742 20:40
0 0.0 0.000 76.430 109.366 7.179 20:50
0 203.3 7.029 35.411 65.495 10.142 20:50
0 167.5 8.476 51.829 78.884 24.049 20:50
0 135.3 4.371 33.088 54.554 16.763 20:50
2 0.0 0.000 22.612 23.297 13.714 21:00
5 260.0 5.233 20.610 46.264 9.826 21:00
0 242.3 7.003 29.601 56.070 8.485 21:00
0 227.3 5.954 26.831 50.991 10.794 21:00
0 0.0 0.000 28.523 56.333 10.554 21:10
0 146.9 4.573 31.879 61.403 10.197 21:10
0 151.4 4.330 29.295 54.513 11.121 21:10
0 134.6 3.911 29.753 57.781 10.771 21:10
[...]
7 values in each row. 4 rows represent 1 data set. I need to get an
avearge for each of the values in the first 6 columns and 4 rows each. The
last value is a timestamp so I don't need an average on that. So for every
4 rows, I need to end up with 1 row of 7 numbers, the first 6 being averages
and the 7th being the time.
I have a subfunction, Average, defined like this:
sub Average {
my ($Sum,$Average) = 0;
foreach my $item (@_) {
$Sum += $item;
}
my $Average = ($Sum / 4);
return $Average;
}
My question is how to walk through the array grabbing column 1 of four rows,
pass those values to the Average function (or if there is a beter way, I am
open to it!), store the average to be used by GD later, then do the next
column, etc, up to column 6, then move on to next 4 rows. Any help is much
appreciated! Thanx!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>