http://qs1969.pair.com?node_id=539387


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.