1Validation::Class::ListUisnegr(3C)ontributed Perl DocumeVnatlaitdiaotnion::Class::Listing(3)
2
3
4
6 Validation::Class::Listing - Generic Container Class for an Array
7 Reference
8
10 version 7.900057
11
13 use Validation::Class::Listing;
14
15 my $foos = Validation::Class::Listing->new;
16
17 $foos->add('foo');
18 $foos->add('bar', 'baz');
19
20 print $foos->count; # 3 objects
21
23 Validation::Class::Listing is a container class that provides general-
24 purpose functionality for arrayref objects.
25
27 new
28 my $self = Validation::Class::Listing->new;
29
30 add
31 $self = $self->add('foo', 'bar');
32
33 clear
34 $self = $self->clear;
35
36 count
37 my $count = $self->count;
38
39 delete
40 $value = $self->delete($index);
41
42 defined
43 $true if $self->defined($name) # defined
44
45 each
46 $self = $self->each(sub{
47
48 my ($index, $value) = @_;
49
50 });
51
52 first
53 my $value = $self->first;
54
55 get
56 my $value = $self->get($index); # i.e. $self->[$index]
57
58 grep
59 $new_list = $self->grep(qr/update_/);
60
61 has
62 $true if $self->has($name) # defined
63
64 iterator
65 my $next = $self->iterator();
66
67 # defaults to iterating by keys but accepts sort, rsort, nsort, or rnsort
68 # e.g. $self->iterator('sort', sub{ (shift) cmp (shift) });
69
70 while (my $item = $next->()) {
71 # do something with $item
72 }
73
74 join
75 my $string = $self->join($delimiter);
76
77 last
78 my $value = $self->last;
79
80 list
81 my @list = $self->list;
82
83 nsort
84 my @list = $self->nsort;
85
86 pairs
87 my @pairs = $self->pairs;
88 # or filter using $self->pairs('grep', $regexp);
89
90 foreach my $pair (@pairs) {
91 # $pair->{index} is $pair->{value};
92 }
93
94 rnsort
95 my @list = $self->rnsort;
96
97 rsort
98 my @list = $self->rsort;
99
100 sort
101 my @list = $self->sort(sub{...});
102
103 unique
104 my @list = $self->unique();
105
107 Al Newkirk <anewkirk@ana.io>
108
110 This software is copyright (c) 2011 by Al Newkirk.
111
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114
115
116
117perl v5.30.1 2020-01-30 Validation::Class::Listing(3)