use File::Find; find(\&process, qw(C:/foo C:/bar)); sub process { return unless /\.(?:h|c|cpp)\z/ and -f $File::Find::name; open FH, "+<", $File::Find::name; s/$some_character// while ; close FH; }