One further note: this uses the package variables $a and $b to communicate the current key and value to the callback. Therefore, this code must be included (e.g. via "require") in each and every namespace where you want to use it.
No, not good enough. The package used is the package in which the source code was found.
Fix:
sub hasheesh(&\%) { my( $c, $h ) = @_; local( $a, $b ); { no strict 'refs'; *{caller().'::a'} = \$a; *{caller().'::b'} = \$b; } ...rest... }
In reply to Re^2: map-like hash iterator
by ikegami
in thread map-like hash iterator
by jdporter
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |