foreach my $file (@files) { open(my $fh, "<", $file; my @data = <$fh>; close($fh); }