I don't know whether this will help, but notice the following transitional segment in the CDR data:

1161871200:12495 A 1161957600:14027 B 1162044000:12132 C 1162126800:10963 D <-3600 less than C 1162130400:0 E <-C + 86400 created and then set to 0 1162213200:12939 F 1162216800:0 G 1162299600:12849 H B = A + 86400 C = B + 86400 D = C + 82800 (3600 less) E = D + 3600 F = D + 86400

Line D is 3600 seconds short of the pattern which your script implements, so it's creating entries from E on, based upon the assumption that entries are always 86400 seconds apart. Line D appears to be an outlier that's caused this problem. This would also account for the two different loops producing the same result.

Given the above, perhaps this will work on your particular data set (untested, so please use with caution):

if ($VAR::CDR_EVENT_COUNT{$eventName}{$loopTime}) { $loopTime = $loopTime + 86400; } elsif($VAR::CDR_EVENT_COUNT{$eventName}{$loopTime-3600}) { $loopTime = $loopTime - 3600; # Adjust $loopTime for outlier value } else { $VAR::CDR_EVENT_COUNT{$eventName}{$loopTime} = 0; $loopTime = $loopTime + 86400; }

This adds a conditional check for an entry only 82800 seconds beyond the previous entry, and then adjusts $loopTime down by 3600 seconds if found. (This downward adjustment will cause the outlier value to be looked at again, but it seems more readable to do this than to add 169200 (86400*2-3600) to $loopTime to skip over the outlier to the next entry.) Continuing to add 86400 to $loopTime within the loop should then work after the adjustment.

Hope this helps!


In reply to Re: loop issue by Kenosis
in thread loop issue by chefchanyu

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.