... did anybody ever try to use goto-labels for poor mans exceptions? I'd like to see those CPAN modules.
Please note that here it's possible to test if a receiver exists.
{ my ($exception,$msg); sub throw { ($exception,$msg) = @_; eval { goto "$exception" }; if ($@) { warn "Couldn't find target $exception"; } } sub get_exception { return ($exception,$msg); } } sub test { throw "DONT_CATCH", "...because... Your Mother ..."; throw "ERROR", "...because"; } { test(); last; ERROR: warn "Caught Error..." , get_exception; }
Couldn't find target DONT_CATCH at d:/Users/lanx/pm/catch_goto.pl line + 12. Caught Error...ERROR...because at d:/Users/lanx/pm/catch_goto.pl line +39.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
In reply to Goto-labels for exception handling? by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |