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

Re: hash assignment wierdness

by Obidan (Initiate)
on Apr 20, 2007 at 18:06 UTC ( [id://611214]=note: print w/replies, xml ) Need Help??


in reply to hash assignment wierdness

The issue is that undef nulls out it's arguments and then returns a scalar value. when you assign something undef, it is not really the *absence* of a value, it is a reserved scalar that perl uses to indicate absence of genuine data.

Digging into hash_file.c would most likely reveal that the hash operators make no special case for undef, and treats it as it would any other scalar value in assignmets. So as far as perl is concerned, when you assign undef to a hash, you're asking it for a hash containing the undef value.

As far as I am aware, the only way to null out a hash is to use it as an argument to undef, as in your example code.

Obidan :wq

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found