[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1029228: ITP: libhash-safekeys-perl -- get hash contents without resetting each iterator



Package: wnpp
Owner: Mason James <mtj@kohaaloha.com>
Severity: wishlist
X-Debbugs-CC: debian-devel@lists.debian.org, debian-perl@lists.debian.org

* Package name    : libhash-safekeys-perl
  Version         : 0.04
  Upstream Author : Marty O'Brien <mob@cpan.org>
* URL             : https://metacpan.org/release/Hash-SafeKeys
* License         : Artistic or GPL-1+
  Programming Lang: Perl
  Description     : get hash contents without resetting each iterator

Every hash variable in Perl has its own internal iterator, accessed by the
builtin each, keys, and values functions. The iterator is also implicitly
used whenever the hash is evaluated in list context. The iterator is "reset"
whenever keys or values is called on a hash, including the implicit calls
when the hash is evaluated in list context. That makes it dangerous to do
certain hash operations inside a while ... each loop:

while (my($k,$v) = each %hash) {

@k = sort keys %hash; # Infinite loop!

@v = grep { /foo/ }, values %hash; # Ack!

print join ' ', %hash; # Run away!

}


The package will be maintained under the umbrella of the Debian Perl Group.

--
Generated with the help of dpt-gen-itp(1) from pkg-perl-tools.


Reply to: