| 1 | package Venus::Hash; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use 5.018; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use Venus::Class; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 16 | base 'Venus::Kind::Value'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 16 | with 'Venus::Role::Mappable'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # BUILDERS | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub build_args { | ||||||||||||||||||||||||||||
| 17 | 343 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
build_args: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 343 | ▶ | if (keys %$data == 1 && exists $data->{value}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
CORE::keys %$data == 1 and exists $data->{"value"}
MC/DC0%0/2
CORE::keys %$data == 1 and exists $data->{"value"}
CORE::keys %$data == 1
exists $data->{"value"}
Truth table66%2/3
A and B
A= CORE::keys %$data == 1B= exists $data->{"value"}
| |||||||||||||||||||||||||||||
| 20 | 0 | return $data; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | return { | ||||||||||||||||||||||||||||
| 23 | 343 | value => $data | |||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # METHODS | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | sub all { | ||||||||||||||||||||||||||||
| 30 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
all: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 2 | my $failed = 0; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 2 | for my $index (CORE::keys %$data) { | |||||||||||||||||||||||||||
| 39 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 42 | 8 | ▶ | $failed++ if !$code->($index, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 8 | ▶ | CORE::last if $failed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 2 | ▶ | return $failed ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub any { | ||||||||||||||||||||||||||||
| 51 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
any: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2 | my $found = 0; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | for my $index (CORE::keys %$data) { | |||||||||||||||||||||||||||
| 60 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 63 | 8 | ▶ | $found++ if $code->($index, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 8 | ▶ | CORE::last if $found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | return $found ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub count { | ||||||||||||||||||||||||||||
| 72 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | my $data = $self->get; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 3 | return scalar(CORE::keys(%$data)); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub default { | ||||||||||||||||||||||||||||
| 80 | 1 | ▶ | return {}; | ||||||||||||||||||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub delete { | ||||||||||||||||||||||||||||
| 84 | 1 | ▶ | my ($self, $key) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | return CORE::delete($data->{$key}); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub each { | ||||||||||||||||||||||||||||
| 92 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
each: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 2 | my $results = []; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 2 | for my $index (CORE::sort(CORE::keys(%$data))) { | |||||||||||||||||||||||||||
| 101 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 104 | 8 | CORE::push(@$results, $code->($index, $value)); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 2 | ▶ | return wantarray ? (@$results) : $results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | sub empty { | ||||||||||||||||||||||||||||
| 111 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 1 | CORE::delete(@$data{CORE::keys(%$data)}); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 1 | return $data; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub exists { | ||||||||||||||||||||||||||||
| 121 | 2 | ▶ | my ($self, $key) = @_; | ||||||||||||||||||||||||||
|
Subroutine
exists: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 2 | ▶ | return CORE::exists($data->{$key}) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | sub find { | ||||||||||||||||||||||||||||
| 129 | 47 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
find: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 47 | my $seen = 0; | |||||||||||||||||||||||||||
| 132 | 47 | my $item = my $data = $self->get; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 47 | ▶ | for (my $i = 0; $i < @args; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 70 | ▶ | if (ref($item) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 136 | 2 | ▶ | if ($args[$i] !~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | $item = undef; | |||||||||||||||||||||||||||
| 138 | 0 | $seen = 0; | |||||||||||||||||||||||||||
| 139 | 0 | CORE::last; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 2 | $seen = $args[$i] <= $#{$item}; | |||||||||||||||||||||||||||
| 142 | 2 | $item = $item->[$args[$i]]; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | elsif (ref($item) eq 'HASH') { | ||||||||||||||||||||||||||||
| 145 | 67 | $seen = exists $item->{$args[$i]}; | |||||||||||||||||||||||||||
| 146 | 67 | $item = $item->{$args[$i]}; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | else { | ||||||||||||||||||||||||||||
| 149 | 1 | $item = undef; | |||||||||||||||||||||||||||
| 150 | 1 | $seen = 0; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 47 | ▶ | return wantarray ? ($item, int(!!$seen)) : $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | sub get { | ||||||||||||||||||||||||||||
| 158 | 247 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 247 | ▶ | return $self->value if !int@args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 4 | my ($index) = @args; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 4 | return $self->value->{$index}; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | sub grep { | ||||||||||||||||||||||||||||
| 168 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
grep: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 2 | my $result = []; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 2 | for my $index (CORE::sort(CORE::keys(%$data))) { | |||||||||||||||||||||||||||
| 177 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 180 | 8 | ▶ | CORE::push(@$result, $index, $value) if $code->($index, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 2 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | sub iterator { | ||||||||||||||||||||||||||||
| 187 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
iterator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 190 | 2 | my @keys = CORE::sort(CORE::keys(%{$data})); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 2 | my $i = 0; | |||||||||||||||||||||||||||
| 193 | 2 | my $j = 0; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | return sub { | ||||||||||||||||||||||||||||
| 196 | 10 | ▶ | return undef if $i > $#keys; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 8 | ▶ | return wantarray ? ($keys[$j++], $data->{$keys[$i++]}) : $data->{$keys[$i++]}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 2 | } | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | sub keys { | ||||||||||||||||||||||||||||
| 202 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
keys: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 1 | return [CORE::sort(CORE::keys(%$data))]; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | sub length { | ||||||||||||||||||||||||||||
| 210 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 1 | return $self->count; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | sub list { | ||||||||||||||||||||||||||||
| 216 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
list: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 2 | ▶ | return wantarray ? (%{$self->value}) : scalar(CORE::keys(%{$self->value})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | sub map { | ||||||||||||||||||||||||||||
| 222 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
map: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 2 | my $result = []; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 2 | for my $index (CORE::sort(CORE::keys(%$data))) { | |||||||||||||||||||||||||||
| 231 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 234 | 8 | CORE::push(@$result, ($code->($index, $value))); | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 2 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | sub merge { | ||||||||||||||||||||||||||||
| 241 | 60 | ▶ | my ($self, $lvalue, @rvalue) = @_; | ||||||||||||||||||||||||||
|
Subroutine
merge: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 60 | ▶ | if (!$lvalue) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | return $self->get; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 60 | ▶ | if (!@rvalue) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 17 | @rvalue = ($lvalue); | |||||||||||||||||||||||||||
| 249 | 17 | $lvalue = $self->get; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 60 | ▶ | if (@rvalue > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | @rvalue = ($lvalue, @rvalue); | |||||||||||||||||||||||||||
| 254 | 0 | $lvalue = $self->get; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 60 | my $result = {%{$lvalue}}; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 60 | for my $rvalue (@rvalue) { | |||||||||||||||||||||||||||
| 260 | 60 | for my $index (CORE::keys(%$rvalue)) { | |||||||||||||||||||||||||||
| 261 | 116 | my $lprop = $$lvalue{$index}; | |||||||||||||||||||||||||||
| 262 | 116 | my $rprop = $$rvalue{$index}; | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 116 | ▶ | $result->{$index} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $rprop eq "HASH" and ref $lprop eq "HASH"
MC/DC100%2/2
ref $rprop eq "HASH" and ref $lprop eq "HASH"
ref $rprop eq "HASH"
ref $lprop eq "HASH"
Truth table100%3/3
A and B
A= ref $rprop eq "HASH"B= ref $lprop eq "HASH"
| |||||||||||||||||||||||||||||
| 265 | = ((ref($rprop) eq 'HASH') and (ref($lprop) eq 'HASH')) | ||||||||||||||||||||||||||||
| 266 | ? merge($self, $lprop, $rprop) | ||||||||||||||||||||||||||||
| 267 | : $rprop; | ||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 60 | ▶ | if (!$self->{merge}++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 23 | $result = merge($self, $self->get, $result); | |||||||||||||||||||||||||||
| 273 | 23 | CORE::delete($self->{merge}); | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 60 | return $result; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | sub none { | ||||||||||||||||||||||||||||
| 280 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
none: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 2 | my $found = 0; | |||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 2 | for my $index (CORE::sort(CORE::keys(%$data))) { | |||||||||||||||||||||||||||
| 289 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 292 | 8 | ▶ | $found++ if $code->($index, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 8 | ▶ | CORE::last if $found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 2 | ▶ | return $found ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | sub one { | ||||||||||||||||||||||||||||
| 301 | 2 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
one: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 2 | my $found = 0; | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 2 | for my $index (CORE::sort(CORE::keys(%$data))) { | |||||||||||||||||||||||||||
| 310 | 8 | my $value = $data->{$index}; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 8 | local $_ = $value; | |||||||||||||||||||||||||||
| 313 | 8 | ▶ | $found++ if $code->($index, $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 8 | ▶ | CORE::last if $found > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 2 | ▶ | return $found == 1 ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | sub pairs { | ||||||||||||||||||||||||||||
| 322 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pairs: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 1 | my $result = [CORE::map { [$_, $data->{$_}] } CORE::sort(CORE::keys(%$data))]; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 1 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | sub path { | ||||||||||||||||||||||||||||
| 332 | 43 | ▶ | my ($self, $path) = @_; | ||||||||||||||||||||||||||
|
Subroutine
path: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 43 | my @path = CORE::grep(/./, CORE::split(/\W/, $path)); | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 43 | ▶ | return wantarray ? ($self->find(@path)) : $self->find(@path); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | sub random { | ||||||||||||||||||||||||||||
| 340 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
random: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 343 | 1 | my $keys = [CORE::keys(%$data)]; | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 1 | return $data->{@$keys[rand($#{$keys}+1)]}; | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | sub reset { | ||||||||||||||||||||||||||||
| 349 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 1 | @$data{CORE::keys(%$data)} = (); | |||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 1 | return $data; | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | sub reverse { | ||||||||||||||||||||||||||||
| 359 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
reverse: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 1 | my $result = {}; | |||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 1 | for (CORE::grep(CORE::defined($data->{$_}), CORE::sort(CORE::keys(%$data)))) { | |||||||||||||||||||||||||||
| 366 | 4 | $result->{$_} = $data->{$_}; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 1 | return {CORE::reverse(%$result)}; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | sub set { | ||||||||||||||||||||||||||||
| 373 | 0 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 0 | ▶ | return $self->value if !int@args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 0 | my ($index, $value) = @args; | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | return $self->value->{$index} = $value; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | sub slice { | ||||||||||||||||||||||||||||
| 383 | 1 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
slice: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 1 | my $data = $self->get; | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 1 | return [@{$data}{@args}]; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 16 | 1; | |||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =head1 NAME | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | Venus::Hash - Hash Class | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =cut | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | =head1 ABSTRACT | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | Hash Class for Perl 5 | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | =cut | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | package main; | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | my $hash = Venus::Hash->new({1..8}); | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | # $hash->random; | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | =cut | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | This package provides methods for manipulating hash data. | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | =head1 INHERITS | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | This package inherits behaviors from: | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | L<Venus::Kind::Value> | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | =cut | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | =head1 INTEGRATES | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | This package integrates behaviors from: | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | L<Venus::Role::Mappable> | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =cut | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | =head1 METHODS | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | This package provides the following methods: | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | =head2 all | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | all(CodeRef $code) (Bool) | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | The all method returns true if the callback returns true for all of the | ||||||||||||||||||||||||||||
| 451 | elements. | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =over 4 | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =item all example 1 | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | # given: synopsis; | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | my $all = $hash->all(sub { | ||||||||||||||||||||||||||||
| 462 | $_ > 1 | ||||||||||||||||||||||||||||
| 463 | }); | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | # 1 | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | =back | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | =over 4 | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | =item all example 2 | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | # given: synopsis; | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | my $all = $hash->all(sub { | ||||||||||||||||||||||||||||
| 476 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | $value > 1 | ||||||||||||||||||||||||||||
| 479 | }); | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | # 1 | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =back | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =cut | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =head2 any | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | any(CodeRef $code) (Bool) | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | The any method returns true if the callback returns true for any of the | ||||||||||||||||||||||||||||
| 492 | elements. | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | =over 4 | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | =item any example 1 | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | # given: synopsis; | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | my $any = $hash->any(sub { | ||||||||||||||||||||||||||||
| 503 | $_ < 1 | ||||||||||||||||||||||||||||
| 504 | }); | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | # 0 | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | =back | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | =over 4 | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | =item any example 2 | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | # given: synopsis; | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | my $any = $hash->any(sub { | ||||||||||||||||||||||||||||
| 517 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | $value < 1 | ||||||||||||||||||||||||||||
| 520 | }); | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | # 0 | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | =back | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | =cut | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =head2 cast | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | cast(Str $kind) (Object | Undef) | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | The cast method converts L<"value"|Venus::Kind::Value> objects between | ||||||||||||||||||||||||||||
| 533 | different I<"value"> object types, based on the name of the type provided. This | ||||||||||||||||||||||||||||
| 534 | method will return C<undef> if the invocant is not a L<Venus::Kind::Value>. | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =over 4 | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | =item cast example 1 | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | package main; | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | my $cast = $hash->cast('array'); | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | # bless({ value => [{}] }, "Venus::Array") | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | =back | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =over 4 | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | =item cast example 2 | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | package main; | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | my $cast = $hash->cast('boolean'); | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | # bless({ value => 1 }, "Venus::Boolean") | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | =back | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | =over 4 | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | =item cast example 3 | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | package main; | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | my $cast = $hash->cast('code'); | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | # bless({ value => sub { ... } }, "Venus::Code") | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | =back | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | =over 4 | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | =item cast example 4 | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | package main; | ||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | my $cast = $hash->cast('float'); | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | # bless({ value => "1.0" }, "Venus::Float") | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | =back | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | =over 4 | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | =item cast example 5 | ||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | package main; | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | my $cast = $hash->cast('hash'); | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | # bless({ value => {} }, "Venus::Hash") | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | =back | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | =over 4 | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | =item cast example 6 | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | package main; | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | my $cast = $hash->cast('number'); | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | # bless({ value => 2 }, "Venus::Number") | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | =back | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =over 4 | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | =item cast example 7 | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | package main; | ||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | my $cast = $hash->cast('regexp'); | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | # bless({ value => qr/(?^u:\{\})/ }, "Venus::Regexp") | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | =back | ||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | =over 4 | ||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||
| 652 | =item cast example 8 | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | package main; | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | my $cast = $hash->cast('scalar'); | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | # bless({ value => \{} }, "Venus::Scalar") | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | =back | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | =over 4 | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | =item cast example 9 | ||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | package main; | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | my $cast = $hash->cast('string'); | ||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||
| 678 | # bless({ value => "{}" }, "Venus::String") | ||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||
| 680 | =back | ||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | =over 4 | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | =item cast example 10 | ||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||
| 686 | package main; | ||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | my $hash = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | my $cast = $hash->cast('undef'); | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | # bless({ value => undef }, "Venus::Undef") | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | =back | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | =cut | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | =head2 count | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | count() (Int) | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | The count method returns the total number of keys defined. | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | =over 4 | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | =item count example 1 | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | # given: synopsis; | ||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | my $count = $hash->count; | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | # 4 | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | =back | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | =cut | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | =head2 default | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | default() (HashRef) | ||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||
| 726 | The default method returns the default value, i.e. C<{}>. | ||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | =over 4 | ||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||
| 732 | =item default example 1 | ||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | # given: synopsis; | ||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||
| 736 | my $default = $hash->default; | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | # {} | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | =back | ||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||
| 742 | =cut | ||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | =head2 delete | ||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | delete(Str $key) (Any) | ||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||
| 748 | The delete method returns the value matching the key specified in the argument | ||||||||||||||||||||||||||||
| 749 | and returns the value. | ||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||
| 751 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | =over 4 | ||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | =item delete example 1 | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | # given: synopsis; | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | my $delete = $hash->delete(1); | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | # 2 | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | =back | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | =cut | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | =head2 each | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | each(CodeRef $code) (ArrayRef) | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | The each method executes callback for each element in the hash passing the | ||||||||||||||||||||||||||||
| 772 | routine the key and value at the current position in the loop. This method can | ||||||||||||||||||||||||||||
| 773 | return a list of values in list-context. | ||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||
| 775 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | =over 4 | ||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||
| 779 | =item each example 1 | ||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||
| 781 | # given: synopsis; | ||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||
| 783 | my $each = $hash->each(sub { | ||||||||||||||||||||||||||||
| 784 | [$_] | ||||||||||||||||||||||||||||
| 785 | }); | ||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | # [[2], [4], [6], [8]] | ||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||
| 789 | =back | ||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||
| 791 | =over 4 | ||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||
| 793 | =item each example 2 | ||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||
| 795 | # given: synopsis; | ||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | my $each = $hash->each(sub { | ||||||||||||||||||||||||||||
| 798 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||
| 800 | [$key, $value] | ||||||||||||||||||||||||||||
| 801 | }); | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | # [[1, 2], [3, 4], [5, 6], [7, 8]] | ||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||
| 805 | =back | ||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | =cut | ||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||
| 809 | =head2 empty | ||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||
| 811 | empty() (HashRef) | ||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||
| 813 | The empty method drops all elements from the hash. | ||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||
| 815 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||
| 817 | =over 4 | ||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||
| 819 | =item empty example 1 | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | # given: synopsis; | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | my $empty = $hash->empty; | ||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||
| 825 | # {} | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | =back | ||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||
| 829 | =cut | ||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||
| 831 | =head2 eq | ||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | eq(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||
| 835 | The eq method performs an I<"equals"> operation using the argument provided. | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||
| 839 | =over 4 | ||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||
| 841 | =item eq example 1 | ||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||
| 843 | package main; | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | use Venus::Array; | ||||||||||||||||||||||||||||
| 846 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||
| 848 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 849 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | # 0 | ||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||
| 855 | =back | ||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||
| 857 | =over 4 | ||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||
| 859 | =item eq example 2 | ||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||
| 861 | package main; | ||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | use Venus::Code; | ||||||||||||||||||||||||||||
| 864 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||
| 866 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 867 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||
| 869 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||
| 871 | # 0 | ||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||
| 873 | =back | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | =over 4 | ||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||
| 877 | =item eq example 3 | ||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||
| 879 | package main; | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | use Venus::Float; | ||||||||||||||||||||||||||||
| 882 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 885 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||
| 887 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||
| 889 | # 0 | ||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | =back | ||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||
| 893 | =over 4 | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | =item eq example 4 | ||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||
| 897 | package main; | ||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||
| 899 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||
| 901 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 902 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||
| 904 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | # 1 | ||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||
| 908 | =back | ||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||
| 910 | =over 4 | ||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||
| 912 | =item eq example 5 | ||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||
| 914 | package main; | ||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||
| 916 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 917 | use Venus::Number; | ||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||
| 919 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 920 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||
| 922 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | # 0 | ||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||
| 926 | =back | ||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||
| 928 | =over 4 | ||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||
| 930 | =item eq example 6 | ||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | package main; | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 935 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||
| 937 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 938 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||
| 940 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||
| 942 | # 0 | ||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | =back | ||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | =over 4 | ||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||
| 948 | =item eq example 7 | ||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||
| 950 | package main; | ||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||
| 952 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 953 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 956 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||
| 958 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||
| 960 | # 0 | ||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||
| 962 | =back | ||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||
| 964 | =over 4 | ||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||
| 966 | =item eq example 8 | ||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||
| 968 | package main; | ||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 971 | use Venus::String; | ||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||
| 973 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 974 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||
| 976 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | # 0 | ||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||
| 980 | =back | ||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||
| 982 | =over 4 | ||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||
| 984 | =item eq example 9 | ||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||
| 986 | package main; | ||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||
| 988 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 989 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||
| 991 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 992 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||
| 994 | my $result = $lvalue->eq($rvalue); | ||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||
| 996 | # 0 | ||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||
| 998 | =back | ||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||
| 1000 | =cut | ||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||
| 1002 | =head2 exists | ||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||
| 1004 | exists(Str $key) (Bool) | ||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||
| 1006 | The exists method returns true if the value matching the key specified in the | ||||||||||||||||||||||||||||
| 1007 | argument exists, otherwise returns false. | ||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||
| 1009 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||
| 1011 | =over 4 | ||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||
| 1013 | =item exists example 1 | ||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||
| 1015 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||
| 1017 | my $exists = $hash->exists(1); | ||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||
| 1019 | # 1 | ||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||
| 1021 | =back | ||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||
| 1023 | =over 4 | ||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||
| 1025 | =item exists example 2 | ||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||
| 1027 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||
| 1029 | my $exists = $hash->exists(0); | ||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||
| 1031 | # 0 | ||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||
| 1033 | =back | ||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||
| 1035 | =cut | ||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||
| 1037 | =head2 find | ||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||
| 1039 | find(Str @data) (Any) | ||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||
| 1041 | The find method traverses the data structure using the keys and indices | ||||||||||||||||||||||||||||
| 1042 | provided, returning the value found or undef. In list-context, this method | ||||||||||||||||||||||||||||
| 1043 | returns a tuple, i.e. the value found and boolean representing whether the | ||||||||||||||||||||||||||||
| 1044 | match was successful. | ||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||
| 1046 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||
| 1048 | =over 4 | ||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||
| 1050 | =item find example 1 | ||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||
| 1052 | package main; | ||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||
| 1054 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||
| 1056 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||
| 1058 | my $find = $hash->find('foo', 'bar'); | ||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||
| 1060 | # "baz" | ||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||
| 1062 | =back | ||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | =over 4 | ||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||
| 1066 | =item find example 2 | ||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||
| 1068 | package main; | ||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||
| 1070 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||
| 1072 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||
| 1074 | my $find = $hash->find('bar', 0); | ||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||
| 1076 | # "baz" | ||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||
| 1078 | =back | ||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||
| 1080 | =over 4 | ||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||
| 1082 | =item find example 3 | ||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||
| 1084 | package main; | ||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||
| 1086 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||
| 1088 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||
| 1090 | my $find = $hash->find('bar'); | ||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||
| 1092 | # ["baz"] | ||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||
| 1094 | =back | ||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||
| 1096 | =over 4 | ||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||
| 1098 | =item find example 4 | ||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||
| 1100 | package main; | ||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||
| 1102 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||
| 1104 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||
| 1106 | my ($find, $exists) = $hash->find('baz'); | ||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||
| 1108 | # (undef, 0) | ||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||
| 1110 | =back | ||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||
| 1112 | =cut | ||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||
| 1114 | =head2 ge | ||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||
| 1116 | ge(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||
| 1118 | The ge method performs a I<"greater-than-or-equal-to"> operation using the | ||||||||||||||||||||||||||||
| 1119 | argument provided. | ||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||
| 1121 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||
| 1123 | =over 4 | ||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||
| 1125 | =item ge example 1 | ||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||
| 1127 | package main; | ||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||
| 1129 | use Venus::Array; | ||||||||||||||||||||||||||||
| 1130 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||
| 1132 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1133 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||
| 1135 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||
| 1137 | # 0 | ||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||
| 1139 | =back | ||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||
| 1141 | =over 4 | ||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||
| 1143 | =item ge example 2 | ||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||
| 1145 | package main; | ||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||
| 1147 | use Venus::Code; | ||||||||||||||||||||||||||||
| 1148 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||
| 1150 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1151 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||
| 1153 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||
| 1155 | # 0 | ||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||
| 1157 | =back | ||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||
| 1159 | =over 4 | ||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||
| 1161 | =item ge example 3 | ||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||
| 1163 | package main; | ||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||
| 1165 | use Venus::Float; | ||||||||||||||||||||||||||||
| 1166 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||
| 1168 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1169 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||
| 1171 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||
| 1173 | # 1 | ||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||
| 1175 | =back | ||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||
| 1177 | =over 4 | ||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||
| 1179 | =item ge example 4 | ||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||
| 1181 | package main; | ||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||
| 1183 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||
| 1185 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1186 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||
| 1188 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | # 1 | ||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||
| 1192 | =back | ||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||
| 1194 | =over 4 | ||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||
| 1196 | =item ge example 5 | ||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||
| 1198 | package main; | ||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||
| 1200 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1201 | use Venus::Number; | ||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||
| 1203 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1204 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||
| 1206 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||
| 1208 | # 1 | ||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||
| 1210 | =back | ||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||
| 1212 | =over 4 | ||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||
| 1214 | =item ge example 6 | ||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||
| 1216 | package main; | ||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||
| 1218 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1219 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||
| 1221 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1222 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||
| 1224 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||
| 1226 | # 0 | ||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||
| 1228 | =back | ||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||
| 1230 | =over 4 | ||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||
| 1232 | =item ge example 7 | ||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||
| 1234 | package main; | ||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||
| 1236 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1237 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||
| 1239 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1240 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||
| 1242 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||
| 1244 | # 0 | ||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||
| 1246 | =back | ||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||
| 1248 | =over 4 | ||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||
| 1250 | =item ge example 8 | ||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||
| 1252 | package main; | ||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||
| 1254 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1255 | use Venus::String; | ||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||
| 1257 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1258 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||
| 1260 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||
| 1262 | # 1 | ||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||
| 1264 | =back | ||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||
| 1266 | =over 4 | ||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||
| 1268 | =item ge example 9 | ||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||
| 1270 | package main; | ||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||
| 1272 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1273 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||
| 1275 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1276 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||
| 1278 | my $result = $lvalue->ge($rvalue); | ||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||
| 1280 | # 1 | ||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||
| 1282 | =back | ||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||
| 1284 | =cut | ||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||
| 1286 | =head2 gele | ||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||
| 1288 | gele(Any $arg1, Any $arg2) (Bool) | ||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||
| 1290 | The gele method performs a I<"greater-than-or-equal-to"> operation on the 1st | ||||||||||||||||||||||||||||
| 1291 | argument, and I<"lesser-than-or-equal-to"> operation on the 2nd argument. | ||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||
| 1293 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||
| 1295 | =over 4 | ||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||
| 1297 | =item gele example 1 | ||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||
| 1299 | package main; | ||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||
| 1301 | use Venus::Array; | ||||||||||||||||||||||||||||
| 1302 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||
| 1304 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1305 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||
| 1307 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||
| 1309 | # 0 | ||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||
| 1311 | =back | ||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||
| 1313 | =over 4 | ||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||
| 1315 | =item gele example 2 | ||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||
| 1317 | package main; | ||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||
| 1319 | use Venus::Code; | ||||||||||||||||||||||||||||
| 1320 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||
| 1322 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1323 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||
| 1325 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||
| 1327 | # 0 | ||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||
| 1329 | =back | ||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||
| 1331 | =over 4 | ||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||
| 1333 | =item gele example 3 | ||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||
| 1335 | package main; | ||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||
| 1337 | use Venus::Float; | ||||||||||||||||||||||||||||
| 1338 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||
| 1340 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1341 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||
| 1343 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||
| 1345 | # 0 | ||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||
| 1347 | =back | ||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||
| 1349 | =over 4 | ||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||
| 1351 | =item gele example 4 | ||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||
| 1353 | package main; | ||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||
| 1355 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||
| 1357 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1358 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||
| 1360 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||
| 1362 | # 0 | ||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||
| 1364 | =back | ||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||
| 1366 | =over 4 | ||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||
| 1368 | =item gele example 5 | ||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||
| 1370 | package main; | ||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||
| 1372 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1373 | use Venus::Number; | ||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||
| 1375 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1376 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||
| 1378 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||
| 1380 | # 0 | ||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||
| 1382 | =back | ||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||
| 1384 | =over 4 | ||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||
| 1386 | =item gele example 6 | ||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||
| 1388 | package main; | ||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||
| 1390 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1391 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||
| 1393 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1394 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||
| 1396 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||
| 1398 | # 0 | ||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||
| 1400 | =back | ||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||
| 1402 | =over 4 | ||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||
| 1404 | =item gele example 7 | ||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||
| 1406 | package main; | ||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||
| 1408 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1409 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||
| 1411 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1412 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||
| 1414 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||
| 1416 | # 0 | ||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||
| 1418 | =back | ||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||
| 1420 | =over 4 | ||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||
| 1422 | =item gele example 8 | ||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||
| 1424 | package main; | ||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||
| 1426 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1427 | use Venus::String; | ||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||
| 1429 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1430 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||
| 1432 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||
| 1434 | # 0 | ||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||
| 1436 | =back | ||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||
| 1438 | =over 4 | ||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||
| 1440 | =item gele example 9 | ||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||
| 1442 | package main; | ||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||
| 1444 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1445 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||
| 1447 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1448 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||
| 1450 | my $result = $lvalue->gele($rvalue); | ||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||
| 1452 | # 0 | ||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||
| 1454 | =back | ||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||
| 1456 | =cut | ||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||
| 1458 | =head2 grep | ||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||
| 1460 | grep(CodeRef $code) (ArrayRef) | ||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||
| 1462 | The grep method executes callback for each key/value pair in the hash passing | ||||||||||||||||||||||||||||
| 1463 | the routine the key and value at the current position in the loop and returning | ||||||||||||||||||||||||||||
| 1464 | a new hash reference containing the elements for which the argument evaluated | ||||||||||||||||||||||||||||
| 1465 | true. This method can return a list of values in list-context. | ||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||
| 1467 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||
| 1469 | =over 4 | ||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||
| 1471 | =item grep example 1 | ||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||
| 1473 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||
| 1475 | my $grep = $hash->grep(sub { | ||||||||||||||||||||||||||||
| 1476 | $_ >= 3 | ||||||||||||||||||||||||||||
| 1477 | }); | ||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||
| 1479 | # [3..8] | ||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||
| 1481 | =back | ||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||
| 1483 | =over 4 | ||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||
| 1485 | =item grep example 2 | ||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||
| 1487 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||
| 1489 | my $grep = $hash->grep(sub { | ||||||||||||||||||||||||||||
| 1490 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||
| 1492 | $value >= 3 | ||||||||||||||||||||||||||||
| 1493 | }); | ||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||
| 1495 | # [3..8] | ||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||
| 1497 | =back | ||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||
| 1499 | =cut | ||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||
| 1501 | =head2 gt | ||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||
| 1503 | gt(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||
| 1505 | The gt method performs a I<"greater-than"> operation using the argument provided. | ||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||
| 1507 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||
| 1509 | =over 4 | ||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||
| 1511 | =item gt example 1 | ||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||
| 1513 | package main; | ||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||
| 1515 | use Venus::Array; | ||||||||||||||||||||||||||||
| 1516 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||
| 1518 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1519 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||
| 1521 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||
| 1523 | # 0 | ||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||
| 1525 | =back | ||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||
| 1527 | =over 4 | ||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||
| 1529 | =item gt example 2 | ||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||
| 1531 | package main; | ||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||
| 1533 | use Venus::Code; | ||||||||||||||||||||||||||||
| 1534 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||
| 1536 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1537 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||
| 1539 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||
| 1541 | # 0 | ||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||
| 1543 | =back | ||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||
| 1545 | =over 4 | ||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||
| 1547 | =item gt example 3 | ||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||
| 1549 | package main; | ||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||
| 1551 | use Venus::Float; | ||||||||||||||||||||||||||||
| 1552 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||
| 1554 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1555 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||
| 1557 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||
| 1559 | # 1 | ||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||
| 1561 | =back | ||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||
| 1563 | =over 4 | ||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||
| 1565 | =item gt example 4 | ||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||
| 1567 | package main; | ||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||
| 1569 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||
| 1571 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1572 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||
| 1574 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||
| 1576 | # 0 | ||||||||||||||||||||||||||||
| 1577 | |||||||||||||||||||||||||||||
| 1578 | =back | ||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||
| 1580 | =over 4 | ||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||
| 1582 | =item gt example 5 | ||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||
| 1584 | package main; | ||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||
| 1586 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1587 | use Venus::Number; | ||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||
| 1589 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1590 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||
| 1592 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||
| 1594 | # 1 | ||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||
| 1596 | =back | ||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||
| 1598 | =over 4 | ||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||
| 1600 | =item gt example 6 | ||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||
| 1602 | package main; | ||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||
| 1604 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1605 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||
| 1607 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1608 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||
| 1610 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||
| 1612 | # 0 | ||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||
| 1614 | =back | ||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||
| 1616 | =over 4 | ||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||
| 1618 | =item gt example 7 | ||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||
| 1620 | package main; | ||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||
| 1622 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1623 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||
| 1625 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1626 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||
| 1628 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||
| 1630 | # 0 | ||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||
| 1632 | =back | ||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||
| 1634 | =over 4 | ||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||
| 1636 | =item gt example 8 | ||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||
| 1638 | package main; | ||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||
| 1640 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1641 | use Venus::String; | ||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||
| 1643 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1644 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 1645 | |||||||||||||||||||||||||||||
| 1646 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||
| 1648 | # 1 | ||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||
| 1650 | =back | ||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||
| 1652 | =over 4 | ||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||
| 1654 | =item gt example 9 | ||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||
| 1656 | package main; | ||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||
| 1658 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1659 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||
| 1661 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1662 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||
| 1664 | my $result = $lvalue->gt($rvalue); | ||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||
| 1666 | # 1 | ||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||
| 1668 | =back | ||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||
| 1670 | =cut | ||||||||||||||||||||||||||||
| 1671 | |||||||||||||||||||||||||||||
| 1672 | =head2 gtlt | ||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||
| 1674 | gtlt(Any $arg1, Any $arg2) (Bool) | ||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||
| 1676 | The gtlt method performs a I<"greater-than"> operation on the 1st argument, and | ||||||||||||||||||||||||||||
| 1677 | I<"lesser-than"> operation on the 2nd argument. | ||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||
| 1679 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||
| 1681 | =over 4 | ||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||
| 1683 | =item gtlt example 1 | ||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||
| 1685 | package main; | ||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||
| 1687 | use Venus::Array; | ||||||||||||||||||||||||||||
| 1688 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||
| 1690 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1691 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||
| 1693 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||
| 1695 | # 0 | ||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||
| 1697 | =back | ||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||
| 1699 | =over 4 | ||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||
| 1701 | =item gtlt example 2 | ||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||
| 1703 | package main; | ||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||
| 1705 | use Venus::Code; | ||||||||||||||||||||||||||||
| 1706 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||
| 1708 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1709 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||
| 1711 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||
| 1713 | # 0 | ||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||
| 1715 | =back | ||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||
| 1717 | =over 4 | ||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||
| 1719 | =item gtlt example 3 | ||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||
| 1721 | package main; | ||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||
| 1723 | use Venus::Float; | ||||||||||||||||||||||||||||
| 1724 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||
| 1726 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1727 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 1728 | |||||||||||||||||||||||||||||
| 1729 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||
| 1731 | # 0 | ||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||
| 1733 | =back | ||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||
| 1735 | =over 4 | ||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||
| 1737 | =item gtlt example 4 | ||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||
| 1739 | package main; | ||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||
| 1741 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||
| 1743 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1744 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||
| 1746 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||
| 1748 | # 0 | ||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||
| 1750 | =back | ||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||
| 1752 | =over 4 | ||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||
| 1754 | =item gtlt example 5 | ||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||
| 1756 | package main; | ||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||
| 1758 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1759 | use Venus::Number; | ||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||
| 1761 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1762 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||
| 1764 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||
| 1766 | # 0 | ||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||
| 1768 | =back | ||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||
| 1770 | =over 4 | ||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||
| 1772 | =item gtlt example 6 | ||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||
| 1774 | package main; | ||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||
| 1776 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1777 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||
| 1779 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1780 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 1781 | |||||||||||||||||||||||||||||
| 1782 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||
| 1784 | # 0 | ||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||
| 1786 | =back | ||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||
| 1788 | =over 4 | ||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||
| 1790 | =item gtlt example 7 | ||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||
| 1792 | package main; | ||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||
| 1794 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1795 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||
| 1797 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1798 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||
| 1800 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||
| 1802 | # 0 | ||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||
| 1804 | =back | ||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||
| 1806 | =over 4 | ||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||
| 1808 | =item gtlt example 8 | ||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||
| 1810 | package main; | ||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||
| 1812 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1813 | use Venus::String; | ||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||
| 1815 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1816 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||
| 1818 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||
| 1820 | # 0 | ||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||
| 1822 | =back | ||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||
| 1824 | =over 4 | ||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||
| 1826 | =item gtlt example 9 | ||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||
| 1828 | package main; | ||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||
| 1830 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1831 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||
| 1833 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1834 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||
| 1836 | my $result = $lvalue->gtlt($rvalue); | ||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||
| 1838 | # 0 | ||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||
| 1840 | =back | ||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||
| 1842 | =cut | ||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||
| 1844 | =head2 iterator | ||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||
| 1846 | iterator() (CodeRef) | ||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||
| 1848 | The iterator method returns a code reference which can be used to iterate over | ||||||||||||||||||||||||||||
| 1849 | the hash. Each time the iterator is executed it will return the values of the | ||||||||||||||||||||||||||||
| 1850 | next element in the hash until all elements have been seen, at which point the | ||||||||||||||||||||||||||||
| 1851 | iterator will return an undefined value. This method can return a tuple with | ||||||||||||||||||||||||||||
| 1852 | the key and value in list-context. | ||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||
| 1854 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||
| 1856 | =over 4 | ||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||
| 1858 | =item iterator example 1 | ||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||
| 1860 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||
| 1862 | my $iterator = $hash->iterator; | ||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||
| 1864 | # sub { ... } | ||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||
| 1866 | # while (my $value = $iterator->()) { | ||||||||||||||||||||||||||||
| 1867 | # say $value; # 1 | ||||||||||||||||||||||||||||
| 1868 | # } | ||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||
| 1870 | =back | ||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||
| 1872 | =over 4 | ||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||
| 1874 | =item iterator example 2 | ||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||
| 1876 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||
| 1878 | my $iterator = $hash->iterator; | ||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||
| 1880 | # sub { ... } | ||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||
| 1882 | # while (grep defined, my ($key, $value) = $iterator->()) { | ||||||||||||||||||||||||||||
| 1883 | # say $value; # 1 | ||||||||||||||||||||||||||||
| 1884 | # } | ||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||
| 1886 | =back | ||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||
| 1888 | =cut | ||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||
| 1890 | =head2 keys | ||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||
| 1892 | keys() (ArrayRef) | ||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||
| 1894 | The keys method returns an array reference consisting of all the keys in the | ||||||||||||||||||||||||||||
| 1895 | hash. | ||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||
| 1897 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||
| 1899 | =over 4 | ||||||||||||||||||||||||||||
| 1900 | |||||||||||||||||||||||||||||
| 1901 | =item keys example 1 | ||||||||||||||||||||||||||||
| 1902 | |||||||||||||||||||||||||||||
| 1903 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||
| 1905 | my $keys = $hash->keys; | ||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||
| 1907 | # [1, 3, 5, 7] | ||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||
| 1909 | =back | ||||||||||||||||||||||||||||
| 1910 | |||||||||||||||||||||||||||||
| 1911 | =cut | ||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||
| 1913 | =head2 le | ||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||
| 1915 | le(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 1916 | |||||||||||||||||||||||||||||
| 1917 | The le method performs a I<"lesser-than-or-equal-to"> operation using the | ||||||||||||||||||||||||||||
| 1918 | argument provided. | ||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||
| 1920 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||
| 1922 | =over 4 | ||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||
| 1924 | =item le example 1 | ||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||
| 1926 | package main; | ||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||
| 1928 | use Venus::Array; | ||||||||||||||||||||||||||||
| 1929 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1930 | |||||||||||||||||||||||||||||
| 1931 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1932 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||
| 1934 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||
| 1936 | # 0 | ||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||
| 1938 | =back | ||||||||||||||||||||||||||||
| 1939 | |||||||||||||||||||||||||||||
| 1940 | =over 4 | ||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||
| 1942 | =item le example 2 | ||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||
| 1944 | package main; | ||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||
| 1946 | use Venus::Code; | ||||||||||||||||||||||||||||
| 1947 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||
| 1949 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1950 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||
| 1952 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||
| 1954 | # 1 | ||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||
| 1956 | =back | ||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||
| 1958 | =over 4 | ||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||
| 1960 | =item le example 3 | ||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||
| 1962 | package main; | ||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||
| 1964 | use Venus::Float; | ||||||||||||||||||||||||||||
| 1965 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1966 | |||||||||||||||||||||||||||||
| 1967 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1968 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 1969 | |||||||||||||||||||||||||||||
| 1970 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 1971 | |||||||||||||||||||||||||||||
| 1972 | # 0 | ||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||
| 1974 | =back | ||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||
| 1976 | =over 4 | ||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||
| 1978 | =item le example 4 | ||||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||
| 1980 | package main; | ||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||
| 1982 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 1983 | |||||||||||||||||||||||||||||
| 1984 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1985 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||
| 1987 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||
| 1989 | # 1 | ||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||
| 1991 | =back | ||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||
| 1993 | =over 4 | ||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||
| 1995 | =item le example 5 | ||||||||||||||||||||||||||||
| 1996 | |||||||||||||||||||||||||||||
| 1997 | package main; | ||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||
| 1999 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2000 | use Venus::Number; | ||||||||||||||||||||||||||||
| 2001 | |||||||||||||||||||||||||||||
| 2002 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2003 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||
| 2005 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 2006 | |||||||||||||||||||||||||||||
| 2007 | # 0 | ||||||||||||||||||||||||||||
| 2008 | |||||||||||||||||||||||||||||
| 2009 | =back | ||||||||||||||||||||||||||||
| 2010 | |||||||||||||||||||||||||||||
| 2011 | =over 4 | ||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||
| 2013 | =item le example 6 | ||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||
| 2015 | package main; | ||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||
| 2017 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2018 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||
| 2020 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2021 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||
| 2023 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||
| 2025 | # 1 | ||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||
| 2027 | =back | ||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||
| 2029 | =over 4 | ||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||
| 2031 | =item le example 7 | ||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||
| 2033 | package main; | ||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||
| 2035 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2036 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 2037 | |||||||||||||||||||||||||||||
| 2038 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2039 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||
| 2041 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 2042 | |||||||||||||||||||||||||||||
| 2043 | # 0 | ||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||
| 2045 | =back | ||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||
| 2047 | =over 4 | ||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||
| 2049 | =item le example 8 | ||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||
| 2051 | package main; | ||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||
| 2053 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2054 | use Venus::String; | ||||||||||||||||||||||||||||
| 2055 | |||||||||||||||||||||||||||||
| 2056 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2057 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||
| 2059 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 2060 | |||||||||||||||||||||||||||||
| 2061 | # 0 | ||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||
| 2063 | =back | ||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||
| 2065 | =over 4 | ||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||
| 2067 | =item le example 9 | ||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||
| 2069 | package main; | ||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||
| 2071 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2072 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||
| 2074 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2075 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||
| 2077 | my $result = $lvalue->le($rvalue); | ||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||
| 2079 | # 0 | ||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||
| 2081 | =back | ||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||
| 2083 | =cut | ||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||
| 2085 | =head2 length | ||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||
| 2087 | length() (Int) | ||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||
| 2089 | The length method returns the total number of keys defined, and is an alias for | ||||||||||||||||||||||||||||
| 2090 | the L</count> method. | ||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||
| 2092 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||
| 2094 | =over 4 | ||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||
| 2096 | =item length example 1 | ||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||
| 2098 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||
| 2100 | my $length = $hash->length; | ||||||||||||||||||||||||||||
| 2101 | |||||||||||||||||||||||||||||
| 2102 | # 4 | ||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||
| 2104 | =back | ||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||
| 2106 | =cut | ||||||||||||||||||||||||||||
| 2107 | |||||||||||||||||||||||||||||
| 2108 | =head2 list | ||||||||||||||||||||||||||||
| 2109 | |||||||||||||||||||||||||||||
| 2110 | list() (Any) | ||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||
| 2112 | The list method returns a shallow copy of the underlying hash reference as an | ||||||||||||||||||||||||||||
| 2113 | array reference. | ||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||
| 2115 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||
| 2117 | =over 4 | ||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||
| 2119 | =item list example 1 | ||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||
| 2121 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||
| 2123 | my $list = $hash->list; | ||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||
| 2125 | # 4 | ||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||
| 2127 | =back | ||||||||||||||||||||||||||||
| 2128 | |||||||||||||||||||||||||||||
| 2129 | =over 4 | ||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||
| 2131 | =item list example 2 | ||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||
| 2133 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||
| 2135 | my @list = $hash->list; | ||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||
| 2137 | # (1..8) | ||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||
| 2139 | =back | ||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||
| 2141 | =cut | ||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||
| 2143 | =head2 lt | ||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||
| 2145 | lt(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||
| 2147 | The lt method performs a I<"lesser-than"> operation using the argument provided. | ||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||
| 2149 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||
| 2151 | =over 4 | ||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||
| 2153 | =item lt example 1 | ||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||
| 2155 | package main; | ||||||||||||||||||||||||||||
| 2156 | |||||||||||||||||||||||||||||
| 2157 | use Venus::Array; | ||||||||||||||||||||||||||||
| 2158 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||
| 2160 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2161 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 2162 | |||||||||||||||||||||||||||||
| 2163 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||
| 2165 | # 0 | ||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||
| 2167 | =back | ||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||
| 2169 | =over 4 | ||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||
| 2171 | =item lt example 2 | ||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||
| 2173 | package main; | ||||||||||||||||||||||||||||
| 2174 | |||||||||||||||||||||||||||||
| 2175 | use Venus::Code; | ||||||||||||||||||||||||||||
| 2176 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||
| 2178 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2179 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||
| 2181 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2182 | |||||||||||||||||||||||||||||
| 2183 | # 1 | ||||||||||||||||||||||||||||
| 2184 | |||||||||||||||||||||||||||||
| 2185 | =back | ||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||
| 2187 | =over 4 | ||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||
| 2189 | =item lt example 3 | ||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||
| 2191 | package main; | ||||||||||||||||||||||||||||
| 2192 | |||||||||||||||||||||||||||||
| 2193 | use Venus::Float; | ||||||||||||||||||||||||||||
| 2194 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2195 | |||||||||||||||||||||||||||||
| 2196 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2197 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 2198 | |||||||||||||||||||||||||||||
| 2199 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2200 | |||||||||||||||||||||||||||||
| 2201 | # 0 | ||||||||||||||||||||||||||||
| 2202 | |||||||||||||||||||||||||||||
| 2203 | =back | ||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||
| 2205 | =over 4 | ||||||||||||||||||||||||||||
| 2206 | |||||||||||||||||||||||||||||
| 2207 | =item lt example 4 | ||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||
| 2209 | package main; | ||||||||||||||||||||||||||||
| 2210 | |||||||||||||||||||||||||||||
| 2211 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2212 | |||||||||||||||||||||||||||||
| 2213 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2214 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||
| 2216 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2217 | |||||||||||||||||||||||||||||
| 2218 | # 0 | ||||||||||||||||||||||||||||
| 2219 | |||||||||||||||||||||||||||||
| 2220 | =back | ||||||||||||||||||||||||||||
| 2221 | |||||||||||||||||||||||||||||
| 2222 | =over 4 | ||||||||||||||||||||||||||||
| 2223 | |||||||||||||||||||||||||||||
| 2224 | =item lt example 5 | ||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||
| 2226 | package main; | ||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||
| 2228 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2229 | use Venus::Number; | ||||||||||||||||||||||||||||
| 2230 | |||||||||||||||||||||||||||||
| 2231 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2232 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 2233 | |||||||||||||||||||||||||||||
| 2234 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2235 | |||||||||||||||||||||||||||||
| 2236 | # 0 | ||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||
| 2238 | =back | ||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||
| 2240 | =over 4 | ||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||
| 2242 | =item lt example 6 | ||||||||||||||||||||||||||||
| 2243 | |||||||||||||||||||||||||||||
| 2244 | package main; | ||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||
| 2246 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2247 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 2248 | |||||||||||||||||||||||||||||
| 2249 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2250 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||
| 2252 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||
| 2254 | # 1 | ||||||||||||||||||||||||||||
| 2255 | |||||||||||||||||||||||||||||
| 2256 | =back | ||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||
| 2258 | =over 4 | ||||||||||||||||||||||||||||
| 2259 | |||||||||||||||||||||||||||||
| 2260 | =item lt example 7 | ||||||||||||||||||||||||||||
| 2261 | |||||||||||||||||||||||||||||
| 2262 | package main; | ||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||
| 2264 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2265 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 2266 | |||||||||||||||||||||||||||||
| 2267 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2268 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 2269 | |||||||||||||||||||||||||||||
| 2270 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||
| 2272 | # 0 | ||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||
| 2274 | =back | ||||||||||||||||||||||||||||
| 2275 | |||||||||||||||||||||||||||||
| 2276 | =over 4 | ||||||||||||||||||||||||||||
| 2277 | |||||||||||||||||||||||||||||
| 2278 | =item lt example 8 | ||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||
| 2280 | package main; | ||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||
| 2282 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2283 | use Venus::String; | ||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||
| 2285 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2286 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||
| 2288 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||
| 2290 | # 0 | ||||||||||||||||||||||||||||
| 2291 | |||||||||||||||||||||||||||||
| 2292 | =back | ||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||
| 2294 | =over 4 | ||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||
| 2296 | =item lt example 9 | ||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||
| 2298 | package main; | ||||||||||||||||||||||||||||
| 2299 | |||||||||||||||||||||||||||||
| 2300 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2301 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 2302 | |||||||||||||||||||||||||||||
| 2303 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2304 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 2305 | |||||||||||||||||||||||||||||
| 2306 | my $result = $lvalue->lt($rvalue); | ||||||||||||||||||||||||||||
| 2307 | |||||||||||||||||||||||||||||
| 2308 | # 0 | ||||||||||||||||||||||||||||
| 2309 | |||||||||||||||||||||||||||||
| 2310 | =back | ||||||||||||||||||||||||||||
| 2311 | |||||||||||||||||||||||||||||
| 2312 | =cut | ||||||||||||||||||||||||||||
| 2313 | |||||||||||||||||||||||||||||
| 2314 | =head2 map | ||||||||||||||||||||||||||||
| 2315 | |||||||||||||||||||||||||||||
| 2316 | map(CodeRef $code) (ArrayRef) | ||||||||||||||||||||||||||||
| 2317 | |||||||||||||||||||||||||||||
| 2318 | The map method executes callback for each key/value in the hash passing the | ||||||||||||||||||||||||||||
| 2319 | routine the value at the current position in the loop and returning a new hash | ||||||||||||||||||||||||||||
| 2320 | reference containing the elements for which the argument returns a value or | ||||||||||||||||||||||||||||
| 2321 | non-empty list. This method can return a list of values in list-context. | ||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||
| 2323 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2324 | |||||||||||||||||||||||||||||
| 2325 | =over 4 | ||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||
| 2327 | =item map example 1 | ||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||
| 2329 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2330 | |||||||||||||||||||||||||||||
| 2331 | my $map = $hash->map(sub { | ||||||||||||||||||||||||||||
| 2332 | $_ * 2 | ||||||||||||||||||||||||||||
| 2333 | }); | ||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||
| 2335 | # [4, 8, 12, 16] | ||||||||||||||||||||||||||||
| 2336 | |||||||||||||||||||||||||||||
| 2337 | =back | ||||||||||||||||||||||||||||
| 2338 | |||||||||||||||||||||||||||||
| 2339 | =over 4 | ||||||||||||||||||||||||||||
| 2340 | |||||||||||||||||||||||||||||
| 2341 | =item map example 2 | ||||||||||||||||||||||||||||
| 2342 | |||||||||||||||||||||||||||||
| 2343 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2344 | |||||||||||||||||||||||||||||
| 2345 | my $map = $hash->map(sub { | ||||||||||||||||||||||||||||
| 2346 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||
| 2348 | [$key, ($value * 2)] | ||||||||||||||||||||||||||||
| 2349 | }); | ||||||||||||||||||||||||||||
| 2350 | |||||||||||||||||||||||||||||
| 2351 | # [[1, 4], [3, 8], [5, 12], [7, 16]] | ||||||||||||||||||||||||||||
| 2352 | |||||||||||||||||||||||||||||
| 2353 | =back | ||||||||||||||||||||||||||||
| 2354 | |||||||||||||||||||||||||||||
| 2355 | =cut | ||||||||||||||||||||||||||||
| 2356 | |||||||||||||||||||||||||||||
| 2357 | =head2 merge | ||||||||||||||||||||||||||||
| 2358 | |||||||||||||||||||||||||||||
| 2359 | merge(HashRef @data) (HashRef) | ||||||||||||||||||||||||||||
| 2360 | |||||||||||||||||||||||||||||
| 2361 | The merge method returns a hash reference where the elements in the hash and | ||||||||||||||||||||||||||||
| 2362 | the elements in the argument(s) are merged. This operation performs a deep | ||||||||||||||||||||||||||||
| 2363 | merge and clones the datasets to ensure no side-effects. The merge behavior | ||||||||||||||||||||||||||||
| 2364 | merges hash references only, all other data types are assigned with precendence | ||||||||||||||||||||||||||||
| 2365 | given to the value being merged. | ||||||||||||||||||||||||||||
| 2366 | |||||||||||||||||||||||||||||
| 2367 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2368 | |||||||||||||||||||||||||||||
| 2369 | =over 4 | ||||||||||||||||||||||||||||
| 2370 | |||||||||||||||||||||||||||||
| 2371 | =item merge example 1 | ||||||||||||||||||||||||||||
| 2372 | |||||||||||||||||||||||||||||
| 2373 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2374 | |||||||||||||||||||||||||||||
| 2375 | my $merge = $hash->merge({1 => 'a'}); | ||||||||||||||||||||||||||||
| 2376 | |||||||||||||||||||||||||||||
| 2377 | # { 1 => "a", 3 => 4, 5 => 6, 7 => 8 } | ||||||||||||||||||||||||||||
| 2378 | |||||||||||||||||||||||||||||
| 2379 | =back | ||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||
| 2381 | =over 4 | ||||||||||||||||||||||||||||
| 2382 | |||||||||||||||||||||||||||||
| 2383 | =item merge example 2 | ||||||||||||||||||||||||||||
| 2384 | |||||||||||||||||||||||||||||
| 2385 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2386 | |||||||||||||||||||||||||||||
| 2387 | my $merge = $hash->merge({1 => 'a'}, {5 => 'b'}); | ||||||||||||||||||||||||||||
| 2388 | |||||||||||||||||||||||||||||
| 2389 | # { 1 => "a", 3 => 4, 5 => "b", 7 => 8 } | ||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||
| 2391 | =back | ||||||||||||||||||||||||||||
| 2392 | |||||||||||||||||||||||||||||
| 2393 | =cut | ||||||||||||||||||||||||||||
| 2394 | |||||||||||||||||||||||||||||
| 2395 | =head2 ne | ||||||||||||||||||||||||||||
| 2396 | |||||||||||||||||||||||||||||
| 2397 | ne(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 2398 | |||||||||||||||||||||||||||||
| 2399 | The ne method performs a I<"not-equal-to"> operation using the argument provided. | ||||||||||||||||||||||||||||
| 2400 | |||||||||||||||||||||||||||||
| 2401 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 2402 | |||||||||||||||||||||||||||||
| 2403 | =over 4 | ||||||||||||||||||||||||||||
| 2404 | |||||||||||||||||||||||||||||
| 2405 | =item ne example 1 | ||||||||||||||||||||||||||||
| 2406 | |||||||||||||||||||||||||||||
| 2407 | package main; | ||||||||||||||||||||||||||||
| 2408 | |||||||||||||||||||||||||||||
| 2409 | use Venus::Array; | ||||||||||||||||||||||||||||
| 2410 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||
| 2412 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2413 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 2414 | |||||||||||||||||||||||||||||
| 2415 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2416 | |||||||||||||||||||||||||||||
| 2417 | # 1 | ||||||||||||||||||||||||||||
| 2418 | |||||||||||||||||||||||||||||
| 2419 | =back | ||||||||||||||||||||||||||||
| 2420 | |||||||||||||||||||||||||||||
| 2421 | =over 4 | ||||||||||||||||||||||||||||
| 2422 | |||||||||||||||||||||||||||||
| 2423 | =item ne example 2 | ||||||||||||||||||||||||||||
| 2424 | |||||||||||||||||||||||||||||
| 2425 | package main; | ||||||||||||||||||||||||||||
| 2426 | |||||||||||||||||||||||||||||
| 2427 | use Venus::Code; | ||||||||||||||||||||||||||||
| 2428 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2429 | |||||||||||||||||||||||||||||
| 2430 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2431 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 2432 | |||||||||||||||||||||||||||||
| 2433 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2434 | |||||||||||||||||||||||||||||
| 2435 | # 1 | ||||||||||||||||||||||||||||
| 2436 | |||||||||||||||||||||||||||||
| 2437 | =back | ||||||||||||||||||||||||||||
| 2438 | |||||||||||||||||||||||||||||
| 2439 | =over 4 | ||||||||||||||||||||||||||||
| 2440 | |||||||||||||||||||||||||||||
| 2441 | =item ne example 3 | ||||||||||||||||||||||||||||
| 2442 | |||||||||||||||||||||||||||||
| 2443 | package main; | ||||||||||||||||||||||||||||
| 2444 | |||||||||||||||||||||||||||||
| 2445 | use Venus::Float; | ||||||||||||||||||||||||||||
| 2446 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2447 | |||||||||||||||||||||||||||||
| 2448 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2449 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 2450 | |||||||||||||||||||||||||||||
| 2451 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2452 | |||||||||||||||||||||||||||||
| 2453 | # 1 | ||||||||||||||||||||||||||||
| 2454 | |||||||||||||||||||||||||||||
| 2455 | =back | ||||||||||||||||||||||||||||
| 2456 | |||||||||||||||||||||||||||||
| 2457 | =over 4 | ||||||||||||||||||||||||||||
| 2458 | |||||||||||||||||||||||||||||
| 2459 | =item ne example 4 | ||||||||||||||||||||||||||||
| 2460 | |||||||||||||||||||||||||||||
| 2461 | package main; | ||||||||||||||||||||||||||||
| 2462 | |||||||||||||||||||||||||||||
| 2463 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2464 | |||||||||||||||||||||||||||||
| 2465 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2466 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2467 | |||||||||||||||||||||||||||||
| 2468 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2469 | |||||||||||||||||||||||||||||
| 2470 | # 0 | ||||||||||||||||||||||||||||
| 2471 | |||||||||||||||||||||||||||||
| 2472 | =back | ||||||||||||||||||||||||||||
| 2473 | |||||||||||||||||||||||||||||
| 2474 | =over 4 | ||||||||||||||||||||||||||||
| 2475 | |||||||||||||||||||||||||||||
| 2476 | =item ne example 5 | ||||||||||||||||||||||||||||
| 2477 | |||||||||||||||||||||||||||||
| 2478 | package main; | ||||||||||||||||||||||||||||
| 2479 | |||||||||||||||||||||||||||||
| 2480 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2481 | use Venus::Number; | ||||||||||||||||||||||||||||
| 2482 | |||||||||||||||||||||||||||||
| 2483 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2484 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 2485 | |||||||||||||||||||||||||||||
| 2486 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2487 | |||||||||||||||||||||||||||||
| 2488 | # 1 | ||||||||||||||||||||||||||||
| 2489 | |||||||||||||||||||||||||||||
| 2490 | =back | ||||||||||||||||||||||||||||
| 2491 | |||||||||||||||||||||||||||||
| 2492 | =over 4 | ||||||||||||||||||||||||||||
| 2493 | |||||||||||||||||||||||||||||
| 2494 | =item ne example 6 | ||||||||||||||||||||||||||||
| 2495 | |||||||||||||||||||||||||||||
| 2496 | package main; | ||||||||||||||||||||||||||||
| 2497 | |||||||||||||||||||||||||||||
| 2498 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2499 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 2500 | |||||||||||||||||||||||||||||
| 2501 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2502 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 2503 | |||||||||||||||||||||||||||||
| 2504 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2505 | |||||||||||||||||||||||||||||
| 2506 | # 1 | ||||||||||||||||||||||||||||
| 2507 | |||||||||||||||||||||||||||||
| 2508 | =back | ||||||||||||||||||||||||||||
| 2509 | |||||||||||||||||||||||||||||
| 2510 | =over 4 | ||||||||||||||||||||||||||||
| 2511 | |||||||||||||||||||||||||||||
| 2512 | =item ne example 7 | ||||||||||||||||||||||||||||
| 2513 | |||||||||||||||||||||||||||||
| 2514 | package main; | ||||||||||||||||||||||||||||
| 2515 | |||||||||||||||||||||||||||||
| 2516 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2517 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 2518 | |||||||||||||||||||||||||||||
| 2519 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2520 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 2521 | |||||||||||||||||||||||||||||
| 2522 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2523 | |||||||||||||||||||||||||||||
| 2524 | # 1 | ||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||
| 2526 | =back | ||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||
| 2528 | =over 4 | ||||||||||||||||||||||||||||
| 2529 | |||||||||||||||||||||||||||||
| 2530 | =item ne example 8 | ||||||||||||||||||||||||||||
| 2531 | |||||||||||||||||||||||||||||
| 2532 | package main; | ||||||||||||||||||||||||||||
| 2533 | |||||||||||||||||||||||||||||
| 2534 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2535 | use Venus::String; | ||||||||||||||||||||||||||||
| 2536 | |||||||||||||||||||||||||||||
| 2537 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2538 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 2539 | |||||||||||||||||||||||||||||
| 2540 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2541 | |||||||||||||||||||||||||||||
| 2542 | # 1 | ||||||||||||||||||||||||||||
| 2543 | |||||||||||||||||||||||||||||
| 2544 | =back | ||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||
| 2546 | =over 4 | ||||||||||||||||||||||||||||
| 2547 | |||||||||||||||||||||||||||||
| 2548 | =item ne example 9 | ||||||||||||||||||||||||||||
| 2549 | |||||||||||||||||||||||||||||
| 2550 | package main; | ||||||||||||||||||||||||||||
| 2551 | |||||||||||||||||||||||||||||
| 2552 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2553 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 2554 | |||||||||||||||||||||||||||||
| 2555 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2556 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 2557 | |||||||||||||||||||||||||||||
| 2558 | my $result = $lvalue->ne($rvalue); | ||||||||||||||||||||||||||||
| 2559 | |||||||||||||||||||||||||||||
| 2560 | # 1 | ||||||||||||||||||||||||||||
| 2561 | |||||||||||||||||||||||||||||
| 2562 | =back | ||||||||||||||||||||||||||||
| 2563 | |||||||||||||||||||||||||||||
| 2564 | =cut | ||||||||||||||||||||||||||||
| 2565 | |||||||||||||||||||||||||||||
| 2566 | =head2 none | ||||||||||||||||||||||||||||
| 2567 | |||||||||||||||||||||||||||||
| 2568 | none(CodeRef $code) (Bool) | ||||||||||||||||||||||||||||
| 2569 | |||||||||||||||||||||||||||||
| 2570 | The none method returns true if none of the elements in the array meet the | ||||||||||||||||||||||||||||
| 2571 | criteria set by the operand and rvalue. | ||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||
| 2573 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2574 | |||||||||||||||||||||||||||||
| 2575 | =over 4 | ||||||||||||||||||||||||||||
| 2576 | |||||||||||||||||||||||||||||
| 2577 | =item none example 1 | ||||||||||||||||||||||||||||
| 2578 | |||||||||||||||||||||||||||||
| 2579 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2580 | |||||||||||||||||||||||||||||
| 2581 | my $none = $hash->none(sub { | ||||||||||||||||||||||||||||
| 2582 | $_ < 1 | ||||||||||||||||||||||||||||
| 2583 | }); | ||||||||||||||||||||||||||||
| 2584 | |||||||||||||||||||||||||||||
| 2585 | # 1 | ||||||||||||||||||||||||||||
| 2586 | |||||||||||||||||||||||||||||
| 2587 | =back | ||||||||||||||||||||||||||||
| 2588 | |||||||||||||||||||||||||||||
| 2589 | =over 4 | ||||||||||||||||||||||||||||
| 2590 | |||||||||||||||||||||||||||||
| 2591 | =item none example 2 | ||||||||||||||||||||||||||||
| 2592 | |||||||||||||||||||||||||||||
| 2593 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2594 | |||||||||||||||||||||||||||||
| 2595 | my $none = $hash->none(sub { | ||||||||||||||||||||||||||||
| 2596 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 2597 | |||||||||||||||||||||||||||||
| 2598 | $value < 1 | ||||||||||||||||||||||||||||
| 2599 | }); | ||||||||||||||||||||||||||||
| 2600 | |||||||||||||||||||||||||||||
| 2601 | # 1 | ||||||||||||||||||||||||||||
| 2602 | |||||||||||||||||||||||||||||
| 2603 | =back | ||||||||||||||||||||||||||||
| 2604 | |||||||||||||||||||||||||||||
| 2605 | =cut | ||||||||||||||||||||||||||||
| 2606 | |||||||||||||||||||||||||||||
| 2607 | =head2 one | ||||||||||||||||||||||||||||
| 2608 | |||||||||||||||||||||||||||||
| 2609 | one(CodeRef $code) (Bool) | ||||||||||||||||||||||||||||
| 2610 | |||||||||||||||||||||||||||||
| 2611 | The one method returns true if only one of the elements in the array meet the | ||||||||||||||||||||||||||||
| 2612 | criteria set by the operand and rvalue. | ||||||||||||||||||||||||||||
| 2613 | |||||||||||||||||||||||||||||
| 2614 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2615 | |||||||||||||||||||||||||||||
| 2616 | =over 4 | ||||||||||||||||||||||||||||
| 2617 | |||||||||||||||||||||||||||||
| 2618 | =item one example 1 | ||||||||||||||||||||||||||||
| 2619 | |||||||||||||||||||||||||||||
| 2620 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2621 | |||||||||||||||||||||||||||||
| 2622 | my $one = $hash->one(sub { | ||||||||||||||||||||||||||||
| 2623 | $_ == 2 | ||||||||||||||||||||||||||||
| 2624 | }); | ||||||||||||||||||||||||||||
| 2625 | |||||||||||||||||||||||||||||
| 2626 | # 1 | ||||||||||||||||||||||||||||
| 2627 | |||||||||||||||||||||||||||||
| 2628 | =back | ||||||||||||||||||||||||||||
| 2629 | |||||||||||||||||||||||||||||
| 2630 | =over 4 | ||||||||||||||||||||||||||||
| 2631 | |||||||||||||||||||||||||||||
| 2632 | =item one example 2 | ||||||||||||||||||||||||||||
| 2633 | |||||||||||||||||||||||||||||
| 2634 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2635 | |||||||||||||||||||||||||||||
| 2636 | my $one = $hash->one(sub { | ||||||||||||||||||||||||||||
| 2637 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||
| 2638 | |||||||||||||||||||||||||||||
| 2639 | $value == 2 | ||||||||||||||||||||||||||||
| 2640 | }); | ||||||||||||||||||||||||||||
| 2641 | |||||||||||||||||||||||||||||
| 2642 | # 1 | ||||||||||||||||||||||||||||
| 2643 | |||||||||||||||||||||||||||||
| 2644 | =back | ||||||||||||||||||||||||||||
| 2645 | |||||||||||||||||||||||||||||
| 2646 | =cut | ||||||||||||||||||||||||||||
| 2647 | |||||||||||||||||||||||||||||
| 2648 | =head2 pairs | ||||||||||||||||||||||||||||
| 2649 | |||||||||||||||||||||||||||||
| 2650 | pairs() (ArrayRef) | ||||||||||||||||||||||||||||
| 2651 | |||||||||||||||||||||||||||||
| 2652 | The pairs method is an alias to the pairs_array method. This method can return | ||||||||||||||||||||||||||||
| 2653 | a list of values in list-context. | ||||||||||||||||||||||||||||
| 2654 | |||||||||||||||||||||||||||||
| 2655 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2656 | |||||||||||||||||||||||||||||
| 2657 | =over 4 | ||||||||||||||||||||||||||||
| 2658 | |||||||||||||||||||||||||||||
| 2659 | =item pairs example 1 | ||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||
| 2661 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2662 | |||||||||||||||||||||||||||||
| 2663 | my $pairs = $hash->pairs; | ||||||||||||||||||||||||||||
| 2664 | |||||||||||||||||||||||||||||
| 2665 | # [[1, 2], [3, 4], [5, 6], [7, 8]] | ||||||||||||||||||||||||||||
| 2666 | |||||||||||||||||||||||||||||
| 2667 | =back | ||||||||||||||||||||||||||||
| 2668 | |||||||||||||||||||||||||||||
| 2669 | =cut | ||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||
| 2671 | =head2 path | ||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||
| 2673 | path(Str $expr) (Any) | ||||||||||||||||||||||||||||
| 2674 | |||||||||||||||||||||||||||||
| 2675 | The path method traverses the data structure using the path expr provided, | ||||||||||||||||||||||||||||
| 2676 | returning the value found or undef. In list-context, this method returns a | ||||||||||||||||||||||||||||
| 2677 | tuple, i.e. the value found and boolean representing whether the match was | ||||||||||||||||||||||||||||
| 2678 | successful. | ||||||||||||||||||||||||||||
| 2679 | |||||||||||||||||||||||||||||
| 2680 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2681 | |||||||||||||||||||||||||||||
| 2682 | =over 4 | ||||||||||||||||||||||||||||
| 2683 | |||||||||||||||||||||||||||||
| 2684 | =item path example 1 | ||||||||||||||||||||||||||||
| 2685 | |||||||||||||||||||||||||||||
| 2686 | package main; | ||||||||||||||||||||||||||||
| 2687 | |||||||||||||||||||||||||||||
| 2688 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2689 | |||||||||||||||||||||||||||||
| 2690 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 2691 | |||||||||||||||||||||||||||||
| 2692 | my $path = $hash->path('/foo/bar'); | ||||||||||||||||||||||||||||
| 2693 | |||||||||||||||||||||||||||||
| 2694 | # "baz" | ||||||||||||||||||||||||||||
| 2695 | |||||||||||||||||||||||||||||
| 2696 | =back | ||||||||||||||||||||||||||||
| 2697 | |||||||||||||||||||||||||||||
| 2698 | =over 4 | ||||||||||||||||||||||||||||
| 2699 | |||||||||||||||||||||||||||||
| 2700 | =item path example 2 | ||||||||||||||||||||||||||||
| 2701 | |||||||||||||||||||||||||||||
| 2702 | package main; | ||||||||||||||||||||||||||||
| 2703 | |||||||||||||||||||||||||||||
| 2704 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||
| 2706 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 2707 | |||||||||||||||||||||||||||||
| 2708 | my $path = $hash->path('/bar/0'); | ||||||||||||||||||||||||||||
| 2709 | |||||||||||||||||||||||||||||
| 2710 | # "baz" | ||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||
| 2712 | =back | ||||||||||||||||||||||||||||
| 2713 | |||||||||||||||||||||||||||||
| 2714 | =over 4 | ||||||||||||||||||||||||||||
| 2715 | |||||||||||||||||||||||||||||
| 2716 | =item path example 3 | ||||||||||||||||||||||||||||
| 2717 | |||||||||||||||||||||||||||||
| 2718 | package main; | ||||||||||||||||||||||||||||
| 2719 | |||||||||||||||||||||||||||||
| 2720 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2721 | |||||||||||||||||||||||||||||
| 2722 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 2723 | |||||||||||||||||||||||||||||
| 2724 | my $path = $hash->path('/bar'); | ||||||||||||||||||||||||||||
| 2725 | |||||||||||||||||||||||||||||
| 2726 | # ["baz"] | ||||||||||||||||||||||||||||
| 2727 | |||||||||||||||||||||||||||||
| 2728 | =back | ||||||||||||||||||||||||||||
| 2729 | |||||||||||||||||||||||||||||
| 2730 | =over 4 | ||||||||||||||||||||||||||||
| 2731 | |||||||||||||||||||||||||||||
| 2732 | =item path example 4 | ||||||||||||||||||||||||||||
| 2733 | |||||||||||||||||||||||||||||
| 2734 | package main; | ||||||||||||||||||||||||||||
| 2735 | |||||||||||||||||||||||||||||
| 2736 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2737 | |||||||||||||||||||||||||||||
| 2738 | my $hash = Venus::Hash->new({'foo' => {'bar' => 'baz'},'bar' => ['baz']}); | ||||||||||||||||||||||||||||
| 2739 | |||||||||||||||||||||||||||||
| 2740 | my ($path, $exists) = $hash->path('/baz'); | ||||||||||||||||||||||||||||
| 2741 | |||||||||||||||||||||||||||||
| 2742 | # (undef, 0) | ||||||||||||||||||||||||||||
| 2743 | |||||||||||||||||||||||||||||
| 2744 | =back | ||||||||||||||||||||||||||||
| 2745 | |||||||||||||||||||||||||||||
| 2746 | =cut | ||||||||||||||||||||||||||||
| 2747 | |||||||||||||||||||||||||||||
| 2748 | =head2 random | ||||||||||||||||||||||||||||
| 2749 | |||||||||||||||||||||||||||||
| 2750 | random() (Any) | ||||||||||||||||||||||||||||
| 2751 | |||||||||||||||||||||||||||||
| 2752 | The random method returns a random element from the array. | ||||||||||||||||||||||||||||
| 2753 | |||||||||||||||||||||||||||||
| 2754 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2755 | |||||||||||||||||||||||||||||
| 2756 | =over 4 | ||||||||||||||||||||||||||||
| 2757 | |||||||||||||||||||||||||||||
| 2758 | =item random example 1 | ||||||||||||||||||||||||||||
| 2759 | |||||||||||||||||||||||||||||
| 2760 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2761 | |||||||||||||||||||||||||||||
| 2762 | my $random = $hash->random; | ||||||||||||||||||||||||||||
| 2763 | |||||||||||||||||||||||||||||
| 2764 | # 6 | ||||||||||||||||||||||||||||
| 2765 | |||||||||||||||||||||||||||||
| 2766 | # my $random = $hash->random; | ||||||||||||||||||||||||||||
| 2767 | |||||||||||||||||||||||||||||
| 2768 | # 4 | ||||||||||||||||||||||||||||
| 2769 | |||||||||||||||||||||||||||||
| 2770 | =back | ||||||||||||||||||||||||||||
| 2771 | |||||||||||||||||||||||||||||
| 2772 | =cut | ||||||||||||||||||||||||||||
| 2773 | |||||||||||||||||||||||||||||
| 2774 | =head2 reset | ||||||||||||||||||||||||||||
| 2775 | |||||||||||||||||||||||||||||
| 2776 | reset() (ArrayRef) | ||||||||||||||||||||||||||||
| 2777 | |||||||||||||||||||||||||||||
| 2778 | The reset method returns nullifies the value of each element in the hash. | ||||||||||||||||||||||||||||
| 2779 | |||||||||||||||||||||||||||||
| 2780 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2781 | |||||||||||||||||||||||||||||
| 2782 | =over 4 | ||||||||||||||||||||||||||||
| 2783 | |||||||||||||||||||||||||||||
| 2784 | =item reset example 1 | ||||||||||||||||||||||||||||
| 2785 | |||||||||||||||||||||||||||||
| 2786 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2787 | |||||||||||||||||||||||||||||
| 2788 | my $reset = $hash->reset; | ||||||||||||||||||||||||||||
| 2789 | |||||||||||||||||||||||||||||
| 2790 | # { 1 => undef, 3 => undef, 5 => undef, 7 => undef } | ||||||||||||||||||||||||||||
| 2791 | |||||||||||||||||||||||||||||
| 2792 | =back | ||||||||||||||||||||||||||||
| 2793 | |||||||||||||||||||||||||||||
| 2794 | =cut | ||||||||||||||||||||||||||||
| 2795 | |||||||||||||||||||||||||||||
| 2796 | =head2 reverse | ||||||||||||||||||||||||||||
| 2797 | |||||||||||||||||||||||||||||
| 2798 | reverse() (HashRef) | ||||||||||||||||||||||||||||
| 2799 | |||||||||||||||||||||||||||||
| 2800 | The reverse method returns a hash reference consisting of the hash's keys and | ||||||||||||||||||||||||||||
| 2801 | values inverted. Note, keys with undefined values will be dropped. | ||||||||||||||||||||||||||||
| 2802 | |||||||||||||||||||||||||||||
| 2803 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2804 | |||||||||||||||||||||||||||||
| 2805 | =over 4 | ||||||||||||||||||||||||||||
| 2806 | |||||||||||||||||||||||||||||
| 2807 | =item reverse example 1 | ||||||||||||||||||||||||||||
| 2808 | |||||||||||||||||||||||||||||
| 2809 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||
| 2811 | my $reverse = $hash->reverse; | ||||||||||||||||||||||||||||
| 2812 | |||||||||||||||||||||||||||||
| 2813 | # { 2 => 1, 4 => 3, 6 => 5, 8 => 7 } | ||||||||||||||||||||||||||||
| 2814 | |||||||||||||||||||||||||||||
| 2815 | =back | ||||||||||||||||||||||||||||
| 2816 | |||||||||||||||||||||||||||||
| 2817 | =cut | ||||||||||||||||||||||||||||
| 2818 | |||||||||||||||||||||||||||||
| 2819 | =head2 slice | ||||||||||||||||||||||||||||
| 2820 | |||||||||||||||||||||||||||||
| 2821 | slice(Str @keys) (ArrayRef) | ||||||||||||||||||||||||||||
| 2822 | |||||||||||||||||||||||||||||
| 2823 | The slice method returns an array reference of the values that correspond to | ||||||||||||||||||||||||||||
| 2824 | the key(s) specified in the arguments. | ||||||||||||||||||||||||||||
| 2825 | |||||||||||||||||||||||||||||
| 2826 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2827 | |||||||||||||||||||||||||||||
| 2828 | =over 4 | ||||||||||||||||||||||||||||
| 2829 | |||||||||||||||||||||||||||||
| 2830 | =item slice example 1 | ||||||||||||||||||||||||||||
| 2831 | |||||||||||||||||||||||||||||
| 2832 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2833 | |||||||||||||||||||||||||||||
| 2834 | my $slice = $hash->slice(1, 3); | ||||||||||||||||||||||||||||
| 2835 | |||||||||||||||||||||||||||||
| 2836 | # [2, 4] | ||||||||||||||||||||||||||||
| 2837 | |||||||||||||||||||||||||||||
| 2838 | =back | ||||||||||||||||||||||||||||
| 2839 | |||||||||||||||||||||||||||||
| 2840 | =cut | ||||||||||||||||||||||||||||
| 2841 | |||||||||||||||||||||||||||||
| 2842 | =head2 tv | ||||||||||||||||||||||||||||
| 2843 | |||||||||||||||||||||||||||||
| 2844 | tv(Any $arg) (Bool) | ||||||||||||||||||||||||||||
| 2845 | |||||||||||||||||||||||||||||
| 2846 | The tv method performs a I<"type-and-value-equal-to"> operation using argument | ||||||||||||||||||||||||||||
| 2847 | provided. | ||||||||||||||||||||||||||||
| 2848 | |||||||||||||||||||||||||||||
| 2849 | I<Since C<0.08>> | ||||||||||||||||||||||||||||
| 2850 | |||||||||||||||||||||||||||||
| 2851 | =over 4 | ||||||||||||||||||||||||||||
| 2852 | |||||||||||||||||||||||||||||
| 2853 | =item tv example 1 | ||||||||||||||||||||||||||||
| 2854 | |||||||||||||||||||||||||||||
| 2855 | package main; | ||||||||||||||||||||||||||||
| 2856 | |||||||||||||||||||||||||||||
| 2857 | use Venus::Array; | ||||||||||||||||||||||||||||
| 2858 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2859 | |||||||||||||||||||||||||||||
| 2860 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2861 | my $rvalue = Venus::Array->new; | ||||||||||||||||||||||||||||
| 2862 | |||||||||||||||||||||||||||||
| 2863 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2864 | |||||||||||||||||||||||||||||
| 2865 | # 0 | ||||||||||||||||||||||||||||
| 2866 | |||||||||||||||||||||||||||||
| 2867 | =back | ||||||||||||||||||||||||||||
| 2868 | |||||||||||||||||||||||||||||
| 2869 | =over 4 | ||||||||||||||||||||||||||||
| 2870 | |||||||||||||||||||||||||||||
| 2871 | =item tv example 2 | ||||||||||||||||||||||||||||
| 2872 | |||||||||||||||||||||||||||||
| 2873 | package main; | ||||||||||||||||||||||||||||
| 2874 | |||||||||||||||||||||||||||||
| 2875 | use Venus::Code; | ||||||||||||||||||||||||||||
| 2876 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2877 | |||||||||||||||||||||||||||||
| 2878 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2879 | my $rvalue = Venus::Code->new; | ||||||||||||||||||||||||||||
| 2880 | |||||||||||||||||||||||||||||
| 2881 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2882 | |||||||||||||||||||||||||||||
| 2883 | # 0 | ||||||||||||||||||||||||||||
| 2884 | |||||||||||||||||||||||||||||
| 2885 | =back | ||||||||||||||||||||||||||||
| 2886 | |||||||||||||||||||||||||||||
| 2887 | =over 4 | ||||||||||||||||||||||||||||
| 2888 | |||||||||||||||||||||||||||||
| 2889 | =item tv example 3 | ||||||||||||||||||||||||||||
| 2890 | |||||||||||||||||||||||||||||
| 2891 | package main; | ||||||||||||||||||||||||||||
| 2892 | |||||||||||||||||||||||||||||
| 2893 | use Venus::Float; | ||||||||||||||||||||||||||||
| 2894 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2895 | |||||||||||||||||||||||||||||
| 2896 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2897 | my $rvalue = Venus::Float->new; | ||||||||||||||||||||||||||||
| 2898 | |||||||||||||||||||||||||||||
| 2899 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2900 | |||||||||||||||||||||||||||||
| 2901 | # 0 | ||||||||||||||||||||||||||||
| 2902 | |||||||||||||||||||||||||||||
| 2903 | =back | ||||||||||||||||||||||||||||
| 2904 | |||||||||||||||||||||||||||||
| 2905 | =over 4 | ||||||||||||||||||||||||||||
| 2906 | |||||||||||||||||||||||||||||
| 2907 | =item tv example 4 | ||||||||||||||||||||||||||||
| 2908 | |||||||||||||||||||||||||||||
| 2909 | package main; | ||||||||||||||||||||||||||||
| 2910 | |||||||||||||||||||||||||||||
| 2911 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2912 | |||||||||||||||||||||||||||||
| 2913 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2914 | my $rvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2915 | |||||||||||||||||||||||||||||
| 2916 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2917 | |||||||||||||||||||||||||||||
| 2918 | # 1 | ||||||||||||||||||||||||||||
| 2919 | |||||||||||||||||||||||||||||
| 2920 | =back | ||||||||||||||||||||||||||||
| 2921 | |||||||||||||||||||||||||||||
| 2922 | =over 4 | ||||||||||||||||||||||||||||
| 2923 | |||||||||||||||||||||||||||||
| 2924 | =item tv example 5 | ||||||||||||||||||||||||||||
| 2925 | |||||||||||||||||||||||||||||
| 2926 | package main; | ||||||||||||||||||||||||||||
| 2927 | |||||||||||||||||||||||||||||
| 2928 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2929 | use Venus::Number; | ||||||||||||||||||||||||||||
| 2930 | |||||||||||||||||||||||||||||
| 2931 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2932 | my $rvalue = Venus::Number->new; | ||||||||||||||||||||||||||||
| 2933 | |||||||||||||||||||||||||||||
| 2934 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2935 | |||||||||||||||||||||||||||||
| 2936 | # 0 | ||||||||||||||||||||||||||||
| 2937 | |||||||||||||||||||||||||||||
| 2938 | =back | ||||||||||||||||||||||||||||
| 2939 | |||||||||||||||||||||||||||||
| 2940 | =over 4 | ||||||||||||||||||||||||||||
| 2941 | |||||||||||||||||||||||||||||
| 2942 | =item tv example 6 | ||||||||||||||||||||||||||||
| 2943 | |||||||||||||||||||||||||||||
| 2944 | package main; | ||||||||||||||||||||||||||||
| 2945 | |||||||||||||||||||||||||||||
| 2946 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2947 | use Venus::Regexp; | ||||||||||||||||||||||||||||
| 2948 | |||||||||||||||||||||||||||||
| 2949 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2950 | my $rvalue = Venus::Regexp->new; | ||||||||||||||||||||||||||||
| 2951 | |||||||||||||||||||||||||||||
| 2952 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2953 | |||||||||||||||||||||||||||||
| 2954 | # 0 | ||||||||||||||||||||||||||||
| 2955 | |||||||||||||||||||||||||||||
| 2956 | =back | ||||||||||||||||||||||||||||
| 2957 | |||||||||||||||||||||||||||||
| 2958 | =over 4 | ||||||||||||||||||||||||||||
| 2959 | |||||||||||||||||||||||||||||
| 2960 | =item tv example 7 | ||||||||||||||||||||||||||||
| 2961 | |||||||||||||||||||||||||||||
| 2962 | package main; | ||||||||||||||||||||||||||||
| 2963 | |||||||||||||||||||||||||||||
| 2964 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2965 | use Venus::Scalar; | ||||||||||||||||||||||||||||
| 2966 | |||||||||||||||||||||||||||||
| 2967 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2968 | my $rvalue = Venus::Scalar->new; | ||||||||||||||||||||||||||||
| 2969 | |||||||||||||||||||||||||||||
| 2970 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2971 | |||||||||||||||||||||||||||||
| 2972 | # 0 | ||||||||||||||||||||||||||||
| 2973 | |||||||||||||||||||||||||||||
| 2974 | =back | ||||||||||||||||||||||||||||
| 2975 | |||||||||||||||||||||||||||||
| 2976 | =over 4 | ||||||||||||||||||||||||||||
| 2977 | |||||||||||||||||||||||||||||
| 2978 | =item tv example 8 | ||||||||||||||||||||||||||||
| 2979 | |||||||||||||||||||||||||||||
| 2980 | package main; | ||||||||||||||||||||||||||||
| 2981 | |||||||||||||||||||||||||||||
| 2982 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 2983 | use Venus::String; | ||||||||||||||||||||||||||||
| 2984 | |||||||||||||||||||||||||||||
| 2985 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 2986 | my $rvalue = Venus::String->new; | ||||||||||||||||||||||||||||
| 2987 | |||||||||||||||||||||||||||||
| 2988 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 2989 | |||||||||||||||||||||||||||||
| 2990 | # 0 | ||||||||||||||||||||||||||||
| 2991 | |||||||||||||||||||||||||||||
| 2992 | =back | ||||||||||||||||||||||||||||
| 2993 | |||||||||||||||||||||||||||||
| 2994 | =over 4 | ||||||||||||||||||||||||||||
| 2995 | |||||||||||||||||||||||||||||
| 2996 | =item tv example 9 | ||||||||||||||||||||||||||||
| 2997 | |||||||||||||||||||||||||||||
| 2998 | package main; | ||||||||||||||||||||||||||||
| 2999 | |||||||||||||||||||||||||||||
| 3000 | use Venus::Hash; | ||||||||||||||||||||||||||||
| 3001 | use Venus::Undef; | ||||||||||||||||||||||||||||
| 3002 | |||||||||||||||||||||||||||||
| 3003 | my $lvalue = Venus::Hash->new; | ||||||||||||||||||||||||||||
| 3004 | my $rvalue = Venus::Undef->new; | ||||||||||||||||||||||||||||
| 3005 | |||||||||||||||||||||||||||||
| 3006 | my $result = $lvalue->tv($rvalue); | ||||||||||||||||||||||||||||
| 3007 | |||||||||||||||||||||||||||||
| 3008 | # 0 | ||||||||||||||||||||||||||||
| 3009 | |||||||||||||||||||||||||||||
| 3010 | =back | ||||||||||||||||||||||||||||
| 3011 | |||||||||||||||||||||||||||||
| 3012 | =cut | ||||||||||||||||||||||||||||