Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Answer: How would I replace the string 'Red1' with $Red1?

by chipmunk (Parson)
on Nov 28, 2000 at 03:19 UTC ( #43563=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How would I replace the string 'Red1' with $Red[1]? - Answer contributed by chipmunk

Actually, it is not necessary to use the /e modifier in the QandAEditors' substitution, because without /e the right-hand side of a substitution interpolates just like a double-quoted string.
$line =~ s/\$red(\d)/$red[$1]/g;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2016-12-03 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.