/usr/share/perl5/Moose/Autobox/Hash.pm is in libmoose-autobox-perl 0.16-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | package Moose::Autobox::Hash;
# ABSTRACT: the Hash role
use Moose::Role 'with';
use List::MoreUtils 0.07 ();
use namespace::autoclean;
our $VERSION = '0.16';
with 'Moose::Autobox::Ref',
'Moose::Autobox::Indexed';
sub delete {
my ($hash, $key) = @_;
CORE::delete $hash->{$key};
}
sub merge {
my ($left, $right) = @_;
Carp::confess "You must pass a hashref as argument to merge"
unless ref $right eq 'HASH';
return { %$left, %$right };
}
sub hslice {
my ($hash, $keys) = @_;
return { map { $_ => $hash->{$_} } @$keys };
}
sub flatten {
return %{$_[0]}
}
# ::Indexed implementation
sub at {
my ($hash, $index) = @_;
$hash->{$index};
}
sub put {
my ($hash, $index, $value) = @_;
$hash->{$index} = $value;
}
sub exists {
my ($hash, $key) = @_;
CORE::exists $hash->{$key};
}
sub keys {
my ($hash) = @_;
[ CORE::keys %$hash ];
}
sub values {
my ($hash) = @_;
[ CORE::values %$hash ];
}
sub kv {
my ($hash) = @_;
[ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];
}
sub slice {
my ($hash, $keys) = @_;
return [ @{$hash}{@$keys} ];
}
sub each {
my ($hash, $sub) = @_;
for my $key (CORE::keys %$hash) {
$sub->($key, $hash->{$key});
}
}
sub each_key {
my ($hash, $sub) = @_;
$sub->($_) for CORE::keys %$hash;
}
sub each_value {
my ($hash, $sub) = @_;
$sub->($_) for CORE::values %$hash;
}
sub each_n_values {
my ($hash, $n, $sub) = @_;
my @keys = CORE::keys %$hash;
my $it = List::MoreUtils::natatime($n, @keys);
while (my @vals = $it->()) {
$sub->(@$hash{ @vals });
}
return;
}
# End Indexed
sub print { CORE::print %{$_[0]} }
sub say { CORE::print %{$_[0]}, "\n" }
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Moose::Autobox::Hash - the Hash role
=head1 VERSION
version 0.16
=head1 SYNOPSIS
use Moose::Autobox;
print { one => 1, two => 2 }->keys->join(', '); # prints 'one, two'
=head1 DESCRIPTION
This is a role to describes a Hash value.
=head1 METHODS
=over 4
=item C<delete>
=item C<merge>
Takes a hashref and returns a new hashref with right precedence
shallow merging.
=item C<hslice>
Slices a hash but returns the keys and values as a new hashref.
=item C<flatten>
=back
=head2 Indexed implementation
=over 4
=item C<at>
=item C<put>
=item C<exists>
=item C<keys>
=item C<values>
=item C<kv>
=item C<slice>
=item C<each>
=item C<each_key>
=item C<each_value>
=item C<each_n_values>
=back
=over 4
=item C<meta>
=item C<print>
=item C<say>
=back
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Moose-Autobox>
(or L<bug-Moose-Autobox@rt.cpan.org|mailto:bug-Moose-Autobox@rt.cpan.org>).
There is also a mailing list available for users of this distribution, at
L<http://lists.perl.org/list/moose.html>.
There is also an irc channel available for users of this distribution, at
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>.
=head1 AUTHOR
Stevan Little <stevan.little@iinteractive.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|