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.
>  

if you really just want to group by city, you don't need that nested 
structure. i am sure you really mean group by state and city right?

#!/usr/bin/perl -w
use strict;

my %hash;

push(@{$hash{(split(/,/))[3,4]}},$_) while(<DATA>);

for(keys %hash){
        print "$_ has ",scalar @{$hash{$_}}," stations and they are:\n";
        print join('',@{$hash{$_}});
}

__DATA__
Cat,1234 main, street,sf,ca,94124,123-4567
Dog,3456 main, street,sf,ca,94131,999-1234
Fish,9123 main, road,oa,wa,97541,431-4312
Bird,3456 main, street,sf,wa,94131,999-1234

prints:

ca has 2 stations and they are:
Cat,1234 main, street,sf,ca,94124,123-4567
Dog,3456 main, street,sf,ca,94131,999-1234
wa has 2 stations and they are:
Fish,9123 main, road,oa,wa,97541,431-4312
Bird,3456 main, street,sf,wa,94131,999-1234

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to