Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: array reference as hash value

by davorg (Chancellor)
on Jul 22, 2009 at 10:15 UTC ( #782238=note: print w/ replies, xml ) Need Help??

in reply to array refernce as hash value

It's possible, but it's not doing what you think it is (as use warnings will show you).

$ perl -Mwarnings -e '%h = { foo => [ 1 .. 3] }' Reference found where even-sized list expected at -e line 1.

You have the wrong kind of brackets. You want:

my %hash = ( key1 => [a1_ref,a1_ref], key2 => [a3_ref,a4_ref] );

Having created your data structure, Data::Dumper will be invaluable for exploring it and perldsc is full of information about how to get values out of it.


See the Copyright notice on my home node.

Perl training courses

Comment on Re: array reference as hash value
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-11-27 13:39 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 (729 votes), past polls