my @lines; foreach my $file(@files) { open(IN, "< $file") or die "Can't open $file: $!"; push @lines, ; close IN; } # Now do whatever you want with @lines #### while(my $line = ) { #Do whatever processing you want with $line }