in reply to How to generate Perl statements on the fly and execute them when they are synthesized.
if ($execute}Change the curly to a paren and it might work better :) Also, use single quotes in assigning $execute to prevent interpolation
update: that chop doesn't do what you think it does. Try printing $execute after the substitution.....
$execute =~ s/ && $//; works.
update2 I gave bad advice on the single quotes. You WANT interpolation since $animal is meaningless outside the loop. DOH!
$execute .= '$str =~ /'.$animal.'/ && ';
|
|---|