Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Always Looping

by reasonablekeith (Deacon)
on Mar 27, 2006 at 08:00 UTC ( #539387=note: print w/replies, xml ) Need Help??


in reply to Re: Always Looping
in thread Always Looping

I'd always try to avoid a loop which could continue to fail like this. What if the file is deleted? You'll be looping forever.
use strict; use LWP::Simple; my $data = ""; my $try_count = 0; while ($try_count++ < 5) { $data = LWP::Simple::get('http://somedomain/'); last if defined $data; print "were is this file?\n"; sleep(5); };
I also changed the criteria for success to check for 'definedness', because the LWP::Simple::get() function will explictly return undef if it fails.
---
my name's not Keith, and I'm not reasonable.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-05-16 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (63 votes). Check out past polls.

    Notices?