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

Re: Re: undef'ing @arrays caveat

by particle (Vicar)
on Apr 20, 2002 at 02:22 UTC ( [id://160724]=note: print w/replies, xml ) Need Help??


in reply to Re: undef'ing @arrays caveat
in thread undef'ing @arrays caveat

i don't find that so strange weird. in each case, the assignment to hash assumed a second argument of undef. it's as if you assigned %hash=undef,undef;. perl just helps you do what you mean. as in the post above, list context is assumed due to the type of the lvalue of the assignment operation.

however, %hash=undef=>undef; may not do what you mean, if you don't know what you mean. here, the difference between , and => is plain.

# $VAR1 = { # 'undef' => undef # };

p.s. assignment is pretty much guaranteed to do just that--assign something. if you want to assign an empty hash, you'll have to assign one %hash = ()

~Particle ;Þ

Replies are listed 'Best First'.
Re: Re: Re: undef'ing @arrays caveat
by lestrrat (Deacon) on Apr 20, 2002 at 03:25 UTC

    Oh I see, the '' is the stringified undef. Yes, that I appreciate, but

    however, %hash=undef=>undef; may not do what you mean, if you don't know what you mean. here, the difference between , and => is plain.

    Boy, did I sound *that* clueless? I was just verifying the various somevariable = undef behavior before I post an answer, and just came upon one that seemed weird strange. ugh.

      i'm sorry, that bit wasn't meant for you. that was meant for all readers. i should have been more clear, perhaps by posting that bit to the original poster. sorry for any unintended offense :-)

      ~Particle ;Þ

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found