Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: print hash of hashes as lists

by perigeeV (Hermit)
on May 29, 2001 at 06:03 UTC ( [id://83818]=note: print w/replies, xml ) Need Help??


in reply to Re: print hash of hashes as lists
in thread print hash of hashes as lists

But that's doing the same thing. From perldsc

If you want to get at the thing a reference is referring to, then you have to do this yourself using either prefix typing indicators, like
${$blah}, @{$blah}, @{$blah[$i]} , or else postfix pointer arrows, like
$a->[3], $h->{fred}, <i>or even</i> $ob->method()->[3].

If you set the hash:
$evilhash->{1} = { ...
and deref:
@{$evilhash->{1}}{@colors})
Then that's the same as setting the hash:
$evilhash{$id} = { ...
and deref:
@{$evilhash{$id}}{@colors}

No?

Replies are listed 'Best First'.
Re: Re: Re: print hash of hashes as lists
by meonkeys (Chaplain) on May 31, 2001 at 03:50 UTC
    First, to clarify, the answer I posted for gdig321 was not intended to represent the only Way to do it (see TMTOWTDI). I'm just used to using the -> operator.

    The two examples you gave are slightly different. First:
    $evilhash->{1} = {}
    makes $evilhash a reference to an anonymous hash. The anonymous hash has one key, "1", with an empty hashref as the value corresponding with this key.
    $evilhash{1} = {}
    makes %evilhash, a true hash, which has one key, "1", with an empty hashref as the value corresponding with this key.

    Your two examples are correctly written and will produce the same result, I agree. Thanks for the clarification,

    -Adam

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found