in reply to Counting incidents of names in a file

Here is a solution that doesn't create any temp values and it keeps all your information in order in an array. A hash is in my opinion the easier way to count the occurances.
use Data::Dumper; my @all; my %occurance; while (<DATA>) { chomp; push @all, [ split(/\|/,$_) ]; $occurance{$all[-1][0]}++; } print Dumper(\@all); print Dumper(\%occurance); __DATA__ name_x|score|date name_y|score|date name_y|score|date name_z|score|date name_z|score|date


I included the Data::Dumper part for monks that haven't used it yet so they can see how it can be used to confirm content without doing a foreach or similar operation to see content of a hash or array.