Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Question about ternary condition

by fmerges (Chaplain)
on Jun 28, 2005 at 10:13 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://470555]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-23 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found