Consider that
is equivalent toforeach ( sort keys %h ) { ... $h{$new} = $new;
The keys have been extracted from the hash before being sorted and processed. Any keys you add after that aren't "visible" to the foreach.@sorted = sort keys %h; foreach ( @sorted ) { ... $h{$new} = $new;
By the way, the "next;" is redundant.
In reply to Re: foreach loop question
by dws
in thread foreach loop question
by dda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |