the typical way to accomplish this is by using the perl alarm function. here's a simple example from section 5.6 of 'advanced perl programming:'
this is all well an good for *NIX systems, but Win32 doesn't implement alarm. (see Alarm Implemented in Win32? for details.) curiously, Win32 does implement SIGALARM. consider:$SIG{ALRM} = \&timed_out; eval { alarm (10); $buf = <>; alarm(0); # Cancel the pending alarm if user responds. }; if ($@ =~ /GOT TIRED OF WAITING/) { print "Timed out. Proceeding with default\n"; .... } sub timed_out { die "GOT TIRED OF WAITING"; }
yep, $SIG{ALRM} is a valid key in %SIG. but is it really?C:\>perl -e "print join ' ', keys %SIG" STOP NUM05 NUM06 ALRM NUM07 NUM24 NUM16 NUM17 NUM18 NUM19 ILL CHLD SEG +V PIPE CLD ABRT CONT INT QUIT KILL BREAK TERM NUM01 FPE NUM10 NUM12
i don't know enough about signals to be able to use a magic number or password to signal an ALRM. i don't know if it is even possible on Win32. if not, is there some other way for me to break out of an eval block before an operation has completed?
~Particle
In reply to ALRMing behavior on Win32 by particle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |