in reply to Better expression for $x = !!$y||0

See the Conditional Operator, to understand the above better.

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!

Replies are listed 'Best First'.
Re^2: Better expression for $x = !!$y||0
by borisz (Canon) on Apr 19, 2005 at 08:41 UTC
    Thanks all, sure I know about the conditional. It just look unnatural in a if statement to me. Thats why I used || in the first place. But since all answers are more or less the same. I shouldn't be so picky.
    Boris

      Since you don't like seeing the conditional operator in the if, why don't you move it to the outside?

      $x = $y ? 1 : 0; if ($x) { ... }

      It has the added advantage of removing an assignement from an if's condition, something I find quite unnatural and unreadable.