Validation::Class::Listing(3pm)

Validation::Class::Listing3pm

Generic container class for an array reference

Usage

    use Validation::Class::Listing;
    my $foos = Validation::Class::Listing->new;
    $foos->add('foo');
    $foos->add('bar', 'baz');
    print $foos->count; # 3 objects

Version

version 7.900059

Overview

Validation::Class::Listing is a container class that provides general-purpose functionality for arrayref objects.

Methods

new

    my $self = Validation::Class::Listing->new;

add

    $self = $self->add('foo', 'bar');

clear

    $self = $self->clear;

count

    my $count = $self->count;

delete

    $value = $self->delete($index);

defined

    $true if $self->defined($name) # defined

each

    $self = $self->each(sub{
        my ($index, $value) = @_;
    });

first

    my $value = $self->first;

get

    my $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
    }

join

    my $string = $self->join($delimiter);

last

    my $value = $self->last;

list

    my @list = $self->list;

nsort

    my @list = $self->nsort;

pairs

    my @pairs = $self->pairs;
    # or filter using $self->pairs('grep', $regexp);
    foreach my $pair (@pairs) {
        # $pair->{index} is $pair->{value};
    }

rnsort

    my @list = $self->rnsort;

rsort

    my @list = $self->rsort;

sort

    my @list = $self->sort(sub{...});

unique

    my @list = $self->unique();

Releases

6 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8
  2. 9
  3. 10–11
  4. 12
  5. 13

Author

Al Newkirk <[email protected]>

From libvalidation-class-perl 7.900059-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.