Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: hashes with multiple values per key

by saskaqueer (Friar)
on Jan 24, 2005 at 13:37 UTC ( [id://424578]=note: print w/replies, xml ) Need Help??


in reply to hashes with multiple values per key

The wording of your question is not too clear, so I'll do my best to guess at what you want. This answers part one of your question, assuming you want the data structure shown after the __END__ token:

my @hash_keys = qw(keyone keytwo keythree); my @hash_vals1 = qw(val1 val2 val3); my @hash_vals2 = qw(val4 val5 val6); my %the_hash; $the_hash{ $hash_keys[$_] } = [ $hash_vals1[$_], $hash_vals2[$_] ] for ( 0 .. $#hash_keys ); __END__ %the_hash = ( keyone => [ qw(val1 val4) ], keytwo => [ qw(val2 val5) ], keythree => [ qw(val3 val6) ] );

update: I'm not sure what you mean by question #2. What has to match for you to want the values?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-29 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found