use strict; use warnings; $^I = '.bak'; # create a backup copy while (<>) { s/HDR//g; # do the replacement print; # print to the modified file }