in reply to Try string, not block

You can suggest it, but I don't think it'll be accepted.

(Besides which, I doubt it would actually be possible to implement without breaking the "Tiny" philosophy. try gets its block-handling syntax by using a sub prototype of (&;@). To be able to accept a string you'd need to part ways with that prototype which would make using Try::Tiny a lot uglier and would break backwards compatibility for all existing users of Try::Tiny; or you'd need to write a lot of custom parsing code using something like Devel::Declare, and that would make it a lot less tiny.)

Stringy eval is usually a sign of code smell (i.e. a sign that you're doing something bizarre that could be handled better another way). Taking your eval "require $module" as an example, you should take a look at Class::Load or Module::Runtime.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Try string, not block
by pushtaev (Sexton) on Sep 12, 2012 at 08:16 UTC

    It's just an example. I understand that "eval $string" is not in common usage, but question is how do I do it properly when I need to.