perl -i.bak -pe ' BEGIN {chdir shift}; s/original regex/new/; ' /path/to/dir file1 file2 file3 file4 ...