foreach my $file (@filenames) { open FILE, "<$file"; while($line = ) { print "$line\n"; last; } close FILE; }