( though this next one not working is quite clearly and simply a bug in Perl
@hash{ 1..keys %hash } = delete @hash{ sort {$a<=>$b} keys %hash };
That was my thought until I realised that by the time the right-hand side of the assignment is evaluated, you've already deleted all the keys, so scalar keys %hash is zero. Whether you run the iterator from 0 as the OP asked or from 1 as your have it, it generates no keys and the values go in the bin.
In reply to Re^2: re-key a hash (not so clear)
by BrowserUk
in thread re-key a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |