local $^I = '.bak'; local @ARGV = ("$dir/$header_file"); while (<>) { s/foo/bar/; # whatever you want print; }