# take the values in @array and use them as keys in %hash, incrementing the values associated with said keys by one for (@array) { $hash{$_}++; }