## #!C:\Perl\bin\perl.exe use strict; use File::Find; use File::Slurp; use Time::Local; print "\nRunning ... \n\n"; my $root = "C:/"; # use forward slash, you can use mapped drives. print "changing to $root\n"; chdir $root; my $no_switches=0; my $no_files=0; my @log = (); my $dir; # find (\&Wanted, "department", "managers", "mybranch", "mycity", "myinfo", "resources"); find (\&Wanted, "working"); #directories - comman delimited sub Wanted { print "*Processing: $root$File::Find::name \n"; if ($_ =~ /\.htm(l)?$/i) { open(xFILE, $_) or die "ERROR: couldn't open file"; my @file = ; foreach my $line (@file) { close (xFILE); if ($line =~ m/$_") or die "ERROR: Can't open $_"; chomp($line); if ($line =~ m/()/i) { my $newline = $1.$3; $line =~ s/$line/$newline/; print "Switched: $newline\n"; } print FILE "@file"; # @file array is entire file. close (FILE); print "file overwritten\n"; push @log,"$root$File::Find::name \n\n"; $no_switches++; } # end if } # end for loop $no_files++; } #end if matches filetype else { print "file type not processed\n\n"; } #add $_ if you want to see URL of file not processed. } # end sub