toddler has asked for the wisdom of the Perl Monks concerning the following question:
This works well to dump the output to the screen, but it doesn't replace the string in the file.open(FH, "file.html"); while(<FH>) { chomp; my $string = "$_"; my $find = "here.company.com/pagedir"; my $replace = "there.company.com/"; $find = quotemeta $find; $string =~ s/$find/$replace/g; print $string; } close(FH);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read from a file and replace
by runrig (Abbot) on Aug 17, 2001 at 23:10 UTC | |
|
Re: Read from a file and replace
by bjelli (Pilgrim) on Aug 18, 2001 at 00:18 UTC | |
|
Re: Read from a file and replace
by chiller (Scribe) on Aug 17, 2001 at 23:14 UTC | |
|
Re: Read from a file and replace
by Sifmole (Chaplain) on Aug 17, 2001 at 23:18 UTC | |
|
Re: Read from a file and replace
by Rudif (Hermit) on Aug 18, 2001 at 03:12 UTC | |
|
Re: Read from a file and replace
by toddler (Initiate) on Aug 17, 2001 at 23:38 UTC |