Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

( #43563=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How would I replace the string 'Red1' with $Red[1]? 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;

Comment on Answer: How would I replace the string 'Red1' with $Red1?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-12-27 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls