Q:

Perl - how to convert a string that contains a space-separated words into a hash

can someone help me how to convert a string that contains a space-separated words into a hash where the hash key is the word from the string and the hash value is the number of occurrences of the word from the hash? 
thanks

A:

Something like this? 
use strict;
use warnings;
use Data::Dumper;

my $string = "foo bar baz foo bar foo bar quux";
my %count;
$count{$_}++ for split /\s+/, $string;

print Dumper( \%count );

Output:
$VAR1 = {
          'bar' => 3,
          'baz' => 1,
          'quux' => 1,
          'foo' => 3
        };

