in reply to Checking for odd/even number

if ($var % 2 == 1) { # odd } else { # even }

Replies are listed 'Best First'.
(cLive ;-) Re: Checking for odd/even number
by cLive ;-) (Prior) on Jan 29, 2002 at 02:22 UTC
    Since for %2, possible results are 0 or 1, you can drop the equivalence as well:
    if ($var%2) { # odd } else { # even }

    cLive ;-)