Samn has asked for the wisdom of the Perl Monks concerning the following question:

Replies are listed 'Best First'.
Re: Storing Arrays in Hashes
by chorny (Scribe) on Sep 25, 2006 at 12:42 UTC
    Your question is hard to understand. Try
    $zipcode{$zip}=[]; push @{$zipcode{$zip}},['First Name1','email1','etc'];
    or
    $zipcode{$zip}=[ ['First Name1','email1','etc'], ['First Name2','email2','etc'], ];
    In general read perlreftut.pod, perllol.pod
    574726
    by Samn (Monk) on Sep 25, 2006 at 12:45 UTC
          To avoid such confusion in future, please mark your post as having been udated. For example:

          Update: I changed x,y and z.

          Thanks

          Martin
    Re: Storing Arrays in Hashes
    by wulvrine (Friar) on Sep 25, 2006 at 15:43 UTC
      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 =+;' *|