Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
the finding works fine, adn the replacing works fine *in memory*, but how do I replace the entire line (or just the string, same thing) in the original file? Many thanks, -Johnuse strict; open (FILE ,"c:/index.htm"); for my $line (<FILE>) { if ($line =~ /foo/) { $line =~ s/foo/bar/gms; print FILE "$line"; #obviously doesn't work print $line; } } close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find and replace
by JediWizard (Deacon) on Jun 21, 2005 at 15:05 UTC | |
|
Re: find and replace
by goober99 (Scribe) on Jun 21, 2005 at 15:09 UTC | |
by Anonymous Monk on Jun 21, 2005 at 15:26 UTC | |
|
Re: find and replace
by ambrus (Abbot) on Jun 21, 2005 at 15:17 UTC | |
|
Re: find and replace
by tlm (Prior) on Jun 21, 2005 at 15:53 UTC | |
|
Re: find and replace
by GrandFather (Saint) on Jun 21, 2005 at 20:43 UTC |