in reply to accessing hash of arrays

$ perl -le' my %hash = ( 4 => [ 10, "mango" ], 2 => [ 04, "banana" ], 3 => [ 20, " +apple" ] ); for my $array ( values %hash ) { print $array->[ 0 ]; } ' 10 20 4

Replies are listed 'Best First'.
Re^2: accessing hash of arrays
by Anonymous Monk on Aug 21, 2009 at 07:39 UTC

    I understood. we can print that by loop. But I want to access like an array. I wanted to sort those numbers. For this I can store all these numbers and I can pass. But I want to pass all those numbers to sort without storing.

      my %hash = ( 4 => 10, "mango" , 2 => 04, "banana" , 3 => 20, "apple" );

      You use values to turn your hash into an array of array references. Then you use map to turn this array into an list of the numbers. Finally you use sort to sort that list.

      -- 
      Ronald Fischer <ynnor@mm.st>