foreach my $file (@lines) { open(my $fh, '<', $file) or die "$file: $!"; ... }