in reply to How would I replace the string 'Red1' with $Red[1]?
You will also need to use the /e modifier (which causes Perl to eval the right-side as an expression).
use strict; my @red; $red[1]='black'; $red[2]='red'; $line =~ s/\$red(\d)/$red[$1]/ge;
|
|---|