in reply to How do I rewrite this foreach() loop as a map{} ?

foreach (sort { $a <=> $b } keys %hash) { push @c, \@{$hash{$_}}; }

maybe something like:

@c = map { \@{ $hash{$_} } } (sort { $a <=> $b } keys %hash);

Note that this is untested and will replace @c with the result of the map. You could append to the @c array like so:

push @c, map { \@{ $hash{$_} } } (sort { $a <=> $b } keys %hash);

Jason L. Froebe

Team Sybase member

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Replies are listed 'Best First'.
Re^2: How do I rewrite this foreach() loop as a map{} ?
by northwind (Hermit) on May 10, 2005 at 16:04 UTC

    Thank you both.  I feel stupid now...