laziness, impatience, and hubris | |
PerlMonks |
Re: Find pieces of text in a file enclosed by `@` and replace the insideby bart (Canon) |
on Mar 08, 2013 at 11:44 UTC ( [id://1022397]=note: print w/replies, xml ) | Need Help?? |
Step one is that you replace text between '@' delimiters. You can do that using
Step two is to replace individual characters on the selected part. Using the /e modifier you can use perl code in the substitution part, where you can use $1 as a normal variable. With a pair of "{}" delimiters on the right hand side, it can even look like normal code, as it looks like a block; you have to use similar paired delimiters on the left to make it work, for example using angle brackets "<>": So you might try to do the replacement using code directly in the substitution part. But, to be safe, you'd better call a sub to do the actual replacement, on the selected text. I'd change your code like this:
Caveat: untested. update: Tested, and bug fixed, this line was wrong:
In Section
Seekers of Perl Wisdom
|
|