1Data::Perl::Role::ColleUcsteironC:o:nHtarsihb(u3t)ed PerDlatDao:c:uPmeernlt:a:tRioolne::Collection::Hash(3)
2
3
4

NAME

6       Data::Perl::Role::Collection::Hash - Wrapping class for Perl's built in
7       hash structure.
8

VERSION

10       version 0.002011
11

SYNOPSIS

13         use Data::Perl qw/hash/;
14
15         my $hash = hash(a => 1, b => 2);
16
17         $hash->values; # (1, 2)
18
19         $hash->set('foo', 'bar'); # (a => 1, b => 2, foo => 'bar')
20

DESCRIPTION

22       This class provides a wrapper and methods for interacting with a hash.
23       All methods that return a list do so via a
24       Data::Perl::Collection::Array object.
25

PROVIDED METHODS

27       new($key, $value, ...)
28           Given an optional list of keys/values, constructs a new
29           Data::Perl::Collection::Hash object initalized with keys/values and
30           returns it.
31
32       get($key, $key2, $key3...)
33           Returns a list of values in the hash for the given keys.
34
35           This method requires at least one argument.
36
37       set($key => $value, $key2 => $value2...)
38           Sets the elements in the hash to the given values. It returns the
39           new values set for each key, in the same order as the keys passed
40           to the method.
41
42           This method requires at least two arguments, and expects an even
43           number of arguments.
44
45       delete($key, $key2, $key3...)
46           Removes the elements with the given keys.
47
48           Returns a list of values in the hash for the deleted keys.
49
50       keys
51           Returns the list of keys in the hash.
52
53           This method does not accept any arguments.
54
55       exists($key)
56           Returns true if the given key is present in the hash.
57
58           This method requires a single argument.
59
60       defined($key)
61           Returns true if the value of a given key is defined.
62
63           This method requires a single argument.
64
65       values
66           Returns the list of values in the hash.
67
68           This method does not accept any arguments.
69
70       kv  Returns the key/value pairs in the hash as an array of array
71           references.
72
73             for my $pair ( $object->option_pairs ) {
74                 print "$pair->[0] = $pair->[1]\n";
75             }
76
77           This method does not accept any arguments.
78
79       elements/all
80           Returns the key/value pairs in the hash as a flattened list..
81
82           This method does not accept any arguments.
83
84       clear
85           Resets the hash to an empty value, like "%hash = ()".
86
87           This method does not accept any arguments.
88
89       count
90           Returns the number of elements in the hash. Also useful for not
91           empty: "has_options => 'count'".
92
93           This method does not accept any arguments.
94
95       is_empty
96           If the hash is populated, returns false. Otherwise, returns true.
97
98           This method does not accept any arguments.
99
100       accessor($key)
101       accessor($key, $value)
102           If passed one argument, returns the value of the specified key. If
103           passed two arguments, sets the value of the specified key.
104
105           When called as a setter, this method returns the value that was
106           set.
107
108       shallow_clone
109           This method returns a shallow clone of the hash reference.  The
110           return value is a reference to a new hash with the same keys and
111           values.  It is shallow because any values that were references in
112           the original will be the same references in the clone.
113
114       _array_class
115           The name of the class which returned lists are instances of; i.e.
116           "Data::Perl::Collection::Array".
117
118           Subclasses of this class can override this method.
119
120       Note that "each" is deliberately omitted, due to its stateful
121       interaction with the hash iterator. "keys" or "kv" are much safer.
122

SEE ALSO

124       •   Data::Perl
125
126       •   MooX::HandlesVia
127

AUTHOR

129       Matthew Phillips <mattp@cpan.org>
130
132       This software is copyright (c) 2020 by Matthew Phillips
133       <mattp@cpan.org>.
134
135       This is free software; you can redistribute it and/or modify it under
136       the same terms as the Perl 5 programming language system itself.
137
138
139
140perl v5.34.0                      2022-01-D2a1ta::Perl::Role::Collection::Hash(3)
Impressum