On Sat, Sep 15, 2012 at 03:40:06PM -0400, Pushtaev Vadim via RT wrote:
Show quoted text> Queue: Try-Tiny
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=79666 >
>
> On Sat Sep 15 15:32:44 2012, doy@tozt.net wrote:
> >
> > This was considered when Try::Tiny was first being written, but the
> > conclusion was that there is actually no way to do this safely, given
> > limitations in perl itself. About the closest you're going to be able
> to
> > get is something like "try { eval_closure(source => $foo) }" (using
> > Eval::Closure).
> >
> > -doy
>
> Thanks, I like this Eval::Closure module.
>
> What about non-safe "try_string" function, like perl "eval" itself? You
> don't want to spread evil over the world? :)
As I said, it's not possible in a general sense - note that
Eval::Closure is limited to string eval of strings that return coderefs
(the example I gave should really be something more along the lines of
"try { eval_closure(source => "sub { $foo }")->() }"). Not all code can
be wrapped in subs like that though.
-doy