If you change:
to:$lights{$light} ? $lights{$light} = 0 : $lights{$light} = 1;
it works ok.$lights{$light} = $lights{$light} ? 0 : 1;
From perlop:
If the argument before the ? is true, the argument before the : is returned, otherwise the argument after the : is returned.
update:
Added quote from the docs
In reply to Re: Ternary if versus normal if question
by wfsp
in thread Ternary if versus normal if question
by tphyahoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |