I can't test this out here, but I think the e after the regex makes the
right side get evaluated as code, so maybe you need to put quotes around the
right-hand side of your regex:
$text=~s/$pattern/"$replacement"/e;
-----Original Message-----
From: Mike
To: [EMAIL PROTECTED]
Sent: 6/26/03 12:38 PM
Subject: HELP! Reg-ex question
Given the following code snippet:
---------------------------------
print "$text\n";
my $text="sour red apples";
my $pattern="(sour)";
my $replacement="very \$1";
$text=~s/$pattern/$replacement/;
print "$text\n";
---------------------------------
I was expecting "very sour red apples" to be printed, but instead I got
"very $1 red apples". I tried changing:
$text=~s/$pattern/$replacement/;
to
$text=~s/$pattern/$replacement/ee;
but that did not work either. How can I make it work, so that it was as
if
I had written:
$test=~s/$pattern/very $1/; # With the "very $1" being extracted from
the
#$replacement variable
Thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]