Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Sleep and Perl

by flexvault (Monsignor)
on Dec 16, 2015 at 05:59 UTC ( [id://1150463]=note: print w/replies, xml ) Need Help??


in reply to Re: Sleep and Perl
in thread Sleep and Perl

Hello toolic,

You may never get to the end of the file if you get more than 100 entries within 10 seconds. I believe the test needs to know the size of the file or the number of records to start with, otherwise you'll never know when you have xx records left.

If you know that each record average 100 bytes then...(untested)

my $size = -s $file; my $avg_recsize = 100; while my $record ( <$in> ) { if ( ( $size - ( 100 * $avg_recsize ) ) <= 0 ) { sleep(10); $size = -s $file; } . . . }
I think this is similar to the 'pop before email' technique. YMMV.

Regards...Ed

"Well done is better than well said." - Benjamin Franklin

Replies are listed 'Best First'.
Re^3: Sleep and Perl
by derby (Abbot) on Dec 16, 2015 at 11:53 UTC

    Hmmm ... Can you explain further. My read of the OP does not show any problems with getting to the end of the loop -- there's nothing in the body of the loop to prevent the eventual exit.

    -derby

      I think this is just a confusion between interpreting the sentence fragment "remainder of count" as "remaining records in file" vs "remainder of division applied to record count"

        Hello SuicideJunkie,

        Yes, I did interpret '...the sentence fragment "remainder of count" as "remaining records in file'.

        We have a tera-byte database that we exceed reading 100K records per second, so it seemed very odd to wait 10 seconds every 100 records. My bad!

        Regards...Ed

        "Well done is better than well said." - Benjamin Franklin

      Hello derby,

      Please see my answer to SuicideJunkie who's suspicion is correct!

      Regards...Ed

      "Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

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

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

    No recent polls found