use warnings; use strict; use File::Replace 'replace3'; my $lookuptxtfile = "lookup.txt"; my ($infh,$outfh,$repl) = replace3($lookuptxtfile); while (<$infh>) { s/The action failed./failed_build/g; print $outfh $_; } $repl->finish;