Hi Bob,
I tried what you suggested and I keep getting a unitialized value error.
here is my code. If you could point me to how I could do what William is
trying to do.

Thanks
Radhika

$_= "goodbarrad";
#$foo =~ s/(.*)bar(.*)/$replacement/g;
my $foo =~ s/(.*)bar(.*)/eval $1/ge;
print "\$1 is: $1\n";
print "$foo\n";


--------------------------------------------------
> On Thu, 2004-09-30 at 10:58, Bob Showalter wrote:
>> William Lewis Brown wrote:
>> > Hi,
>> >         I have a need to store replacement text for a regex
>> > substitution in a variable.  In other words, I have code in a perl
>> > script like so::
>> >
>> > $foo =~ s/(.*)bar(.*)/$replacement/g;
>> >
>> > The $replacement string needs to contain a "reference" to $1.  In
>> > other words, the string $replacement will contain the string "$1".  I
>> > need to have the $1 string interpreted so that it will be replaced
>> > with the text of the first '(.*)' expression.  I have not yet found a
>> > way to get this to happen.  The "$1" string always seems to be
>> > interpreted as a plain string.
>>
>> You need to use eval and /e
>>
>>     $foo =~ s/(.*)bar(.*)/eval $replacement/ge;
>
> Hi,
>       That definitely did the trick.  I had tried "eval" and "/e" but never
> in conjunction.  Thanks for your time and your help.
>
>                               Bill
>
> --
> William L. Brown
> Email: [EMAIL PROTECTED]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


-- 
It's all a matter of perspective. You can choose your view by choosing
where to stand.
Larry Wall
---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to