use strict; use warnings; while (<DATA>) { s/a/x/g unless $. & 1; print; } __DATA__ Anyone know a way to apply a substitution in a file to every other line rather than the hole file?
Prints:
Anyone know a way to apply a substitution in x file to every other line rather thxn the hole file?
In reply to Re: Search and replace in all odd lines
by GrandFather
in thread Search and replace in all odd lines
by greatshots
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |