FAQ

On Tue, Sep 16, 2014 at 11:05:14PM -0000, Father Chrysostomos wrote:
And it stops there. Somehow the message sent to the list has been truncated. The full version can be seen in the RT ticket.
I posted my thoughts on the wrong thread. I've had a mental image of error
strings from core behaving much like $! does -- the actual error is an
integer, but has a magic locale-aware stringification attached.

Therefore, code like this will behave the same as before:

     eval { foo() } or warn "got error: $@";

but code like this can be smarter:

     use Try::Tiny;
     try { foo() }
     catch { # $@ is now in $_
         create_file() if $_ == EFILENOTFOUND;
         create_dir() if $_ == EDIRNOTFOUND;
         ...
     };

This would make a *lot* of code simpler (with the exception of having to
cope with back-compatibility, alas). The very first example I have at the
top of my mind is:
https://metacpan.org/source/ZEFRAM/Module-Runtime-0.014/lib/Module/Runtime.pm#L378

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2021 Grokbase