in reply to How do I add a delay in my perl program?

sleep usage:

while ( not defined $result ) { ( $result = try( $something ) ) or sleep 3; }

And a select example:

while ( not defined $result ) { ( $result = try( $something ) ) or select undef, undef, undef, 3000; }

select can be used to pause for n number of milliseconds, so 3000 would be three seconds. Though this isn't the primary purpose for select, it's a useful side effect. What's useful about it is that you have more resolution than with sleep (which only has one-second granularity).

Probably a more Perlish solution than abusing select would be to use Time::HiRes (which I believe comes with Perl). Its use is as simple as sleep:

use Time::HiRes qw/ usleep /; while( not defined $result ) { ( $result = try( $something ) ) or usleep( 3000 ); }

Dave