alpal has asked for the wisdom of the Perl Monks concerning the following question:
print "\nEnter extension of files to look in (example: log or tx +t):\n\n"; $fileext = <STDIN>; $fileext = lc($fileext); print "\nConfirmed: $fileext\n\n"; print "\nEnter exact name of player to find and replace:\n\n"; $playertofind = <STDIN>; print "\nConfirmed: $playertofind\n\n"; print "\nEnter exact name of player to replace $playertofind with:\n\n +"; $newplayer = <STDIN>; print "\nConfirmed: $newplayer\n\n"; @filestocheck = <*.$fileext>; foreach $file (@filestocheck) { open FILE, "$file" or die "\nError: Unable to open file for read. +.."; @lines = <FILE>; close FILE; open FILE, ">$file" or die "\nError: Unable to open file for writ +e..."; foreach $line (@lines) { $line =~ s/$playertofind/$newplayer/g; print FILE $line; } close FILE; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple file editing problems
by kabel (Chaplain) on Oct 23, 2002 at 20:35 UTC | |
|
Re: Simple file editing problems
by fglock (Vicar) on Oct 23, 2002 at 20:25 UTC | |
|
Re: Simple file editing problems
by Wonko the sane (Curate) on Oct 24, 2002 at 17:31 UTC |