my %hash; %hash = map { chomp; $_ => '1' } split /(\s+|\W+)/, <>;
This should do what you want:
my %hash = map /(\w+)/ ? ( $1, 1 ) : (), <>;
In reply to Re: Having trouble loading a hash with map
by jwkrahn
in thread Having trouble loading a hash with map
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |