Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2018-02-25 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (312 votes). Check out past polls.

    Notices?