[18:25][nick:~/monks]$ cat 1135741.pl
#! perl -w
use strict;
use feature qw/ say /;
use Path::Tiny qw/ path /;
my $file = 'test.dat';
my @lines = path( $file )->lines( { chomp => 1 } );
# do something with @lines ...
my @append = (); # empty array
path( $file )->append( @append, { truncate => 1 } );
say "Done.";
__END__
####
[18:25][nick:~/monks]$ cat test.dat
foo
bar
baz
quux
####
[18:26][nick:~/monks]$ perl 1135741.pl
Done.
####
[18:26][nick:~/monks]$ cat test.dat
[18:26][nick:~/monks]$