for my $infile ($foo, $bar) { last if open ($fh, '<', $infile); warn "Cannot open '$infile' for reading: $!"; } unless (eof $fh) { ... } else { warn "None of the files could be opened. What a shame."; }