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


in reply to Question about ternary condition

Hi,

Take a look at perlop, here you'll get explained the ternary operator and a indication for what is goind wrong here.

The code really says this:

( (exists $hash{$_} and $hash{$_} eq 'on') ? $result = 'OK' : $result +) = 'KO';

And the result of the ternary operator is an assignable value so that it gets to:

$result = 'KO'

With this, it works well

(exists $hash{$_} and $hash{$_} eq 'on') ? ($result = 'OK') : ($result = 'KO');

Regards,

:-)

Update:
Losed too much time to answer, so it was already answered... next time ;-)