in reply to Re^5: Error: Not enough space
in thread Error: Not enough space
Functions that set $! will always return a false value on failure, and a true value on success. Never, ever use $! to determine whether something succeeded or not - the specification of your system libraries allows a function to set errno to whatever it wants in case of success (all that $! does is give you the value of errno - whose value usually isn't under Perls control). Always use the return value of the function used to determine success, and only use $! immediately after determining failure. Typically this is done by interpolating $! in the message you give with die. In your example, both print and open can set $!. But if your code reaches the test for if ($!), the open has succeeded (because you'll die if it fails). Which means that at that moment, the value of $! is utterly meaningless. No information can be derived from it.
The manual page will tell you whether a function sets $!. Functions that set $! include (but aren't limited to): open, close, print, umask, chmod, unlink, rename, mkdir, rmdir, sysopen, sysread, syswrite, and fork.
|
|---|