perlquestion
njcodewarrior
<p>
Why does:
</p>
<code>
my @keys = qw{ a b c d };
my %hash = map { $_++ } @keys;
</code>
<p>
Produce the following warning:
</p>
<code>
Odd number of elements in hash assignemnt.
</code>
<p>
while the following does not:
</p>
<code>
my %hash;
foreach ( @keys ) {
$hash{$_}++;
}
</code>
<p>
I thought the map method was just a short hand way of using a loop?
<br /><br />
Thanks in advance - <i>njcodewarrior</i>
</p>