Acme-CPANModules-HashUtilities
view release on metacpan or search on metacpan
"IPC::Open3" : "0",
"Test::More" : "0"
}
},
"x_lists" : {
"x_lists" : {
"Data::ModeMerge" : "0",
"Hash::Merge" : "0",
"Hash::MoreUtil" : "0",
"Hash::MoreUtils" : "0",
"Hash::Subset" : "0",
"Hash::Union" : "0",
"Hash::Util" : "0",
"Hash::Util::Pick" : "0",
"Hash::WithDefault" : "0"
}
},
"x_mentions" : {
"x_mentions" : {
"Data::ModeMerge" : "0",
"Hash::Merge" : "0",
"Hash::MoreUtil" : "0",
"Hash::MoreUtils" : "0",
"Hash::Subset" : "0",
"Hash::Union" : "0",
"Hash::Util" : "0",
"Hash::Util::Pick" : "0",
"Hash::WithDefault" : "0"
}
}
},
"provides" : {
"Acme::CPANModules::HashUtilities" : {
"file" : "lib/Acme/CPANModules/HashUtilities.pm",
":PerlExecFiles"
],
"skips" : [],
"switch" : []
}
},
"name" : "@Author::PERLANCAR/Test::Compile",
"version" : "2.058"
},
{
"class" : "Dist::Zilla::Plugin::Test::Perl::Critic::Subset",
"config" : {
"Dist::Zilla::Plugin::Test::Perl::Critic::Subset" : {
"finder" : [
":ExecFiles",
":InstallModules",
":TestFiles"
]
}
},
"name" : "@Author::PERLANCAR/Test::Perl::Critic::Subset",
"version" : "3.001.006"
},
{
"class" : "Dist::Zilla::Plugin::Test::Rinci",
"name" : "@Author::PERLANCAR/Test::Rinci",
"version" : "0.040"
},
{
"class" : "Dist::Zilla::Plugin::StaticInstall",
"config" : {
- ':InstallModules'
needs_display: 0
phase: test
script_finder:
- ':PerlExecFiles'
skips: []
switch: []
name: '@Author::PERLANCAR/Test::Compile'
version: '2.058'
-
class: Dist::Zilla::Plugin::Test::Perl::Critic::Subset
config:
Dist::Zilla::Plugin::Test::Perl::Critic::Subset:
finder:
- ':ExecFiles'
- ':InstallModules'
- ':TestFiles'
name: '@Author::PERLANCAR/Test::Perl::Critic::Subset'
version: 3.001.006
-
class: Dist::Zilla::Plugin::Test::Rinci
name: '@Author::PERLANCAR/Test::Rinci'
version: '0.040'
-
class: Dist::Zilla::Plugin::StaticInstall
config:
Dist::Zilla::Plugin::StaticInstall:
dry_run: 0
Acme::CPANModules::HashUtilities (from Perl distribution
Acme-CPANModules-HashUtilities), released on 2023-10-29.
DESCRIPTION
Most of the time, you don't need modules to manipulate hashes; Perl's
built-in facilities suffice. The modules below, however, are sometimes
convenient. This list is organized by task.
Creating an alias to another variable
Hash::Util's "hv_store" allows you to store an alias to a variable in a
hash instead of copying the value. This means, if you set a hash value,
it will instead set the value of the aliased variable instead. Copying
from Hash::Util's documentation:
my $sv = 0;
hv_store(%hash,$key,$sv) or die "Failed to alias!";
$hash{$key} = 1;
print $sv; # prints 1
Getting internal information
Aside from creating restricted hash, Hash::Util also provides routines
to get information about hash internals, e.g. hash_seed(), hash_value(),
Data::ModeMerge
Hash::Union
Providing default value for non-existing keys
Hash::WithDefault
Restricting keys
Perl through Hash::Util (a core module) allows you to restrict what keys
can be set in a hash. This can be used to protect against typos and for
simple validation. (For more complex validation, e.g. allowing patterns
of valid keys and/or rejecting patterns of invalid keys, you can use the
tie mechanism.)
Reversing (inverting)
Reversing a hash (where keys become values and values become keys) can
be done using the builtin's "reverse" (which actually just reverse a
list):
%hash = (a=>1, b=>2);
Since the new keys can contain duplicates, this can "destroy" some old
keys:
%hash = (a=>1, b=>1);
%reverse = reverse %hash; # => sometimes (1=>"b"), sometimes (1=>"a")
Hash::MoreUtil's "safe_reverse" allows you to specify a coderef that can
decide whether to ignore overwriting, croak, or whatever else.
Slicing (creating subset)
Hash::MoreUtils's "slice_*" functions.
Hash::Subset
Hash::Util::Pick
Tying
The tie mechanism, although relatively slow, allows you to create
various kinds of "magical" hash that does things whenever you get or set
keys.
ACME::CPANMODULES ENTRIES
Hash::Util
Author: RJBS <https://metacpan.org/author/RJBS>
Hash::Merge
Author: HERMES <https://metacpan.org/author/HERMES>
Data::ModeMerge
Author: PERLANCAR <https://metacpan.org/author/PERLANCAR>
Hash::Union
Author: LONERR <https://metacpan.org/author/LONERR>
Hash::WithDefault
Hash::MoreUtil
Hash::MoreUtils
Author: REHSACK <https://metacpan.org/author/REHSACK>
Hash::Subset
Author: PERLANCAR <https://metacpan.org/author/PERLANCAR>
Hash::Util::Pick
Author: PINE <https://metacpan.org/author/PINE>
FAQ
What is an Acme::CPANModules::* module?
An Acme::CPANModules::* module, like this module, contains just a list
of module names that share a common characteristics. It is a way to
categorize modules and document CPAN. See Acme::CPANModules for more
lib/Acme/CPANModules/HashUtilities.pm view on Meta::CPAN
summary => "List of modules that manipulate hashes",
description => <<'_',
Most of the time, you don't need modules to manipulate hashes; Perl's built-in
facilities suffice. The modules below, however, are sometimes convenient. This
list is organized by task.
## Creating an alias to another variable
<pm:Hash::Util>'s C<hv_store> allows you to store an alias to a variable in a
hash instead of copying the value. This means, if you set a hash value, it will
instead set the value of the aliased variable instead. Copying from Hash::Util's
documentation:
my $sv = 0;
hv_store(%hash,$key,$sv) or die "Failed to alias!";
$hash{$key} = 1;
print $sv; # prints 1
## Getting internal information
lib/Acme/CPANModules/HashUtilities.pm view on Meta::CPAN
## Providing default value for non-existing keys
<pm:Hash::WithDefault>
## Restricting keys
Perl through <pm:Hash::Util> (a core module) allows you to restrict what keys
can be set in a hash. This can be used to protect against typos and for simple
validation. (For more complex validation, e.g. allowing patterns of valid keys
and/or rejecting patterns of invalid keys, you can use the tie mechanism.)
## Reversing (inverting)
Reversing a hash (where keys become values and values become keys) can be done
using the builtin's `reverse` (which actually just reverse a list):
%hash = (a=>1, b=>2);
lib/Acme/CPANModules/HashUtilities.pm view on Meta::CPAN
Since the new keys can contain duplicates, this can "destroy" some old keys:
%hash = (a=>1, b=>1);
%reverse = reverse %hash; # => sometimes (1=>"b"), sometimes (1=>"a")
<pm:Hash::MoreUtil>'s `safe_reverse` allows you to specify a coderef that can
decide whether to ignore overwriting, croak, or whatever else.
## Slicing (creating subset)
<pm:Hash::MoreUtils>'s `slice_*` functions.
<pm:Hash::Subset>
<pm:Hash::Util::Pick>
## Tying
The tie mechanism, although relatively slow, allows you to create various kinds
of "magical" hash that does things whenever you get or set keys.
_
'x.app.cpanmodules.show_entries' => 0,
};
Acme::CPANModulesUtil::Misc::populate_entries_from_module_links_in_description;
1;
# ABSTRACT: List of modules that manipulate hashes
lib/Acme/CPANModules/HashUtilities.pm view on Meta::CPAN
=head1 DESCRIPTION
Most of the time, you don't need modules to manipulate hashes; Perl's built-in
facilities suffice. The modules below, however, are sometimes convenient. This
list is organized by task.
=head2 Creating an alias to another variable
L<Hash::Util>'s C<hv_store> allows you to store an alias to a variable in a
hash instead of copying the value. This means, if you set a hash value, it will
instead set the value of the aliased variable instead. Copying from Hash::Util's
documentation:
my $sv = 0;
hv_store(%hash,$key,$sv) or die "Failed to alias!";
$hash{$key} = 1;
print $sv; # prints 1
=head2 Getting internal information
Aside from creating restricted hash, L<Hash::Util> also provides routines to
lib/Acme/CPANModules/HashUtilities.pm view on Meta::CPAN
L<Hash::Union>
=head2 Providing default value for non-existing keys
L<Hash::WithDefault>
=head2 Restricting keys
Perl through L<Hash::Util> (a core module) allows you to restrict what keys
can be set in a hash. This can be used to protect against typos and for simple
validation. (For more complex validation, e.g. allowing patterns of valid keys
and/or rejecting patterns of invalid keys, you can use the tie mechanism.)
=head2 Reversing (inverting)
Reversing a hash (where keys become values and values become keys) can be done
using the builtin's C<reverse> (which actually just reverse a list):
%hash = (a=>1, b=>2);
%reverse = reverse %hash; # => (2=>"b", 1=>"a")
Since the new keys can contain duplicates, this can "destroy" some old keys:
%hash = (a=>1, b=>1);
%reverse = reverse %hash; # => sometimes (1=>"b"), sometimes (1=>"a")
L<Hash::MoreUtil>'s C<safe_reverse> allows you to specify a coderef that can
decide whether to ignore overwriting, croak, or whatever else.
=head2 Slicing (creating subset)
L<Hash::MoreUtils>'s C<slice_*> functions.
L<Hash::Subset>
L<Hash::Util::Pick>
=head2 Tying
The tie mechanism, although relatively slow, allows you to create various kinds
of "magical" hash that does things whenever you get or set keys.
=head1 ACME::CPANMODULES ENTRIES
=over
=item L<Hash::Util>
Author: L<RJBS|https://metacpan.org/author/RJBS>
=item L<Hash::Merge>
lib/Acme/CPANModules/HashUtilities.pm view on Meta::CPAN
Author: L<LONERR|https://metacpan.org/author/LONERR>
=item L<Hash::WithDefault>
=item L<Hash::MoreUtil>
=item L<Hash::MoreUtils>
Author: L<REHSACK|https://metacpan.org/author/REHSACK>
=item L<Hash::Subset>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Hash::Util::Pick>
Author: L<PINE|https://metacpan.org/author/PINE>
=back
=head1 FAQ
t/author-critic.t view on Meta::CPAN
unless ($ENV{AUTHOR_TESTING}) {
print qq{1..0 # SKIP these tests are for testing by the author\n};
exit
}
}
use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.006
use Test::Perl::Critic (-profile => "") x!! -e "";
my $filenames = ['lib/Acme/CPANModules/HashUtilities.pm'];
unless ($filenames && @$filenames) {
$filenames = -d "blib" ? ["blib"] : ["lib"];
}
all_critic_ok(@$filenames);
( run in 1.749 second using v1.01-cache-2.11-cpan-49f99fa48dc )