in reply to Re^3: alphabet counting
in thread alphabet counting
Hmm...
my %h = ( a => 1, b => 2, c => 3 ); print "$k => $h{$k}\n" for my $k (sort keys %h);
Output:
syntax error at D:\progs\perl\junk.pl line 5, near "$k (" Execution of D:\progs\perl\junk.pl aborted due to compilation errors.
Maybe you meant something like:
print "$_ => $h{$_}\n" for sort keys %h;Or the (no doubt) more newbie-friendly:
for my $k ( sort keys %h ) { print "$k => $h{$k}\n"; };
In Section
Seekers of Perl Wisdom