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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|