|
NAMEValidation::Class::Listing - Generic Container Class for an Array Reference VERSIONversion 7.900057 SYNOPSIS use Validation::Class::Listing;
my $foos = Validation::Class::Listing->new;
$foos->add('foo');
$foos->add('bar', 'baz');
print $foos->count; # 3 objects
DESCRIPTIONValidation::Class::Listing is a container class that provides general-purpose functionality for arrayref objects. METHODSnewmy $self = Validation::Class::Listing->new; add $self = $self->add('foo', 'bar');
clear$self = $self->clear; countmy $count = $self->count; delete$value = $self->delete($index); defined$true if $self->defined($name) # defined each $self = $self->each(sub{
my ($index, $value) = @_;
});
firstmy $value = $self->first; getmy $value = $self->get($index); # i.e. $self->[$index] grep$new_list = $self->grep(qr/update_/); has$true if $self->has($name) # defined iterator my $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
}
joinmy $string = $self->join($delimiter); lastmy $value = $self->last; listmy @list = $self->list; nsortmy @list = $self->nsort; pairs my @pairs = $self->pairs;
# or filter using $self->pairs('grep', $regexp);
foreach my $pair (@pairs) {
# $pair->{index} is $pair->{value};
}
rnsortmy @list = $self->rnsort; rsortmy @list = $self->rsort; sort my @list = $self->sort(sub{...});
uniquemy @list = $self->unique(); 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.
|