-----Original Message----- From: senthil prabu [mailto:[EMAIL PROTECTED] Sent: Friday, April 02, 2004 12:55 AM To: Charles K. Clarkson; [EMAIL PROTECTED] Subject: RE: help in find and replacing a string in a number of files
Hi, I want to open all (.txt,.html,.js files) files in a particular directory and replace a text in all that files. What I done so far was a script to replace text in all files in the current directory. What I want was," When I run the script,it should ask for the path of a particular directory and also the types(all files of its type in that dir) of files to open. I wrote a script to change the directory to I specified through commandline.but again it lists only the files in current directory. Please help me in this issue, The code is print "Enter a path name: "; my $path=<STDIN>; chdir($path); my $file=''; my @files=<*.txt>; foreach $file (@files){ { inner loop for pattern matchinh }; With Thanks inadvance, Prabu. Senthil, Try this in inner loop : my @files = <*>; if ( ! -d $file && $file =~ /\.txt/ ) {do replacement} else { chdir($file) ; do recuresion that calls this function } Jay -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>