On 5/31/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote:
I have the following script that takes in an input file, output file and replaces the string in the input file with some other string and writes out the output file. I want to change the script to traverse through a directory of files ie instead of prompting for input and output files, the script should take as argument a directory path such as C:\temp\allFilesTobeReplaced\ and search for a string x and replace it with y for all files under that directory path and write out the same files perl C:\temp\allFilesTobeReplaced\
You might want to look at perldoc perlrun (the -p and -i switches, in particular). For example, you can run a search/replace on all files in a directory just using the perl command: perl -pi -e 's/original text/new text/g' *
If you wish to go deeper into the directory structure, a find command with this one-liner might be easier than a full-fledged Perl script. Hope this helps, Ricky -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>