in reply to Pattern Matching

you must evaluate by using the /e option for your regexp
$temp0="ZO"; $temp1='$1'; $x="ABCZO"; $x =~ s/([A-Za-z]+)$temp0/$temp1/ee; print $x; # should print ABC

hope this helps

MP

Replies are listed 'Best First'.
Re: Re: Pattern Matching
by Hofmator (Curate) on Aug 23, 2001 at 20:05 UTC

    Your suggestion works ... but the question was a bit more complicated because $temp = 'foo$1bar'. And then the simple evaluation doesn't work ... you have to employ a little extra trick (proposed by japhy a couple of days ago):

    $temp0="ZO"; $temp1='foo$1bar'; $x="ABCZO"; $x =~ s/([A-Za-z]+)$temp0/qq[qq[$temp1]]/ee; print $x; # prints fooABCbar

    -- Hofmator