http://www.perlmonks.org?node_id=626681


in reply to Counting the Times Two Unknown Values Appear Together

I think maybe you want this:

while (<FILE>){ my ($src,$sport) = (split /;/)[9,12]; $hash{$src}{$sport}++; }

Then you can say something like...

foreach my $src ( keys %hash ) { foreach my $sport ( keys %{$hash{$src}} ) { printf "%s appears with %s %d times\n", $src, $sport, $hash{$src}{$sport}; } }

Or just use something like Data::Dumper or YAML to spew out the whole structure.