in reply to hash to count occurences

Actual example:
foreach (split /\s/, <DATA>){ $hash{$_}++; } foreach $key (sort keys %hash){ print "$key $hash{$key}\n"; } __DATA__ SINE LINE LINE LINE SINE Alu Alu SINE
output will be
Alu 2 LINE 3 SINE 3
that __DATA__ thing at the end of the script
is kind of an emulation of a real file inside script - handy.
In the first line we take a single line from the <DATA>
and split it by spaces (\s) into $_ variable one by one.
Then we put into hash values which are sent by foreach and
increment them if they are exist and if not,
they are automatically created and incremented right after creation.
And the second foreach cycle print keys and values from the
newly created hash.