in reply to Re: sorting hash keys
in thread sorting hash keys

Hi

Thanks for your code but I can't get it to work.

foreach my $key (sort keys { $a <=> $b } %results) { print MAIL "$key) $results{$key}\n"; }
Gives me the error Type of arg 1 to keys must be hash (not modulus (%)) at test.pl line 509, near "results) " Bareword "results" not allowed while "strict subs" in use at test.pl line 508. Execution of test.pl aborted due to compilation errors.

Replies are listed 'Best First'.
Re^3: sorting hash keys
by holli (Abbot) on May 28, 2005 at 19:47 UTC
    ah, sorry. I'm tired. That should of course be
    foreach my $key (sort { $a <=> $b } keys %results) { print "$key) $results{$key}\n"; }
    my bad.


    holli, /regexed monk/