use strict ; use warnings ; my @files = qw( data1.txt data2.txt data3.txt ) ; foreach ( @files ) { open( my $fh, "<", $_ ) or die "Can't open < $_: $!" ; while(<$fh>) { chomp; print $_ . "\n" ; } close( $fh ) ; }