William Lewis Brown wrote:
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.

You are asking a FAQ.

    perldoc -q "expand variables"

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
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