perlvar says in the second paragraph about $!:
Many system or library calls set errno if they fail, to indicate the cause of failure. They usually do not set errno to zero if they succeed. This means errno , hence $! , is meaningful only immediately after a failure:
In reply to Re^2: Testing for readdir failure (Perl-bug)
by Corion
in thread Testing for readdir failure
by Bob Cook
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |