in reply to Use of grep and foreach
use strict; open(INFILE, "/path/to/file"); my @lines = map {s/oldthing/newthing/ if(m/myLine/);$_;} <INFILE>; close(INFILE); open(OUTFILE, ">/path/to/file"); print OUTFILE $_ foreach(@lines); close(OUTFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Use of grep and foreach
by monaLisa (Initiate) on Aug 11, 2003 at 13:34 UTC |