in reply to Re: Useless unless
in thread Useless unless

doX() if ($cond) otherwise doY();

I think I may be the only person in the world that would (actively) prefer to see that as:

$cond and doX or doY;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^3: Useless unless
by tilly (Archbishop) on Aug 08, 2005 at 05:00 UTC
    What happens if doX returns a false value?
      I think BrowserUk's point was on functions that don't return a value. I was assuming that in my post o/w I need to use the ternerary operator to catch it. Well one might argue that it is not always required to trap the return value but I feel if the funcion returns something then it is worth something

      I still like the otherwise idea coz it makes the code more english like. Nothing more, nothing less. :) I cannot argue with BrowserUk on the equivalence of the code! :)They do the same thing!

        In Perl, all functions return a value unless normal processing is interrupted. The latter would include functions that die or exit.

      Obviously, if there was any chance of that it would have to be

      $cond and doX,1 or doY;

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.