Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Question about ternary condition

by fmerges (Chaplain)
on Jun 28, 2005 at 10:13 UTC ( #470555=note: print w/replies, xml ) Need Help??


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 ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://470555]
help
Chatterbox?
and monks are getting baked in the sun...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2018-06-25 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?