blob: eb090b876915772bdca54c71212d4f0440481d2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# NAME
Data::Perl - Base classes wrapping fundamental Perl data types.
# VERSION
version 0.002009
# SYNOPSIS
use Data::Perl;
my $array = array(1,2,3, qw/a b c/);
$array->count; # 6
my @elements = $array->grep(sub {/b/}); # (b)
my $hash = hash(a => 1, b => 2);
$hash->keys; # ('a', 'b');
my $number = number(5);
$number->add(10); # 15
my $string = string("foo\n");
$string->chomp; # return 1, chomps string
my $counter = counter();
$counter->inc; # counter is now 1
my $sub = code(sub { 'foo' });
$sub->execute; # returns 'foo'
$foo
# DESCRIPTION
Data::Perl is a collection of classes that wrap fundamental data types that
exist in Perl. These classes and methods as they exist today are an attempt to
mirror functionality provided by Moose's Native Traits. One important thing to
note is all classes currently do no validation on constructor input.
Data::Perl is a container class for the following classes:
- [Data::Perl::Collection::Hash](http://search.cpan.org/perldoc?Data::Perl::Collection::Hash)
- [Data::Perl::Collection::Array](http://search.cpan.org/perldoc?Data::Perl::Collection::Array)
- [Data::Perl::String](http://search.cpan.org/perldoc?Data::Perl::String)
- [Data::Perl::Number](http://search.cpan.org/perldoc?Data::Perl::Number)
- [Data::Perl::Counter](http://search.cpan.org/perldoc?Data::Perl::Counter)
- [Data::Perl::Bool](http://search.cpan.org/perldoc?Data::Perl::Bool)
- [Data::Perl::Code](http://search.cpan.org/perldoc?Data::Perl::Code)
# ALPHA API
The API provided by these modules is as of now considered alpha and undecided.
The API __WILL__ change. If you are writing code that you will not touch again
for years, do not use this until this warning is removed.
# PROVIDED FUNCTIONS
Data::Perl exports helper constructor functions to interface with the above classes:
- __hash(key, value, ...)__
Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args.
- __array(@args)__
Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values.
- __string($arg)__
Returns a Data::Perl::String object initialized with the optionally passed in scalar arg.
- __number($arg)__
Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg.
- __counter($arg)__
Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg.
- __bool($arg)__
Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg.
- __code($arg)__
Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg.
# THANKS
Much thanks to the [Moose](http://search.cpan.org/perldoc?Moose) team for their work with native traits, for which
much of this work is based.
# SEE ALSO
- [MooX::HandlesVia](http://search.cpan.org/perldoc?MooX::HandlesVia)
# AUTHOR
Matthew Phillips <mattp@cpan.org>
# COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Matthew Phillips <mattp@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
|