in reply to Regex to find/replace in a file
You're on the right track. After this: $lines =~ s/foo/bar/gms;the substitution has been made, but it's still in memory. The next step is to write it to the file:
You said "other file", so I'm not sure if you want to overwrite the original file or not. If you do, just substitute its name instead of theother.txt above.open(FILE, ">theother.txt") or die "Can't open the other file: $!\n"; print FILE $lines; close FILE;
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex to find/replace in a file
by amarceluk (Beadle) on May 16, 2002 at 19:14 UTC |