line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Builtin; |
2
|
4
|
|
|
4
|
|
27737
|
use 5.008001; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
161
|
|
3
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
121
|
|
4
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
340
|
|
5
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%02d", q$Revision: 0.5 $ =~ /(\d+)/g; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
14707
|
use Class::Builtin::Scalar (); |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
166
|
|
8
|
4
|
|
|
4
|
|
4896
|
use Class::Builtin::Array (); |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
116
|
|
9
|
4
|
|
|
4
|
|
6588
|
use Class::Builtin::Hash (); |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
101
|
|
10
|
4
|
|
|
4
|
|
7243
|
use Data::Dumper (); |
|
4
|
|
|
|
|
52987
|
|
|
4
|
|
|
|
|
137
|
|
11
|
4
|
|
|
4
|
|
53
|
use Scalar::Util (); |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
120
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
14
|
4
|
|
|
4
|
|
26
|
use base qw/Exporter/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1989
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw(OO); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our %new = ( |
19
|
|
|
|
|
|
|
'' => __PACKAGE__ . '::Scalar', |
20
|
|
|
|
|
|
|
map { $_ => __PACKAGE__ . '::' . ucfirst( lc($_) ) } qw/ARRAY HASH/ |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
85
|
|
|
85
|
0
|
120
|
my $class = shift; |
25
|
85
|
|
|
|
|
102
|
my $obj = shift; |
26
|
85
|
100
|
|
|
|
334
|
my $new = $new{ ref $obj } or return $obj; |
27
|
71
|
|
|
|
|
266
|
$new->new($obj); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
# to make $a->sort happy |
32
|
|
|
|
|
|
|
if (my $pkg = caller){ |
33
|
4
|
|
|
4
|
|
33
|
no strict 'refs'; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
159
|
|
34
|
4
|
|
|
4
|
|
23
|
no warnings 'once'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
842
|
|
35
|
|
|
|
|
|
|
${$pkg . '::a'} = undef; |
36
|
|
|
|
|
|
|
${$pkg . '::b'} = undef; |
37
|
|
|
|
|
|
|
${$pkg . '::_'} = undef; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
13
|
|
|
13
|
0
|
577
|
sub OO { __PACKAGE__->new(@_) } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; # End of Class::Builtin |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Class::Builtin - Scalar/Array/Hash as objects |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 VERSION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$Id: Builtin.pm,v 0.5 2011/05/21 21:40:47 dankogai Exp $ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Quick summary of what the module does. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Perhaps a little code snippet. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use Class::Builtin; |
60
|
|
|
|
|
|
|
my $scalar = OO('perl'); |
61
|
|
|
|
|
|
|
my $array = OO([0..9]); |
62
|
|
|
|
|
|
|
my $hash = OO({key=>'value'}); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
print $scalar->length; # 4; |
65
|
|
|
|
|
|
|
print $array->length; # 10; |
66
|
|
|
|
|
|
|
print $hash->keys->[0] # 'key' |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 EXPORT |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
C |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 FUNCTIONS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
See |
75
|
|
|
|
|
|
|
L, |
76
|
|
|
|
|
|
|
L, |
77
|
|
|
|
|
|
|
and L |
78
|
|
|
|
|
|
|
for details. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
To check what methods the object has, simply try |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
print $o->methods->join("\n"); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Dan Kogai, C<< >> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 BUGS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
91
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at |
92
|
|
|
|
|
|
|
L. I |
93
|
|
|
|
|
|
|
will be notified, and then you'll automatically be notified of |
94
|
|
|
|
|
|
|
progress on your bug as I make changes. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SUPPORT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
perldoc Class::Builtin |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
You can also look for information at: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * CPAN Ratings |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * Search CPAN |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L, L, L L |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Copyright 2009 Dan Kogai, all rights reserved. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
133
|
|
|
|
|
|
|
under the same terms as Perl itself. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |