![]() |
![]()
| ![]() |
![]()
NAMEValidation::Class::Mapping - Generic Container Class for a Hash Reference VERSIONversion 7.900057 SYNOPSISuse Validation::Class::Mapping; my $foos = Validation::Class::Mapping->new; $foos->add(foo => 'one foo'); $foos->add(bar => 'one bar'); print $foos->count; # 2 objects DESCRIPTIONValidation::Class::Mapping is a container class that provides general-purpose functionality for hashref objects. METHODSnewmy $self = Validation::Class::Mapping->new; add$self = $self->add(foo => 1, bar => 2); clear$self = $self->clear; countmy $count = $self->count; delete$value = $self->delete($name); defined$true if $self->defined($name) # defined each$self = $self->each(sub{ my ($key, $value) = @_; }); exists$true if $self->exists($name) # exists getmy $value = $self->get($name); # i.e. $self->{$name} grep$new_list = $self->grep(qr/update_/); has$true if $self->has($name) # defined or exists hashmy $hash = $self->hash; iteratormy $next = $self->iterator(); # defaults to iterating by keys but accepts: sort, rsort, nsort, or rnsort # e.g. $self->iterator('sort', sub{ (shift) cmp (shift) }); while (my $item = $next->()) { # do something with $item (value) } keysmy @keys = $self->keys; listmy %hash = $self->list; merge$self->merge($hashref); nsortmy @keys = $self->nsort; pairsmy @pairs = $self->pairs; # or filter using $self->pairs('grep', $regexp); foreach my $pair (@pairs) { # $pair->{key} is $pair->{value}; } rmerge$self->rmerge($hashref); rnsortmy @keys = $self->rnsort; rsortmy @keys = $self->rsort; sortmy @keys = $self->sort(sub{...}); valuesmy @values = $self->values; AUTHORAl Newkirk <anewkirk@ana.io> COPYRIGHT AND LICENSEThis software is copyright (c) 2011 by Al Newkirk. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|