eval { for my $file (@files) { open FILE, $file or die 'Cannot open file'; ... } }; warn 'Could not process all files' if $@;