in reply to [untitled node, ID 574723]
#!/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.
|
|---|