in reply to How to generate Perl statements on the fly and execute them when they are synthesized.

As noted, eval is your friend here.

However, note that in the specific task you are trying to do , you don't need to use evals. You can do something like:

@searchstrings = qw( cat dog ); if ( scalar grep { $str =~ $_ } @searchstrings == scalar @searchstrings ) { print "Found them all!\n"; }

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
It's not what you know, but knowing how to find it if you don't know that's important

  • Comment on Re: How to generate Perl statements on the fly and execute them when they are synthesized.
  • Download Code