Here is a typical generic wait for something or timout piece of code. In this case we wait for an exclusive file lock
my $timeout = 15; # timeout in seconds my $delay = 1; # number of seconds between re-tries open (FILE, ">$file") or die "Unable to create file '$file': $!\n"; my $count = 0; until (flock FILE, LOCK_EX) { sleep $delay; $count += $delay; die "Can't lock file '$file': $!\n" if $count >= $timeout; }
cheers
tachyon
In reply to Re: Waiting for an event
by tachyon
in thread Waiting for an event
by Segfault
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |