in reply to Printing to a specific place in a file
Here is a little inplace edit script to play with (backup with .bak suffix written):
cheers#!/usr/bin/perl -i.bak -w @ARGV = ('c:/test.txt'); # set our file to process while (<>) { print "newline\n" if m/somecond/; # add a new line is line matches +somecond s/this/that/; # substitute this for that on eve +ry line print; # write the modified (or not) lin +es }
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:{2} Printing to a specific place in a file
by jeroenes (Priest) on Oct 04, 2001 at 19:36 UTC |