Hello Rina
The following code uses File::Find and Tie::File. Note that Tie::File reads each line into an array so you can attempt a substitution. It also edits the file in place so that the original file will be changed to one with the substitutions. Be *careful* of this code as it will change your original files! Maybe set up a dummy directory with some dummy files to test it. I did to test this script! Note that this will change all files in the top directory, /some/dir_name, and goes through each sub_directory looking at all the files.
#!/usr/bin/perl
use strict;
use warnings;
use Tie::File;
use File::Find;
my @directories_to_search = ("/some/dir_name");
find(\&wanted, @directories_to_search);
sub wanted {
if (-f) {
tie my @array, 'Tie::File', $_ or die $!;
s/\$Log/\$History/gi for @array;
}
}
Hope this helps
Chris |