foreach my $file (@files) { if (open my $fh => $file) { read in file do whatever you need to do } }