#Open the file and slurp it into an array @lines #Search orig_name in line and replace it with new_name map{s/$orig_name/$new_name/g} @lines; #Write the transformed array into file again