in reply to Re: Best method to order a hash of arrays
in thread Best method to order a hash of arrays

You should be aware that your code, above, creates a hash with keys "37", "165", "22", "683", "1".
Unfortunately, if you want the leading zeroes, you'll need to explicitly quote the keys.

A word spoken in Mind will reach its own level, in the objective world, by its own weight
  • Comment on Re^2: Best method to order a hash of arrays

Replies are listed 'Best First'.
Re^3: Best method to order a hash of arrays
by kyle (Abbot) on May 16, 2007 at 02:43 UTC

    Actually, it's worse than that. The leading zero causes Perl to interpret it as an octal value, so 037 becomes '31'.

    use Data::Dumper; my %user_types =( 037 => [ 'member', '1' ], 165 => [ 'public', '2' ], 022 => [ 'staff', '3' ], 683 => [ 'babe', '4' ], 001 => [ 'old fart', '5' ] ); print Dumper( \%user_types ); __END__ $VAR1 = { '1' => [ 'old fart', '5' ], '18' => [ 'staff', '3' ], '165' => [ 'public', '2' ], '683' => [ 'babe', '4' ], '31' => [ 'member', '1' ] };