Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Is this code correct

by GrandFather (Saint)
on Mar 23, 2021 at 19:52 UTC ( [id://11130236]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Is this code correct
in thread Is this code correct

Try:

my $color = $form_inputs{color} // $user_color // $default_color;

Using || in this context is simply wrong. If the user chooses black (some would say a valid choice) the user's choice is overridden, possibly generating a warning along the way.

In this case warnings don't blatantly alert you to a key issue (|| instead of //), but they do give you a heads up to say that something needs attention. It is somewhat subtle, but the warning is telling you that the wrong operator is being used or inappropriate processing is taking place. Good warnings. Thank you warnings for helping me not shoot myself in the foot.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 11:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found