Re: open a file for input

2004-11-24 Thread John W. Krahn
FlashMX wrote: Right...but my problem is I don't want the substitutions to happen on ALL the lines matched. Notice from the below input and output examples I do a grep to search for "0 AAA ". I then do a substitution on "0 AAA " to "0 AAA BBB ". Then the first occurence of "XXX" after the "0 AAA "

re: open a file for input

2004-11-24 Thread Chris Devers
On Wed, 24 Nov 2004, FlashMX wrote: > Right...but my problem is I don't want the substitutions to happen on > ALL the lines matched. Fine then. $line = sub_one( $line ) COND; Where COND is any condition you specify, e.g. $line = sub_one( $line ) if ( $line =~ /pattern one/ );

re: open a file for input

2004-11-24 Thread FlashMX
Right...but my problem is I don't want the substitutions to happen on ALL the lines matched. Notice from the below input and output examples I do a grep to search for "0 AAA ". I then do a substitution on "0 AAA " to "0 AAA BBB ". Then the first occurence of "XXX" after the "0 AAA " substitutio

re: open a file for input

2004-11-24 Thread Chris Devers
On Wed, 24 Nov 2004, FlashMX wrote: > I'm trying to understand the logic. When you open a file each line is > read in one at a time. At that point you can do whatever you want to > that line. In my case a search and replace. > > Can I do two search and replaces on the same line or would I have t

re: open a file for input

2004-11-24 Thread FlashMX
Hi, I'm trying to understand the logic. When you open a file each line is read in one at a time. At that point you can do whatever you want to that line. In my case a search and replace. Can I do two search and replaces on the same line or would I have to open the file again for a second pass?