in reply to Having trouble loading a hash with map

my %hash; %hash = map { chomp; $_ => '1' } split /(\s+|\W+)/, <>;

This should do what you want:

my %hash = map /(\w+)/ ? ( $1, 1 ) : (), <>;

Replies are listed 'Best First'.
Re^2: Having trouble loading a hash with map
by AnomalousMonk (Archbishop) on May 03, 2012 at 18:31 UTC
    This should do what you want:

    my %hash = map /(\w+)/ ? ( $1, 1 ) : (), <>;

    Maybe it should, but it doesn't: only maps first word from each line.