note
tybalt89
<p>
And here's the Path::Tiny version...
</p>
<code>
#!/usr/bin/perl
# https://perlmonks.org/?node_id=1222734
use strict;
use warnings;
use Path::Tiny;
my $lookuptxtfile = 'd.lookuptxtfile';
path($lookuptxtfile)->spew(<<END);
one
two
The action failed.
three
The action failed. twice The action failed.
four
END
print path($lookuptxtfile)->slurp;
print "\n";
# end setup for testing
# start actual code
path($lookuptxtfile)->edit( sub { s/The action failed./failed_build/g } );
# end actual code
print path($lookuptxtfile)->slurp; # debug print
</code>
1222734
1222734