in reply to Question about ternary condition
Prececedence:
is parsed as(exists $hash{$_} and $hash{$_} eq 'on') ? $result = 'OK' : $result = 'KO'
and if cond is true, gets reduced to( cond ? $result = 'OK' : $result) = '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($result = 'OK') = 'KO'
Dave.
|
---|
In Section
Seekers of Perl Wisdom