in reply to Stopping code in eval

It's possible to terminate some varieties of infinite looping with alarm():

# setup an ALRM handler my $timed_out = 0; local $SIG{ALRM} = sub { die "Timed out!" }; # run some code for 10 seconds max eval { alarm 10; # let it run 10 seconds eval($code); die $@ if $@; }; # figure out if it got an alarm warn "Alarm rang!" if $@ and $@ =~ /Timed out!/;

However, an infinitely running regex would probably not get interupted here due to Perl's new safe-signals implementation which only looks for new signals between op-codes.

-sam