in reply to Search and replace in all odd lines
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Search and replace in all odd lines
by jesuashok (Curate) on Jun 25, 2007 at 10:52 UTC | |
by johngg (Canon) on Jun 25, 2007 at 13:36 UTC | |
by clinton (Priest) on Jun 25, 2007 at 14:54 UTC | |
by johngg (Canon) on Jun 25, 2007 at 15:02 UTC |