Ovid has asked for the wisdom of the Perl Monks concerning the following question:
If you have an anonymous function die, you can still "name" the function to make for better error messages:
use Carp 'croak'; sub { local *__ANON__ = 'my_anonymous_sub'; croak("Whee!"); }->(); __END__ Whee! at anon.pl line 9 main::my_anonymous_sub() called at anon.pl line 10
Unfortunately, if the error is in an eval, you get messsages like:
Some annoying error at (eval 7) line 17281Can anyone think of a method of naming evals to make debugging easier?
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Named evals? (#line)
by tye (Sage) on Jan 29, 2008 at 15:31 UTC | |
by Ovid (Cardinal) on Jan 29, 2008 at 15:42 UTC | |
|
Re: Named evals? (Sub::Name)
by lodin (Hermit) on Feb 01, 2008 at 12:08 UTC |