I figured out I can do this:
eval {
local $SIG{ALRM} = sub { warn("alarm\n") };
alarm 1;
for(my $j = 0; $j < 1_000_000, $j++) {
my $x = log(rand()*1000+1);
}
alarm 0;
};
if ( $@ ) {
carp "[EMAIL PROTECTED]";
}
Which is very similar to the man pages.
But there are a few inconsistencies I'm trying to sort out.
First, I can't seem to get the statement from the manpages
die $@,"\n" unless $@ eq "alarm\n";
to work.
Second, I tried putting this into a for(){...} loop to attempt this 5
times. I can't seem to get it to do that. It goes through one loop and
then it just keeps doing the warn("alarm\n") without doing anything else.
Conceptually, I'm trying to do something and if it take too long, start
over again, retrying 5 times.
Unfortunately 'perl -d' really doesn't handle this very well.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>