Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Error in Camel Book Ver2?

by redcloud (Parson)
on Dec 21, 2000 at 10:14 UTC ( #47741=note: print w/ replies, xml ) Need Help??


in reply to Error in Camel Book Ver2?

Well, look at that example line this way:

$pi ||= 3;

is like saying:

$pi = $pi || 3;

Now, the || operator short circuits if the first operand is true, so if $pi has any value that is true (i.e. it is not 0, "", or undef -- any others?) then the value of the right hand side will be $pi, otherwise it'll be 3. So, this is a way to say that the default value of $pi is 3, because that's what it'll be set to if it hasn't been set to something else already.

So, in your case, you might do:

$list_info{subscribed_message} ||= $subscribed_message;

Make sense?

Update:This doesn't work, though if "" is a valid value.


Comment on Re: Error in Camel Book Ver2?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2015-07-02 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls