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

You've got double quotes around the entire string in the concatenation loop. Not good. $execute.='$str=~/'.$animal.'/ && ';

You're removing the first && when you try to chop the last one. $execute =~ s/ && $//;

Both of these can be more succinctly fixed with map and join. But anyway...

You need to simple eval the expression: if (eval $execute) (Oh, and change the closing bracket).

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