Yanet I wrote:
> I have been trying to replace a string:
> This-ismy-oldstring
> to 
> This-ismy-newstring
> 
> on a unix box 
> 
> underneath a directory, which contain files and subdirectories containing
> other files, which have my This-ismy-oldstring.  I need to make a global
> replacement substituting This-ismy-oldstring to This-ismy-newstring
> 
> I have managed to do it opening a single file, but I need to do it in
> multiple files.  What is a good approach to accomplish this task?  I was

Here is one way to do it:

#!/usr/bin/perl -w
use strict;
use File::Find;

{ local ( $^I, @ARGV ) = '.bak';
find( sub {
     return unless -f;  # only want -f type files
     push @ARGV, $File::Find::name;
     }, '/dir/to/use' );

while ( <> ) {
     s/This-ismy-oldstring/This-ismy-newstring/g;
     print;
     }
}

__END__


John
-- 
use Perl;
program
fulfillment


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to