Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Answer: How do I make a hash of hashes?

by chromatic (Archbishop)
on Apr 01, 2000 at 01:13 UTC ( #6618=categorized answer: print w/replies, xml ) Need Help??

Q&A > Data Structures > How do I make a hash of hashes? - Answer contributed by chromatic

You can also add a hash by doing something like this:
$hash{toes} = { biggest => 'hairy troll', smallest => 'toddler', };
(Note that the {} make a reference to an anonymous hash. See perlman:perldsc for more gritty details.)

Log In?

What's my password?
Create A New User
choroba's discovered two instances of a weird animal in the code at work: \@$var
[Eily]: hum, tied scalar, generates a new array when derefed ? :D
[Corion]: choroba: Ah, when doing a shallow copy, I prefer [ @$var ] - I think \@$var might return the same reference instead of a reference to a fresh copy
[Corion]: perl -wle "my $ar = [1,2,3]; my $br=\@$ar; print qq($ar / $br)" confirms this to me
[karlgoethebier]: "discovered" this to sum an array: perl -E 'say scalar map {1 .. $_} (1..3);'
[Corion]: karlgoethebier: Hahaha :)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2017-09-26 08:47 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.