I have a Perl program that does not seem to be calculating numbers right. It parses a log file with lines in this format:
#ErrorLevel,Computer,IDO,Description,MinValue,MinTime,MaxValue,MaxTim +e,CurrentValue,CurrentTime 0,localhost,1.3.6.1.4.1.314.50.1.20.3.1.3,CFG persistent MEM,18720,11: +29,18760,12:30,17176,14:26
The code is supposed to see how the current values (from the %CONFIG hash) compare to the min and max values from the log, then make it the min_value or max_value if it is less than or greater than them (respectively). Here's a snippet of the code:
if (! /^\s*(\d),(\w+),([\d\.]+),([^,]+),([^,]+),(\d+:\d+),([^,]+),(\d+ +:\d+),.*$/ ) { exit_error("Cannot parce log file") } $level=$1; $computer=$2; $iod=$3; $comment=$4; $min_value=$5; $min_time=$6; $max_value=$7; $max_time=$8; if ( $CONFIG{$computer}{iod}{$iod}{value} =~ /\w+/ ) {} elsif ( $CONFIG{$computer}{iod}{$iod}{value} < $min_value ) { $min_value = $CONFIG{$computer}{iod}{$iod}{value}; $min_time = "$hour:$min"; } elsif ( $CONFIG{$computer}{iod}{$iod}{value} > $max_value ) { $max_value = $CONFIG{$computer}{iod}{$iod}{value}; $max_time = "$hour:$min"; } print LOG "$level,$computer,$iod,$comment,$min_value,$min_time,$max_va +lue, $max_time,$CONFIG{$computer}{iod}{$iod}{value},$hour:$min\n";
The problem is that at least sometimes have a current value that is less than the min_value, but doesn't get passed on to it (as in the log file line above).

In reply to When is not necessarily by melguin

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.