open my $fh, "<", $file or warn "Couldn't open '$file': $!" and exit;
####
my $file = "does-not-exist";
while () {
eval {
open my $fh, "<", $file
or warn "Couldn't open '$file': $!" and exit;
};
print STDERR "ERROR: $@" if $@;
}
####
while () {
eval {
open my $fh, "<", $file
or CORE::die "Couldn't open '$file': $!";
};
print STDERR "ERROR: $@" if $@;
}
####
ERROR: Couldn't open 'does-not-exist': No such file or directory at ./680735.pl line 10, line 1.
ERROR: Couldn't open 'does-not-exist': No such file or directory at ./680735.pl line 10, line 2.
...