Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Different Type of Hashes

by JavaFan (Canon)
on May 07, 2012 at 18:29 UTC ( #969307=note: print w/ replies, xml ) Need Help??


in reply to Different Type of Hashes

Example 1 has on the RHS of the assignment a reference to a hash, where the hash has just two elements. It's assigned to a hash, which mean the reference is stringified and acts as a key, whose value will be undef.

Example 2 has an 8 element list on the RHS of the assignment. When turned into a hash, you end up with a 2 element hash, as the keys are repeated.

Example 3 has a 2 element list on the RHS of the assigment, each element a reference to a hash. The second reference will survive the assignment to a hash, but the first will be stringified as the key.

I don't know what you want; the closest I can think of is an array of hashes:

my @h = ({1 => "j", 2 => "b"}, {1 => "p", 2 => "b"});
Perhaps you want a two level hash, but none of the examples gives any clue as what the top level keys should be.


Comment on Re: Different Type of Hashes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2015-07-06 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls