Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: DBI messes up sleep

by bigmacbear (Monk)
on Sep 14, 2007 at 22:48 UTC ( [id://639102]=note: print w/replies, xml ) Need Help??


in reply to DBI messes up sleep

I think your issue is that you only actually check the time once, in the very first statement in the loop, when you run localtime(time). All the sprintf commands that follow merely format the same snapshot in time.

One of the nice features of localtime and gmtime in Perl is that if you run them in scalar context, you get a string with the time already formatted for you. So all you need to do to fix this issue is replace the assignment to $now every time it appears with:

$now = localtime(time);

and get rid of the first line that begins with "my" in its entirety. This will give you a much clearer picture of whether or not your sleep commands are being messed up by DBI, because they will be more accurate.

Replies are listed 'Best First'.
Re^2: DBI messes up sleep
by pilcrow (Sexton) on Sep 15, 2007 at 04:35 UTC
    ...you only actually check the time once, in the very first statement in the loop...

    No, localtime is called for each of many loop iterations, as you'll see if you inspect the sample output or re-examine (or run) the code.

    (I, too, saw the OP's false and misleading "time after sleep" print statement, and initially thought as did you.)

    -pilcrow

      I have to agree with bigmacbear that localtime is only called once per iteration. So the shown behaviour is as expected.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found