Hm. If the hash is of any size, that is a much slower and more memory hungry approach to solving the problem than simply using keys %job_categories; within the outer loop to reset the iterator:
$h{ $_ } = $_ for 0 .. 1e6;; cmpthese 1,{ a=>q[ while( ( $k, $v ) = each %h ){ my $x = "$k:$v"; } ], b=>q[ for my $k ( keys %h ){ my $x = "$k:$h{$k}"; } ], };; s/iter b a b 8.67 -- -83% a 1.52 472% --
In reply to Re^2: While loop and LAST
by BrowserUk
in thread While loop and LAST
by mcoblentz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |