LanX has asked for the wisdom of the Perl Monks concerning the following question:
... 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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Goto-labels for exception handling?
by shmem (Chancellor) on May 09, 2018 at 19:38 UTC | |
Re: Goto-labels for exception handling?
by zentara (Cardinal) on May 10, 2018 at 13:40 UTC | |
Re: Goto-labels for exception handling?
by ikegami (Patriarch) on May 10, 2018 at 05:08 UTC | |
Re: Goto-labels for exception handling?
by RonW (Parson) on May 10, 2018 at 00:55 UTC | |
by LanX (Saint) on May 10, 2018 at 01:00 UTC | |
by RonW (Parson) on May 14, 2018 at 19:14 UTC | |
by LanX (Saint) on May 14, 2018 at 21:02 UTC | |
by RonW (Parson) on May 15, 2018 at 19:26 UTC | |
Re: Goto-labels for exception handling?
by Anonymous Monk on May 10, 2018 at 00:03 UTC | |
by LanX (Saint) on May 10, 2018 at 00:26 UTC |