<?xml version="1.0" encoding="windows-1252"?>
<node id="20367" title="Answer: How would I replace the string 'Red1' with $Red[1]?" created="2000-06-29 13:50:08" updated="2005-08-13 05:06:30">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
Use an array (or a hash).  What you're trying to
do now smells like symbolic refrences, which 
are just yicky (to use the technical term )
and make your code harder to write and maintain.
&lt;p&gt;
You will also need to use the [s|/e] modifier (which
causes Perl to eval the right-side as an expression).
&lt;code&gt;
use strict;
my @red;
$red[1]='black';
$red[2]='red';
$line =~ s/\$red(\d)/$red[$1]/ge;                                           
&lt;/code&gt;</field>
<field name="parent_node">
20361</field>
</data>
</node>
