in reply to Looping structure

Other monks have pointed our your source of error. I just want to say that you are doing a lot of unnecessary work. For example, the code
my $value = $list{$location}; $value++; $list{$location} = $value;
can be written as -
$list{$location}++;
And your entire code block can be simplified to just one line of Perl (assuming your $location is never '0') -
$list{ $location || 'Unknown' }++;