#! perl use strict; use warnings; my $filename = 'test.txt'; open(my $fh, '>', $filename) or die "Cannot open file '$filename' for writing: $!"; print $fh "The quick brown fox jumped over the unfortunate dog."; seek $fh, 0, 0; print $fh "The final output."; close($fh) or die "Cannot close file '$filename': $!"; #### The final output.ox jumped over the unfortunate dog.