You were using the same variable $x for max and min, and never updating it, nor comparing with the current max value for a $server and $metric combination. I'm surprised either max or min was correct. I suggest an alternative approach.

while(<DATA>){ next unless /\w/; my($server,$datetime,$metric,$value) = (split)[0,1,2,3]; $value =~ s/,//g ; my $ddhh = substr $datetime,0,13; my $dd = substr $datetime,0,10; if (! defined($d{$dd }{$server}{$metric}{max})) { $d{$dd }{$server}{$metric}{max} = 0; $d{$dd }{$server}{$metric}{min} = 99999999; $h{$ddhh }{$server}{$metric}{max} = 0; $h{$ddhh }{$server}{$metric}{min} = 99999999; } $d{$dd }{$server}{$metric}{max} = $value if ($d{$dd }{$serve +r}{$metric}{max} < $value); $d{$dd }{$server}{$metric}{min} = $value if ($d{$dd }{$serve +r}{$metric}{min} > $value); $h{$ddhh }{$server}{$metric}{max} = $value if ($h{$ddhh }{$serve +r}{$metric}{max} < $value); $h{$ddhh }{$server}{$metric}{min} = $value if ($h{$ddhh }{$serve +r}{$metric}{min} > $value); $ser{$server} = 1; $met{$metric} = 1; }
Dum Spiro Spero

In reply to Re^5: Analytics on Hash Arrays by GotToBTru
in thread Analytics on Hash Arrays by yasser8@gmail.com

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.