1Data::Perl(3) User Contributed Perl Documentation Data::Perl(3)
2
3
4
6 Data::Perl - Base classes wrapping fundamental Perl data types.
7
9 version 0.002011
10
12 use Data::Perl;
13
14 my $array = array(1,2,3, qw/a b c/);
15
16 $array->count; # 6
17
18 my @elements = $array->grep(sub {/b/}); # (b)
19
20 my $hash = hash(a => 1, b => 2);
21
22 $hash->keys; # ('a', 'b');
23
24 my $number = number(5);
25
26 $number->add(10); # 15
27
28 my $string = string("foo\n");
29
30 $string->chomp; # return 1, chomps string
31
32 my $counter = counter();
33
34 $counter->inc; # counter is now 1
35
36 my $sub = code(sub { 'foo' });
37
38 $sub->execute; # returns 'foo'
39
40 $foo
41
43 Data::Perl is a collection of classes that wrap fundamental data types
44 that exist in Perl. These classes and methods as they exist today are
45 an attempt to mirror functionality provided by Moose's Native Traits.
46 One important thing to note is all classes currently do no validation
47 on constructor input.
48
49 Data::Perl is a container class for the following classes:
50
51 · Data::Perl::Collection::Hash
52
53 · Data::Perl::Collection::Array
54
55 · Data::Perl::String
56
57 · Data::Perl::Number
58
59 · Data::Perl::Counter
60
61 · Data::Perl::Bool
62
63 · Data::Perl::Code
64
66 The API provided by these modules is as of now considered alpha and
67 undecided. The API WILL change. If you are writing code that you will
68 not touch again for years, do not use this until this warning is
69 removed.
70
72 Data::Perl exports helper constructor functions to interface with the
73 above classes:
74
75 · hash(key, value, ...)
76
77 Returns a Data::Perl::Collection::Hash object initialized with the
78 optionally passed in key/value args.
79
80 · array(@args)
81
82 Returns a Data::Perl::Collection::Array object initialized with the
83 optionally passed in values.
84
85 · string($arg)
86
87 Returns a Data::Perl::String object initialized with the optionally
88 passed in scalar arg.
89
90 · number($arg)
91
92 Returns a Data::Perl::Number object initialized with the optionally
93 passed in scalar arg.
94
95 · counter($arg)
96
97 Returns a Data::Perl::Counter object initialized with the
98 optionally passed in scalar arg.
99
100 · bool($arg)
101
102 Returns a Data::Perl::Bool object initialized with the truth value
103 of the passed in scalar arg.
104
105 · code($arg)
106
107 Returns a Data::Perl::Code object initialized with the optionally
108 passed in scalar coderef as an arg.
109
111 Much thanks to the Moose team for their work with native traits, for
112 which much of this work is based.
113
115 · MooX::HandlesVia
116
118 Matthew Phillips <mattp@cpan.org>
119
121 Toby Inkster <tobyink@cpan.org> since version 0.002010.
122
124 · Graham Knop <haarg@haarg.org>
125
126 · Jon Portnoy <avenj@cobaltirc.org>
127
128 · kristof.pap@gmail.com <kristof.pap@gmail.com>
129
130 · Matt Phillips <mattp@cpan.org>
131
132 · Toby Inkster <tobyink@cpan.org>
133
135 This software is copyright (c) 2020 by Matthew Phillips
136 <mattp@cpan.org>.
137
138 This is free software; you can redistribute it and/or modify it under
139 the same terms as the Perl 5 programming language system itself.
140
141
142
143perl v5.32.0 2020-07-28 Data::Perl(3)