in reply to Ternary if versus normal if question

If you change:

$lights{$light} ? $lights{$light} = 0 : $lights{$light} = 1;
to:
$lights{$light} = $lights{$light} ? 0 : 1;
it works ok.

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