Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Storing Arrays in Hashes

by wulvrine (Friar)
on Sep 25, 2006 at 15:43 UTC ( [id://574760]=note: print w/replies, xml ) Need Help??


in reply to [untitled node, ID 574723]

I am not completely sure what you want, but I think you want a hash of arrays and how to create and or access them. Here is a little example of one way.
#!/usr/bin/perl use strict; use warnings; my %zipcodes; foreach my $row (2..10) { my $zip = "020" . $row; my $f = "f-$row"; my $l = "l-$row"; my $e = "e-$row"; #create a hash of arrays holding our values $zipcodes{$zip} = [$zip, $f, $l, $e]; } #cycle through the hash and print out all values foreach my $key (sort keys(%zipcodes)) { print "key = $key"; print " fn = " .$zipcodes{$key}->[1]; print " ln = " .$zipcodes{$key}->[2]; print " e = " .$zipcodes{$key}->[3] . "\n"; }

As you can see I tried to use most of your information.
I used the hash zipcodes and added an array to each zipcode ( $zipcodes{$zip} = $zip, $f, $l, $e; ).
In the second half of the program I cycle through the hash using the 'keys' keyword and access the individual members of the associated array when printing them out.
I hope this helps and is what you wanted.

s&&VALKYRIE &&& print $_^q|!4 =+;' *|

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-19 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found