amarceluk has asked for the wisdom of the Perl Monks concerning the following question:
All very well and good. But how do I replace "foo" with "bar"? I tried this:{ open(FILE, "sample.txt") or die "Can't open sample.txt\n"; local $/ = undef; $lines = <FILE>; close(FILE); } if($lines =~ /foo/) { print "A match was found\n" }
but it doesn't do anything to the other file. Help! Thank you!$lines =~ s/foo/bar/gms;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex to find/replace in a file
by VSarkiss (Monsignor) on May 16, 2002 at 19:08 UTC | |
by amarceluk (Beadle) on May 16, 2002 at 19:14 UTC | |
|
Re: Regex to find/replace in a file
by yodabjorn (Monk) on May 16, 2002 at 21:01 UTC |