Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Tomcat42
perl-Hash-SafeKeys
perl-Hash-SafeKeys.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-Hash-SafeKeys.spec of Package perl-Hash-SafeKeys
# # spec file for package perl-Hash-SafeKeys # # Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # %define cpan_name Hash-SafeKeys Name: perl-Hash-SafeKeys Version: 0.04 Release: 0 License: Artistic-1.0 OR GPL-1.0-or-later Summary: Get hash contents without resetting each iterator URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/M/MO/MOB/%{cpan_name}-%{version}.tar.gz BuildRequires: perl BuildRequires: perl-macros %{perl_requires} %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 } %prep %autosetup -n %{cpan_name}-%{version} %build perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" %make_build %check make test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %doc Changes README %changelog
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