Re: counting in long variable in perl

From: Wayne Fulton (nospam_at_invalid.com)
Date: 11/18/03


Date: Mon, 17 Nov 2003 21:43:15 -0600

In article <slrnbriq9h.dt0.tadmc@magna.augustmail.com>,
tadmc@augustmail.com says...
>
>That can happen in a multitasking environment when you
>don't implement file locking, and the crufty code you snarfed
>doesn't do file locking.
>
>It was clearly written by an amateur. Be careful with it...

It came from a free script site. I used this one routine out of it to
increment a count file, a long time back. It is locked prior to the call,
via a named file. I know flock is better, important, but not in this
case. The value of this file is the timestamp it was last written, but
since it does count to change that timestamp, I'm curious why it doesnt
count right, why it appears to reset.

A race might occur, but for a counter that can only increment by one, I
dont see how such race could ever reset or decrease the count - it seems
to me that it might only miss a count or two, now and then. Such miss is
not important here in this case, but I'm puzzled why it resets.

>Numbers are double precision floating point internal to perl,
>they can go waaaaay beyond 65536.

That's why I suspected the print statement, but I dont know the cause. I
take it that you you dont think print is doing it.

I have not seen it reset to zero, nor turn over at 65K, that was just my
guess. The evidence I have seen (a few times) is that a prior larger
number like say 41234 might be 12926 next time I look (like after a few
months). I've never seen it past 65K, and I know it is counting several
times an hour, 24/7, so even if it is missing many of the counts, it
should be way over 65K by now, and I dont see how it can ever decrease.

OK, thanks, I will keep looking for the cause. I'll probably add flock
too, but I dont see how that can reset a counter.



Relevant Pages

  • Re: My "D" Drive has been removed
    ... use a CD Cleaner on it and clean it. ... I thought it was my Video card so I would just reset the computer and shut ... Ok my D drive on my computer has been removed, I dont know what ... I checked some log files ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: counting in long variable in perl
    ... >>don't implement file locking, and the crufty code you snarfed ... why it appears to reset. ... locking a file after opening it for plain old writing doesn't work. ...
    (comp.lang.perl.misc)
  • FS: working Gottlieb Magnotron project in cleveland
    ... I messed with it for 10 minutes & I can get it to reset & kick ... the game is beat, I think it was in a campground in its ... the cover for the coin door top where the coins go in) & can easily be ... I dont have pics now, but if interested I can snap a few & ...
    (rec.games.pinball)
  • Re: Freeze Panes Twice?
    ... I dont think either of those will work. ... PRINT | ADD | RESET | ... that "Freeze Pane" has the labels that need to remain on top of the ...
    (microsoft.public.excel.misc)
  • Re: Tapi 3.0 VB6.0 Event only sometimes works?
    ... as your TAPI object variable is holding an object. ... back...so I cant get the CallerID anymore:( ... If i shut my Application down or reset the Telephone(put off/on the ... Nothing everywhere I was not shure...but I think this dont solve my ...
    (microsoft.public.win32.programmer.tapi)