Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Run in eval and out of evalby wrc (Initiate) |
on Apr 13, 2012 at 12:10 UTC ( [id://964905]=perlquestion: print w/replies, xml ) | Need Help?? |
wrc has asked for the wisdom of the Perl Monks concerning the following question:
How can a perl object know when it is running in an eval compared to running outside an eval?
So an object which is running something that generates a huge log. When the exception is thrown. it send a message and the catch will dump the log.
eval{ $obj->run() };if ($@) { $obj->dump(); }
And this is the way to run the object. But some people won't read the doc and simply run:
$obj->run();
and expect the script to die with a log dump if it fails.
Other than a $obj->set_verbose(); is there a way to determine if the object is running under an eval?
Back to
Seekers of Perl Wisdom
|
|