Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: What is the difference between |= and ||=?

by Anonymous Monk
on Apr 08, 2009 at 04:51 UTC ( [id://756225]=note: print w/replies, xml ) Need Help??


in reply to Re^3: What is the difference between |= and ||=?
in thread What is the difference between |= and ||=?

It's undef because the hash reference is a value returned from an SQL query. If no rows are selected (for instance), then it's possible for the 'id' value to be undef. And when I perform some math operation (as noted by Marshall below), the warning is triggered. I could wrap the math operation code around a conditional to suppress the warning:

if ($some_href->{id}) { if ($some_href->{id} > 0) { do_something(); } }
But I'm not sure if that's better than using ||=.

Replies are listed 'Best First'.
Re^5: What is the difference between |= and ||=?
by ikegami (Patriarch) on Apr 08, 2009 at 06:11 UTC
    If no row was selected, then whose id is that? Sure smells fishy.

      The "id" was an example. But there are cases (especially when JOINS are involved) where some columns have NULL values or where rows are not yet inserted. In those instances, the particular value of the hash reference is undef.

        The "id" was an example.

        Which brings us back to my answer: It all depends on the situation. In the situation you gave, it doesn't seem right.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found