|laziness, impatience, and hubris|
Stopping code in evalby Outaspace (Scribe)
|on Jul 19, 2006 at 21:44 UTC||Need Help??|
Outaspace has asked for the
wisdom of the Perl Monks concerning the following question:
Dear all wise Monks of the Perl Code,
i have a question that is disturbing my inner confidence.
I want to eval a piece of code. So with an eval I can make sure that an error in the code dont let me script die. But what if the code enter an infinite loop? Is there any way (except modifying the code that is evaled) to stop it My script so far:
Now I want to give the text to be evaled a certain time to execute and break it of if it not ended after this time. Because the code can be anything (contains maybe an infinite loop or something else that can hang). I cant run it as a separate process, because it needs the context of my script. Anyone have any idea ?
Bless Perl and all other things that are good and righteous,