use warnings; use strict; use File::Replace 'replace'; my $lookuptxtfile = "lookup.txt"; my $fh = replace($lookuptxtfile); while (<$fh>) { s/The action failed./failed_build/g; print $fh $_; } close $fh;