nysus has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that this throws errors like 'Argument "apwu749_d5" isn't numeric in sort at update_settings.pl line 87' because it's trying to sort the hash keyed with a string numerically. What's the best way to modify this subroutine so it works for all kinds of hashes?sub hash_sort { my ($hash) = @_; return [ (sort {$a <=> $b} keys %$hash) ]; }
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Data::Dumpers Sortkeys subroutine
by almut (Canon) on Nov 27, 2008 at 07:18 UTC | |
by nysus (Parson) on Nov 27, 2008 at 07:25 UTC | |
by nysus (Parson) on Nov 27, 2008 at 07:22 UTC | |
by Corion (Patriarch) on Nov 27, 2008 at 07:24 UTC | |
|
Re: Using Data::Dumpers Sortkeys subroutine
by nysus (Parson) on Nov 27, 2008 at 07:37 UTC | |
by almut (Canon) on Nov 27, 2008 at 08:01 UTC | |
by nysus (Parson) on Nov 27, 2008 at 17:22 UTC |