http://qs321.pair.com?node_id=470547


in reply to Question about ternary condition

Prececedence:
(exists $hash{$_} and $hash{$_} eq 'on') ? $result = 'OK' : $result = 'KO'
is parsed as
( cond ? $result = 'OK' : $result) = 'KO'
and if cond is true, gets reduced to
($result = 'OK') = 'KO'
so you assign OK, then KO, to $result. In any case, your first syntax is preferable, and the use of exists is unnecessary as the only keys you're testing are the the keys of the hash, so they must always exist

Dave.