| 1 | package Data::Perl; | ||||||||||||||||||||
| 2 | 9 | $Data::Perl::VERSION = '0.002011'; | |||||||||||||||||||
| 3 | # ABSTRACT: Base classes wrapping fundamental Perl data types. | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 9 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 9 | require Exporter; | |||||||||||||||||||
| 7 | 9 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 8 | 9 | our @EXPORT = qw(hash array counter string code bool number); | |||||||||||||||||||
| 9 | } | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 9 | ▶ | use strictures 1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 9 | ▶ | use Data::Perl::Collection::Array; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 9 | ▶ | use Data::Perl::Collection::Hash; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 9 | ▶ | use Data::Perl::Code; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 9 | ▶ | use Data::Perl::Number; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 9 | ▶ | use Data::Perl::Bool; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 9 | ▶ | use Data::Perl::String; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 9 | ▶ | use Data::Perl::Counter; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 49 | ▶ | sub array { Data::Perl::Collection::Array->new(@_) } | ||||||||||||||||||
|
Subroutine
array: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 15 | ▶ | sub hash { Data::Perl::Collection::Hash->new(@_) } | ||||||||||||||||||
|
Subroutine
hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 5 | ▶ | sub code { Data::Perl::Code->new(shift||sub {}) } | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Subroutine
code: called CC=2 SCAR=7.2
Pod
documented
Condition66%2/3
shift() || sub {
}
MC/DC0%0/2
shift() || sub {
}
shift()
sub {
}
Truth table66%2/3
A || B
A= shift()B= sub {
}
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 4 | ▶ | sub number { Data::Perl::Number->new(shift||0) } | ||||||||||||||||||
|
Subroutine
number: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 4 | ▶ | sub bool { Data::Perl::Bool->new(shift||0) } | ||||||||||||||||||
|
Subroutine
bool: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 9 | ▶ | sub string { Data::Perl::String->new(shift||'') } | ||||||||||||||||||
|
Subroutine
string: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 5 | ▶ | sub counter { Data::Perl::Counter->new(shift||0) } | ||||||||||||||||||
|
Subroutine
counter: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 9 | 1; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =pod | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =encoding UTF-8 | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head1 NAME | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | Data::Perl - Base classes wrapping fundamental Perl data types. | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =head1 VERSION | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | version 0.002011 | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | use Data::Perl; | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | my $array = array(1,2,3, qw/a b c/); | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | $array->count; # 6 | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | my @elements = $array->grep(sub {/b/}); # (b) | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | my $hash = hash(a => 1, b => 2); | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | $hash->keys; # ('a', 'b'); | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | my $number = number(5); | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | $number->add(10); # 15 | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | my $string = string("foo\n"); | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | $string->chomp; # return 1, chomps string | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | my $counter = counter(); | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | $counter->inc; # counter is now 1 | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | my $sub = code(sub { 'foo' }); | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | $sub->execute; # returns 'foo' | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | $foo | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =head1 DESCRIPTION | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | Data::Perl is a collection of classes that wrap fundamental data types that | ||||||||||||||||||||
| 84 | exist in Perl. These classes and methods as they exist today are an attempt to | ||||||||||||||||||||
| 85 | mirror functionality provided by Moose's Native Traits. One important thing to | ||||||||||||||||||||
| 86 | note is all classes currently do no validation on constructor input. | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | Data::Perl is a container class for the following classes: | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =over 4 | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =item * L<Data::Perl::Collection::Hash> | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =item * L<Data::Perl::Collection::Array> | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =item * L<Data::Perl::String> | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =item * L<Data::Perl::Number> | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =item * L<Data::Perl::Counter> | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =item * L<Data::Perl::Bool> | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =item * L<Data::Perl::Code> | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =back | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =head1 ALPHA API | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | The API provided by these modules is as of now considered alpha and undecided. | ||||||||||||||||||||
| 111 | The API B<WILL> change. If you are writing code that you will not touch again | ||||||||||||||||||||
| 112 | for years, do not use this until this warning is removed. | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =head1 PROVIDED FUNCTIONS | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | Data::Perl exports helper constructor functions to interface with the above classes: | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =over 4 | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =item * B<hash(key, value, ...)> | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args. | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | =item * B<array(@args)> | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values. | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =item * B<string($arg)> | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | Returns a Data::Perl::String object initialized with the optionally passed in scalar arg. | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | =item * B<number($arg)> | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg. | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | =item * B<counter($arg)> | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg. | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | =item * B<bool($arg)> | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg. | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =item * B<code($arg)> | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg. | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | =back | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | =head1 THANKS | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | Much thanks to the L<Moose> team for their work with native traits, for which | ||||||||||||||||||||
| 153 | much of this work is based. | ||||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | =head1 SEE ALSO | ||||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | =over 4 | ||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | =item * L<MooX::HandlesVia> | ||||||||||||||||||||
| 160 | |||||||||||||||||||||
| 161 | =back | ||||||||||||||||||||
| 162 | |||||||||||||||||||||
| 163 | =head1 AUTHOR | ||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | Matthew Phillips <mattp@cpan.org> | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | =head1 MAINTAINER | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | Toby Inkster <tobyink@cpan.org> since version 0.002010. | ||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | =head1 CONTRIBUTORS | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | =for stopwords Graham Knop Jon Portnoy kristof.pap@gmail.com Matt Phillips Toby Inkster | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | =over 4 | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | =item * | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | Graham Knop <haarg@haarg.org> | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | =item * | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | Jon Portnoy <avenj@cobaltirc.org> | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | =item * | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | kristof.pap@gmail.com <kristof.pap@gmail.com> | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | =item * | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | Matt Phillips <mattp@cpan.org> | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | =item * | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | Toby Inkster <tobyink@cpan.org> | ||||||||||||||||||||
| 196 | |||||||||||||||||||||
| 197 | =back | ||||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | This software is copyright (c) 2020 by Matthew Phillips <mattp@cpan.org>. | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 204 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | =cut | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | __END__ | ||||||||||||||||||||