develooper Front page | perl.perl5.porters | Postings from July 2013

Re: Try/Catch Exception Objects: Possible?

Thread Previous | Thread Next
David Golden
July 23, 2013 19:05
Re: Try/Catch Exception Objects: Possible?
Message ID:
On Tue, Jul 23, 2013 at 2:32 PM, David Golden <> wrote:
> I would recommend using $@ for familiarity.

Expanding on this thought:

I see no problem omitting $@ entirely in the context of a
well-designed try/catch syntax that doesn't need to park the exception
in a temporary variable (e.g. if 'catch FOO' catches any exception
that isa 'FOO').  However, if the exception needs to be parked in a
global, I'd park it in $@ for consistency with what happens outside

I'd also probably be happy with something that moved us away from
keeping errors in globals entirely during exception handling and just
passed them as arguments to handler blocks.  E.g.:

    try {
    catch error::io, error::network {
        my $err = shift;
        # do something useful
    otherwise {
        log_this( shift );
    finally {


David Golden <>
Take back your inbox! →
Twitter/IRC: @xdg

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About