in reply to Re^3: Useless unless
in thread Useless unless

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!

Replies are listed 'Best First'.
Re^5: Useless unless
by tilly (Archbishop) on Aug 08, 2005 at 15:06 UTC
    In Perl, all functions return a value unless normal processing is interrupted. The latter would include functions that die or exit.
      Thanks for the correction tilly! I should have known better. Agreed all functions return a value unless called in a void context!!!

      When i started to play around with BrowserUk's statement on functions that return a value (with explicit return in my case) I realized i did not have that in mind when i wrote for the otherwise idea... So did not reply back saying it will fail under that instance coz i am not using the return value either in my code. What i forgot in the process was that subs implicitly return the last expression evaluated and the problem of returning false will execute both functions even if an explicit return in not used

      I guess after reading jdporter's post and your question about functions returning false values, I guess it makes me feel otherwise will be a good feature if one want to write such conditional statements

      I know it is too late in the game to think about such additions but it is nice to discuss!

      -SK