in reply to Re^2: Dynamic given statement
in thread Dynamic given statement

Not sure I follow you altogether but it seems what you want to do is something like:

while(my $thing = input()){ my $consequence = given_thing($thing,\&get_file,qw(foo bar baz)); ## accept the consequences of your actions ... } sub given_thing { my ($thing,$action,@keys) = @_; do { $thing ~~ $_ and return $action->($thing)} for @keys; }

I wouldn't be too quick to throw eval away. Sure it is slow and a security risk but the ability to dynamically create executable perl can significantly shorten the road from here to there.

Replies are listed 'Best First'.
Re^4: Dynamic given statement
by Logicus (Initiate) on Oct 22, 2011 at 22:33 UTC

    I concur that eval has it's place, it's just that in most cases there exists a neat solution that can and really ought to be used instead.