FILE: for my $file (@files) { open my $fh, ... or do { warn "skipping $file: $!"; next FILE }; ... close $fh; }