in reply to Re: Re: variable set to 0 ? 0 : 1
in thread variable set to 0 ? 0 : 1

How about...

return 0+($status!=0)

Decent golf score and I think that works just like the original. Can anyone think of a counterexample?

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Re: Re: variable set to 0 ? 0 : 1
by BrowserUk (Patriarch) on Sep 07, 2002 at 02:08 UTC

    Apart from the fact that it gives

    Argument "fred" isn't numeric in numeric ne (!=) line 1 0

    with -w, which admittedly the original did too.

    The result of ($status!=0) will always be either 0 or 1 won't it?

    In which case, the 0+ isn't doing anything? In fact neither then are the () nor the return?

    I get the distinct feeling I'm walking into the trap here, but I cannot see it.


    Well It's better than the Abottoire, but Yorkshire!
      The result of ($status!=0) will always be either 0 or 1 won't it?

      It will either be 1 or "" (the empty string.) All of the comparison operators work this way with the obvious exceptions of <=> and cmp. So do logical negation and most of the file test operators.

      I get the distinct feeling I'm walking into the trap here, but I cannot see it.

      Well, it wasn't really meant to be a trap but, yes, you walked into it. :-)

      -sauoq
      "My two cents aren't worth a dime.";