in reply to Hash assignments using map
my @keys = qw{a b c d}; my %hash = map { $_ => 1 } @keys;
Your loop alternative could be written
my @keys = qw{a b c d}; my %hash; $hash{$_} ++ for @keys;
Another alternative is to use a hash slice
my @keys = qw{a b c d}; my %hash; @hash{@keys} = (1) x scalar @keys;
I hope this is of use.
Cheers,
JohnGG
|
|---|