in reply to Re: Ternary if versus normal if question
in thread Ternary if versus normal if question

Or, more succinctly, $lights[$light] ^= 1;.

Replies are listed 'Best First'.
Re^3: Ternary if versus normal if question
by Aristotle (Chancellor) on Nov 18, 2005 at 14:01 UTC

    Beware of strings vs numbers, though. The bitwise ops in Perl are hazardous if used imprudently.

    Makeshifts last the longest.

Re^3: Ternary if versus normal if question
by Moron (Curate) on Nov 18, 2005 at 13:48 UTC
    I looked for a solution with ^=, but it doesn't work unless it can be made into a unary operator at which point I gave up looking down that route. Your suggestion only turns the light on when off but does not turn it off when on.

    -M

    Free your mind

      $ perl -wle '$a=0; $a ^= 1; print $a' 1 $ perl -wle '$a=1; $a ^= 1; print $a' 0
        Hmm looks like you are right - I tested exactly this, with a slightly different script and got a 1 for both cases but the above test looks right and does suggest it works after all. If the problem is an inaccesible NFS mountpoint, how about dismounting it just from your local system during the installation?

        -M

        Free your mind