#!/usr/bin/perl use strict; use warnings; use File::Slurp qw(read_file write_file); my $filename = 'in.txt'; my $data = read_file $filename, {binmode => ':utf8'}; $data =~ s/The action failed\./failed_build/g; write_file $filename, {binmode => ':utf8'}, $data; __END__ $ cat in.txt one two The action failed. three The action failed. twice The action failed. four $ cat in.txt one two failed_build three failed_build twice failed_build four #### #!/usr/bin/perl use strict; use warnings; use File::Slurper qw(read_text write_text); my $filename = 'in.txt'; my $data = read_text($filename); $data =~ s/The action failed\./failed_build/g; write_text($filename, $data); __END__ $ cat in.txt one two The action failed. three The action failed. twice The action failed. four $ cat in.txt one two failed_build three failed_build twice failed_build four #### #!/usr/bin/perl use strict; use warnings; use IO::All -utf8; # Turn on utf8 for all io my $contents = io->file('in.txt')->slurp; $contents =~ s/The action failed\./failed_build/g; $contents > io('in.txt'); __END__ $ cat in.txt one two The action failed. three The action failed. twice The action failed. four $ cat in.txt one two failed_build three failed_build twice failed_build four