$ cat t.pl #!/usr/bin/perl use strict; use warnings; use autodie; open my $FH, '>', 'TEST.x'; print $FH <>', 'TEST.x'; while (<$FH>) { chomp; print "$.: $_\n"; } print $FH "foobar\n"; close $FH; $ perl t.pl $ cat TEST.x now is the time for all good men to come to the aid of their party. foobar