I must be too ignorant to see why STDOUT should be closed
Closing STDOUT was a simple way to make print fail, nothing more. There are several other ways how print can fail. A simple one is running out of disk space while STDOUT is redirected to a file. But I was too lazy to show creating, formatting, mounting, and filling a loop device just to show that print may fail. A third one is a disappearing block device - unplugging the wrong USB stick or harddisk. Number four: a failing disk. Number five: Disk quotas. Number six: Network disconnected while writing to a remote filesystem.
in a one-liner (???)
I never limited my post to one-liners. print and exit is problematic in one-liners as well as in scripts and modules, because it does not always exit, but it may look like it does. And, as posted in Re^5: improve script, the proper way to terminate a script with an error message is to use die. It writes the error message to where it belongs: STDERR.
Alexander
In reply to Re^4: improve script
by afoken
in thread improve script
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |