Instead of slurping the file into a scalar, read it to an array, and then do the substitutions one line at a time, printing as you go if you succeed at substituting on the line. I'm loath to attempt to code it since I should have been in bed quite a while ago, but in general if you want line-by-line action and control on a file, you shouldn't put it in a scalar.
In reply to Re: Comparing $_ --- before/after
by ssandv
in thread Comparing $_ --- before/after
by mrc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |