in reply to Re^12: Computing results through Arrays
in thread Computing results through Arrays
I may still not understand exactly what you're trying to do. But if you want to keep track of a max value for each time/database at the same time that you're keeping a total for the purpose of averaging, you could do something like this inside your while() loop:
$h{$ddhh }{$database}{total} += $speed; $m{$ddhhmm}{$database}{total} += $speed; $h{$ddhh }{$database}{max} = max(($h{$ddmm}{$database}{max} || 0), + $speed); $m{$ddhhmm}{$database}{max} = max(($h{$ddmm}{$database}{max} || 0), + $speed);
You can use the max() function from List::Util or write your own. Now later in the code where you used to access the total speed with $h{$timestamp}{$database}, you'll change that to access it as $h{$timestamp}{$database}{total}. And that makes room to keep track of the maximum value for each one in $h{$timestamp}{$database}{max}. Make sense?
Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^14: Computing results through Arrays
by yasser8@gmail.com (Novice) on Jun 26, 2015 at 09:32 UTC |