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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Stopping execution of an eval statement
by dave_the_m (Monsignor) on Jul 23, 2005 at 15:39 UTC | |
by slloyd (Hermit) on Jul 23, 2005 at 20:51 UTC | |
by polettix (Vicar) on Jul 23, 2005 at 21:12 UTC | |
by slloyd (Hermit) on Jul 25, 2005 at 12:37 UTC | |
Re: Stopping execution of an eval statement
by davidrw (Prior) on Jul 23, 2005 at 14:56 UTC | |
Re: Stopping execution of an eval statement
by kwaping (Priest) on Jul 23, 2005 at 15:03 UTC | |
Your evaluate() routine does not work.
by schwern (Scribe) on Jul 24, 2005 at 21:16 UTC |
Back to
Seekers of Perl Wisdom