Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Tomcat42
perl-Hash-SafeKeys
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Meta Configuration of Package perl-Hash-SafeKeys
<package name="perl-Hash-SafeKeys" project="devel:languages:perl"> <title>Get hash contents without resetting each iterator</title> <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: while (my($k,$v) = each %hash) { ... @k = sort safekeys %hash; # Can do @v = grep { /foo/ }, safevalues %hash; # No problem print join ' ', safecopy %hash; # Right away, sir }</description> <url>https://metacpan.org/release/Hash-SafeKeys</url> </package>
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor