in reply to Exception handling (alternatives)
# (by the way, i _do_ hate having to see # that 'sub' word right after try... # since there's no other way to # pass a block of code as an argument other than # via the anonymous sub/closure) # # try sub { # foo(); # };
You can use prototypes to enable passing sub-refs without the 'sub' keyword. See, for example, the perlsub manpage, and/or some of the other exception handling modules:Exception::Class, Error, and the older Exception for variations on try{}catch{} examples (actually, Exception::Class doesn't implement try/catch directly but you can use it in conjunction with Error.pm (according to the docs) to get that syntax with it). The (&) prototype is one of the few useful uses of prototypes (in certain circumstances).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Exception handling (alternatives)
by vladb (Vicar) on Dec 21, 2001 at 19:38 UTC | |
by vladb (Vicar) on Dec 21, 2001 at 19:51 UTC |