Package : perl-Hash-SafeKeys
Package details
Summary: Get hash contents without resetting each iterator
Description:
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!
}
'Hash::SafeKeys' provides alternate functions to access the keys, values,
or entire contents of a hash in a way that does not reset the iterator,
making them safe to use in such contexts:
URL: http://search.cpan.org/dist/Hash-SafeKeys
License: GPL+ or Artistic
Maintainer: nobody
Description:
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!
}
'Hash::SafeKeys' provides alternate functions to access the keys, values,
or entire contents of a hash in a way that does not reset the iterator,
making them safe to use in such contexts:
URL: http://search.cpan.org/dist/Hash-SafeKeys
License: GPL+ or Artistic
Maintainer: nobody
List of RPMs
- perl-Hash-SafeKeys-0.30.0-7.mga5.i586.rpm (Mageia 5, i586 media, core-release) Install