in reply to append middle of File
$ cat 2 1 2 3 4 $ perl -i.orig -p -l -e "print 'three' if /3/" 2 $ cat 2 1 2 three 3 4 $ cat 2.orig 1 2 3 4 $ perl -MO=Deparse -i.orig -p -l -e "print 'three' if /3/" BEGIN { $^I = ".orig"; } BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; print 'three' if /3/; } continue { print $_; } -e syntax OK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: append middle of File
by PyrexKidd (Monk) on Apr 10, 2010 at 19:01 UTC | |
by graff (Chancellor) on Apr 10, 2010 at 19:24 UTC |