http://qs321.pair.com?node_id=477474

slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to stop the execution of an eval statement during execution without killing the main program?
use strict; $SIG{INT}=\&stopEvaluate; $SIG{HUP}=\&stopEvaluate; my $x=0; my $evalstatement=qq| for(my \$x=0;\$x<25;\$x++){ print "line \$x\n"; sleep(\$x); } return "statement Done"; |; evaluate($evalstatement); print "Done\n"; exit; sub evaluate{ my $perl=shift || return; print "evaluate\n$perl\n\n"; my $rtn=eval($perl); if($@){return $@;} return $rtn; } sub stopEvaluate{ print "stopping eval..."; #Can I call something to stop the eval. return; }