Just another Perl shrine | |
PerlMonks |
Pass Matched Variable into Regex Replace Variableby deMize (Monk) |
on Dec 17, 2010 at 18:06 UTC ( [id://877671]=perlquestion: print w/replies, xml ) | Need Help?? |
deMize has asked for the wisdom of the Perl Monks concerning the following question:
Question: I'm curious how to interpolate a matched variable ($1) into the replacement variable of the regex.
I was able to accomplish it by creating an external function and passing $1 as a parameter to that function, but I figure there's an easier way. Also, I was not able to create and call the inline function in one step. Please no comments like, "why don't you $text=~s/From/To/"? As always, I appreciate the help. Demize Downvotes are welcome, just please comment as to why you are doing them. Thank you.
Back to
Seekers of Perl Wisdom
|
|