in reply to Compiling regular expressions to perform substitution

The reason they aren't compiling properly is that s/// is an operator. If you are going to be compiling regexps from a string, you need only compile the left-hand side of a s///, as the right-hand side is essentially a double quoted string.
use strict; my $re = qr/foo./; my $str = "foo bar baz"; $str =~ s/$re/FOOD /; print "$str\n"; __output__ FOOD bar baz

HTH

broquaint

Replies are listed 'Best First'.
Re: Re: Compiling regular expressions to perform substitution
by Stegalex (Chaplain) on Apr 11, 2002 at 13:20 UTC
    Well pluck my feathers and fry me in a vat! You're right. Thanks! I like chicken.