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

Re: hash assignment wierdness

by DigitalKitty (Parson)
on Apr 20, 2007 at 16:00 UTC ( #611194=note: print w/ replies, xml ) Need Help??

in reply to hash assignment wierdness

Hi Bro. Doug.

As mentioned in the chatterbox by andye++, the Data::Dumper module, while not perfect, is a useful tool.

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %hash = undef; print Dumper \%hash; #Output $VAR1 = { '' => undef };

Update: bart++ for suggesting a reference to %hash.

Hope this helps,

Comment on Re: hash assignment wierdness
Download Code
Replies are listed 'Best First'.
Re^2: hash assignment wierdness
by shmem (Canon) on Apr 21, 2007 at 12:33 UTC
    The output of Data::Dumper is misleading here, as it looks like undef was assigned to the value, not the key. But it's the key that gets the scalar:
    qwurx [shmem] ~ > perl -le '%h = "one"; print "$_ => $h{$_}" for keys +%h' one =>


    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-11-26 14:05 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (701 votes), past polls