in reply to Re: re-key a hash
in thread re-key a hash

Let the garbage collector do the deletes... I know, I know, it's not the problem spec!
my $count = 0; %hash = map { $count++ => $a{$_} } sort { $a <=> $b } keys %hash;

Replies are listed 'Best First'.
Re^3: re-key a hash
by Aristotle (Chancellor) on Aug 03, 2004 at 02:17 UTC

    There's no delete in mine either of course, and you still need two statements your way. :-) It's what I'd probably use in production code though.

    Makeshifts last the longest.