use warnings; use strict; open my $fh, '<', 'file.txt' or die "can't open the damned file!: $!"; while (<$fh>){ chomp; if (! eof){ print "$_,\n"; } else { print "$_\n"; } } #### one two three #### one, two, three
## one two three ##
## one, two, three