I'd be tempted to use a hash of hash of hashes, storing it like this: $hash{$city}{$station}{add1}=$address1 $hash{$city}{$station}{add2}=$address2 $hash{$city}{$station}{state}=$state $hash{$city}{$station}{zip}=$zip $hash{$city}{$station}{phone}=$phone
So my loop would look like this: foreach my $city (sort keys %hash) { print 'There are ', scalar (keys %{$hash{$city}}), " station(s) in $city. They are:\n"; foreach my $station (sort keys %{$hash{$city}}) { print " $station\n"; print " $hash{$city}{$station}{add1}\n"; print " $hash{$city}{$station}{add2}\n"; # etc. etc. } } but here's how I did it, because you asked for arrays... $line='station1,stat1add1,stat1add2,city1,ST,01234,555-1212'; ($station, $add1, $add2, $city, $state, $zip, $phone)=split(/,/, $line); push @{$hash{$city}{$station}}, $add1; push @{$hash{$city}{$station}}, $add2; push @{$hash{$city}{$station}}, $state; push @{$hash{$city}{$station}}, $zip; push @{$hash{$city}{$station}}, $phone; foreach my $city (sort keys %hash) { print 'There are ', scalar (keys %{$hash{$city}}), " station(s) in $city. They are:\n"; foreach my $station (sort keys %{$hash{$city}}) { print " $station\n"; # using arrays here, might as well loop foreach (@{$hash{$city}{$station}}) { print " $_\n"; } } } On Fri, 24 Jan 2003, Glenn Tremblay wrote: > This is what I need to do: > I believe I need a hash of hashes of arrays... > I am creating output in the format of inspection pages which list all > inspection stations in each town (some towns have only one, others have > several). > I need to group the lines (of address information) by city and get a count > of the number of stations in a given city. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]