alpal has asked for the wisdom of the Perl Monks concerning the following question:
is used to search for, when it searches the line strings, it will assume we are using ROT THE MAN to search with, which is not the case, and ends up not actually finding what we need. I don't know if there is a different type of variable to use, or a different search to use or what, but I'm totally lost as to what to try next. Here's the code thus far...[ROT] THE MAN
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"; chomp $fileext; print "\nEnter exact name of player to find and replace:\n\n"; $playertofind = <STDIN>; print "\nConfirmed: $playertofind\n\n"; chomp $playertofind; print "\nEnter exact name of player to replace $playertofind with:\n\n +"; $newplayer = <STDIN>; print "\nConfirmed: $newplayer\n\n"; chomp $newplayer; @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; } print "\nFile $file has been corrected.\n"; close FILE; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple file editing problems2
by sauoq (Abbot) on Oct 23, 2002 at 22:22 UTC | |
|
Re: Simple file editing problems2
by Ovid (Cardinal) on Oct 23, 2002 at 22:40 UTC | |
|
Re: Simple file editing problems2
by rir (Vicar) on Oct 23, 2002 at 22:56 UTC |