in reply to Re^3: Two simple code style advice questions
in thread Two simple code style advice questions
It would seem to me that most Unix commands return 0 when things are "OK." So.. if you want to accuse me of showing my C programming roots, I plead guily.
I understand the derivation, but still, the bland token OK has always suggested TRUE to me, and always will.
Hence my suggested alternative of use constant NOERROR => 0; which seems less likely to cause confusion.
That said, I wouldn't define a constant for 0 at all. It simply isn't necessary to compare against zero in Perl. The clearest idiom is simply:
my $errstr = $case ? $msg[ $case ] : '';
But I'd still prefer setting $msg[ 0 ] == ''; and simply:
my $errstr = $msg[ $case ];
|
|---|