$line = s/\s+//; #get rid of the leading spaces my @f=split(/[\s\t]+/,$line); my $user=$f[0]; # if our hash does not contain an entry for our user $counter{$user} = [] if ( ! defined($counter{$user}) ) ; $counter{$user}->{$product}++;