There's more than one way to do things | |
PerlMonks |
Substituting with match containing newline and space charactersby MorayJ (Beadle) |
on Mar 30, 2015 at 12:19 UTC ( [id://1121812]=perlquestion: print w/replies, xml ) | Need Help?? |
MorayJ has asked for the wisdom of the Perl Monks concerning the following question: Hi, I'm trying to do a substitution in a file I am trying to match:
I then want to switch it out so it says
I am trying the following code:
But, although the match works when I print it out ($1 prints the line I want to match), it doesn't work when I use it in the substitution. Even if I replace the substitution with a literal switch like
I think this is because the match($1) has a newline and some spaces in it If that's the case, how do I tell it to use exactly what's in the match in the substitution (and why doesn't it do that anyway)? Or have I probably made a mistake somewhere? Thanks for your help MorayJ
Back to
Seekers of Perl Wisdom
|
|