Hello.
We are using Try::Tiny module in our project. I'm always using "try" instead of "eval" whenever I can, but eval can do some things, that "try" cannot: it's evaluation code from strings.
So, when I use eval() with string I should do something like this:
eval "require $module" or $self->error("...");
instead of nice and pretty
try "require $module" # It's not going to work catch { $self->error("..."); }
I can try something like this:
try { eval "require $module" or die $@; } catch { $self->error("..."); }
but it still looks ugly, because it's actually eval{eval""}.
Should I worry about this? Should I suggest improving Try::Tiny so it can "try" strings, not only blocks?
P. S. I believe the root of the problem is perl "eval" itself. It does two things for me (evaluate strings AND catch "exceptions") that are not really connected.
In reply to Try string, not block by pushtaev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |