in reply to Idiom for looping thru key/value pairs
my @data = ( [ 'a', 2 ], [ 'b', 5 ], [ 'b', 2 ], [ 'c', 8 ] ); # Keep data sorted on keys. @data = sort { $a->[0] cmp $b->[0] } @data; # Get list of values in order @values = map { $_->[1] } @data; # Operate on values, in order { $_->[1] =* 2 } foreach ( @data );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Idiom for looping thru key/value pairs
by petdance (Parson) on May 26, 2001 at 01:09 UTC | |
by tye (Sage) on May 26, 2001 at 01:12 UTC |