unless (defined( $line = <> )) {
die $! if $!; # $! is only current and valid in the aftermath of a failure
last; # reached EOF
}
####
$line = <>;
if ($!) {
print "Ohh noo, $!"; # an indefinite false-positive
}
####
$ touch test; # create the dummy
$ perl -Mstrict -Wle 'undef $!; open my $fh, "<", "test" or warn "warn : $!"; print "after : $!"'
after : Inappropriate ioctl for device
$ rm test;
$perl -Mstrict -Wle 'undef $!; open my $fh, "<", "test" or warn "warn : $!"; print "after : $!"
warn : No such file or directory at -e line 1.
after : No such file or directory