in reply to Return values from a key sorted hash
It's just like this:
#!/usr/bin/perl use strict; use warnings; my %tmp = ( a=>1, b=>2, c=>3 ); my @vals = @tmp{reverse sort keys %tmp}; print "@vals\n";
Which prints (on my system):
Roboticus@Roboticus-PC ~ $ perl t.pl 3 2 1
All the magic is in the single line:
my @vals = @tmp{reverse sort keys %tmp};
Basically, you're just returning the list of values from a hash slice:
...roboticus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Return values from a key sorted hash
by BrowserUk (Patriarch) on Sep 10, 2010 at 22:23 UTC | |
by roboticus (Chancellor) on Sep 10, 2010 at 23:56 UTC |