in reply to sort in arbitrary order with subroutine, syntax error
If I understood well, you don't need to sort nothing, you can use the keys directly: a simple hash slice can do the job:
my %h = (one=>2,three=>4,five=>6,seven=>8,nine=>0); print "$_\n" for (@h{qw/five nine one seven three/})'
Outputs:
6 0 2 8 4
Or even easier:
my %h = (one=>2,three=>4,five=>6,seven=>8,nine=>0); print "$_ => $h{$_}\n" for (qw/five nine one seven three/);
Outputs:
five => 6 nine => 0 one => 2 seven => 8 three => 4
Is this what you are trying to do?
citromatik
|
|---|