#!/usr/bin/perl $dir = $ARGV[0] || '.'; $!=1; chdir($dir) or die $!; opendir(DIR,$dir) or die $!; my $changes=0; print "\n :: find :. "; $find=; chop($find); print " :: replace :. "; $replace=; chop($replace); $/=undef; foreach my $file (readdir(DIR)) { if($file=~/^.+\.pm$|^.+\.pl$/) # adjust pattern to your needs { print "parsing file $file..\n"; open(FILE,"<$file") or die $!; my $file_data=; close(FILE); $changes += $file_data =~ s/$find/$replace/gme; open(FILE,">$file") or die $!; print FILE $file_data; close(FILE); } } print "done. ($changes changes)\n";