{ local *ARGV; @ARGV = "yourfilenamehere"; local $/; local $^I = ".bak"; # or "" if you don't want the backup $_ = ; # truncate $_ as you wish: it's the entire file print; }