Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: loop issue

by Kenosis (Priest)
on Aug 10, 2012 at 03:52 UTC ( [id://986652]=note: print w/replies, xml ) Need Help??


in reply to loop issue

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!

Replies are listed 'Best First'.
Re^2: loop issue
by chefchanyu (Novice) on Aug 10, 2012 at 05:34 UTC
    Thanks fix this issue :). after I check all those times, I did found a entry is 82800. it was 20061029 - 20061030. so why have this issue happen?
    CDR_TOTAL_901J902M905S906WAPENC906System932X: 1152799200 - 1152712800 = 86400 1152885600 - 1152799200 = 86400 1152972000 - 1152885600 = 86400 1153058400 - 1152972000 = 86400 1153144800 - 1153058400 = 86400 1153231200 - 1153144800 = 86400 1153317600 - 1153231200 = 86400 1153404000 - 1153317600 = 86400 1153490400 - 1153404000 = 86400 1153576800 - 1153490400 = 86400 1153663200 - 1153576800 = 86400 1153749600 - 1153663200 = 86400 1153836000 - 1153749600 = 86400 1153922400 - 1153836000 = 86400 1154008800 - 1153922400 = 86400 1154095200 - 1154008800 = 86400 1154181600 - 1154095200 = 86400 1154268000 - 1154181600 = 86400 1154354400 - 1154268000 = 86400 1154440800 - 1154354400 = 86400 1154527200 - 1154440800 = 86400 1154613600 - 1154527200 = 86400 1154700000 - 1154613600 = 86400 1154786400 - 1154700000 = 86400 1154872800 - 1154786400 = 86400 1154959200 - 1154872800 = 86400 1155045600 - 1154959200 = 86400 1155132000 - 1155045600 = 86400 1155218400 - 1155132000 = 86400 1155304800 - 1155218400 = 86400 1155391200 - 1155304800 = 86400 1155477600 - 1155391200 = 86400 1155564000 - 1155477600 = 86400 1155650400 - 1155564000 = 86400 1155736800 - 1155650400 = 86400 1155823200 - 1155736800 = 86400 1155909600 - 1155823200 = 86400 1155996000 - 1155909600 = 86400 1156082400 - 1155996000 = 86400 1156168800 - 1156082400 = 86400 1156255200 - 1156168800 = 86400 1156341600 - 1156255200 = 86400 1156428000 - 1156341600 = 86400 1156514400 - 1156428000 = 86400 1156600800 - 1156514400 = 86400 1156687200 - 1156600800 = 86400 1156773600 - 1156687200 = 86400 1156860000 - 1156773600 = 86400 1156946400 - 1156860000 = 86400 1157032800 - 1156946400 = 86400 1157119200 - 1157032800 = 86400 1157205600 - 1157119200 = 86400 1157292000 - 1157205600 = 86400 1157378400 - 1157292000 = 86400 1157464800 - 1157378400 = 86400 1157551200 - 1157464800 = 86400 1157637600 - 1157551200 = 86400 1157724000 - 1157637600 = 86400 1157810400 - 1157724000 = 86400 1157896800 - 1157810400 = 86400 1157983200 - 1157896800 = 86400 1158069600 - 1157983200 = 86400 1158156000 - 1158069600 = 86400 1158242400 - 1158156000 = 86400 1158328800 - 1158242400 = 86400 1158415200 - 1158328800 = 86400 1158501600 - 1158415200 = 86400 1158588000 - 1158501600 = 86400 1158674400 - 1158588000 = 86400 1158760800 - 1158674400 = 86400 1158847200 - 1158760800 = 86400 1158933600 - 1158847200 = 86400 1159020000 - 1158933600 = 86400 1159106400 - 1159020000 = 86400 1159192800 - 1159106400 = 86400 1159279200 - 1159192800 = 86400 1159365600 - 1159279200 = 86400 1159452000 - 1159365600 = 86400 1159538400 - 1159452000 = 86400 1159624800 - 1159538400 = 86400 1159711200 - 1159624800 = 86400 1159797600 - 1159711200 = 86400 1159884000 - 1159797600 = 86400 1159970400 - 1159884000 = 86400 1160056800 - 1159970400 = 86400 1160143200 - 1160056800 = 86400 1160229600 - 1160143200 = 86400 1160316000 - 1160229600 = 86400 1160402400 - 1160316000 = 86400 1160488800 - 1160402400 = 86400 1160575200 - 1160488800 = 86400 1160661600 - 1160575200 = 86400 1160748000 - 1160661600 = 86400 1160834400 - 1160748000 = 86400 1160920800 - 1160834400 = 86400 1161007200 - 1160920800 = 86400 1161093600 - 1161007200 = 86400 1161180000 - 1161093600 = 86400 1161266400 - 1161180000 = 86400 1161352800 - 1161266400 = 86400 1161439200 - 1161352800 = 86400 1161525600 - 1161439200 = 86400 1161612000 - 1161525600 = 86400 1161698400 - 1161612000 = 86400 1161784800 - 1161698400 = 86400 1161871200 - 1161784800 = 86400 1161957600 - 1161871200 = 86400 1162044000 - 1161957600 = 86400 --->1162126800 - 1162044000 = 82800 1162213200 - 1162126800 = 86400 1162299600 - 1162213200 = 86400 1162386000 - 1162299600 = 86400 1162472400 - 1162386000 = 86400 1162558800 - 1162472400 = 86400 1162645200 - 1162558800 = 86400 1162731600 - 1162645200 = 86400 1162818000 - 1162731600 = 86400 1162904400 - 1162818000 = 86400 1162990800 - 1162904400 = 86400 1163077200 - 1162990800 = 86400 1163163600 - 1163077200 = 86400 1163250000 - 1163163600 = 86400 1163336400 - 1163250000 = 86400 1163422800 - 1163336400 = 86400 1163509200 - 1163422800 = 86400 1163595600 - 1163509200 = 86400 1163682000 - 1163595600 = 86400 1163768400 - 1163682000 = 86400 1163854800 - 1163768400 = 86400 1163941200 - 1163854800 = 86400 1164027600 - 1163941200 = 86400 1164114000 - 1164027600 = 86400 1164200400 - 1164114000 = 86400 1164286800 - 1164200400 = 86400 1164373200 - 1164286800 = 86400 1164459600 - 1164373200 = 86400 1164546000 - 1164459600 = 86400 1164632400 - 1164546000 = 86400 1164718800 - 1164632400 = 86400 1164805200 - 1164718800 = 86400 1164891600 - 1164805200 = 86400 1164978000 - 1164891600 = 86400 1165064400 - 1164978000 = 86400 1165150800 - 1165064400 = 86400 1165237200 - 1165150800 = 86400 1165323600 - 1165237200 = 86400 1165410000 - 1165323600 = 86400 1165496400 - 1165410000 = 86400 1165582800 - 1165496400 = 86400 1165669200 - 1165582800 = 86400 1165755600 - 1165669200 = 86400 1165842000 - 1165755600 = 86400 1165928400 - 1165842000 = 86400 1166014800 - 1165928400 = 86400 1166101200 - 1166014800 = 86400 1166187600 - 1166101200 = 86400 1166274000 - 1166187600 = 86400 1166360400 - 1166274000 = 86400 1166446800 - 1166360400 = 86400 1166533200 - 1166446800 = 86400 1166619600 - 1166533200 = 86400 1166706000 - 1166619600 = 86400 1166792400 - 1166706000 = 86400 1166878800 - 1166792400 = 86400 1166965200 - 1166878800 = 86400 1167051600 - 1166965200 = 86400 1167138000 - 1167051600 = 86400 1167224400 - 1167138000 = 86400 1167310800 - 1167224400 = 86400 1167397200 - 1167310800 = 86400

      Am unsure why the issue happened, but am glad the script is now working for you...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://986652]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-03-19 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found