sub inplace{ my @files = @_; local ($^I, @ARGV) = (".bak", $file); # Now i can use <> while(<>){ # do stuff on $_ print; } }