Hello,
and it prints:
a 1
a 2
a 3
a 4
b 1
b 2
b 3
c 1
c 2
d 1
What I really need is:
a = 4
b = 3
c = 2
d = 1
>
How would I do this? Any ideas?
You're printing each time its incremented, just print the keys and their
value out *after* the for loop, also see:
perldoc -f map
# perl -mstrict -wle 'use Data::Dumper;my %letter_count;map {
$letter_count{$_}++ } qw(a a a a b b b c c d);print Dumper \%letter_count;'
$VAR1 = {
'c' => 2,
'a' => 4,
'b' => 3,
'd' => 1
};
#
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>