in reply to Re: style for returning errors from subroutines
in thread style for returning errors from subroutines
Well, I voted you up, for your entry adds some food for thought, but I disagree. Returning 0 on success and an error code in case of failure, that's what the shell works. In a a shell script, you mostly run commands for what they give you on the standard output, which you can pipe into other commands. The return value is merely a side effect, that can only cary a number, and that is perfect for error reporting. To this effect, the truth in Shell is the opposite as in Perl: 0 is true, while everything else is false.
If you want to do the same in Perl, you'd have to cram ! everywhere, which IMHO does not participate to the legibility of your code. And you deprive yourself of the ability of returning a wealth of data, scalars, lists, references from functions.
--bwana147
|
|---|