line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package scalar::object; |
2
|
|
|
|
|
|
|
# use 5.010; -- works ok on 5.8 |
3
|
1
|
|
|
1
|
|
22185
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
1664
|
use overload (); |
|
1
|
|
|
|
|
1148
|
|
|
1
|
|
|
|
|
24
|
|
6
|
1
|
|
|
1
|
|
639
|
use Class::Builtin::Scalar; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
243
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $class = __PACKAGE__; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
1
|
|
|
1
|
|
69
|
$^H{$class} = 1; |
12
|
|
|
|
|
|
|
overload::constant( |
13
|
|
|
|
|
|
|
map { |
14
|
1
|
|
|
2
|
|
4
|
$_ => sub { Class::Builtin::Scalar->new(shift) } |
|
2
|
|
|
|
|
108
|
|
15
|
4
|
|
|
|
|
26
|
} qw/integer float binary q/ |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub unimport { |
20
|
0
|
|
|
0
|
|
|
$^H{$class} = 0; |
21
|
0
|
|
|
|
|
|
overload::remove_constant( '', qw/integer float binary q qr/ ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub in_effect { |
25
|
0
|
|
0
|
0
|
0
|
|
my $level = shift || 0; |
26
|
0
|
|
|
|
|
|
my $hinthash = ( caller($level) )[10]; |
27
|
0
|
|
|
|
|
|
return $hinthash->{$class}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
scalar::object - automagically turns scalar constants into objects |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 VERSION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$Id: object.pm,v 0.2 2009/06/21 15:44:41 dankogai Exp $ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
use scalar::objects; |
44
|
|
|
|
|
|
|
my $o = 42; # $o is a Class::Builtin::Scalar object |
45
|
|
|
|
|
|
|
print 42->length # 2; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
my $n = 1; # $n is an ordinary scalar |
48
|
|
|
|
|
|
|
print $n->length # dies |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 EXPORT |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
None. But see L |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 TODO |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This section itself is to do :) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SEE ALSO |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
L, L |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Dan Kogai, C<< >> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L, L |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Copyright 2009 Dan Kogai, all rights reserved. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
75
|
|
|
|
|
|
|
under the same terms as Perl itself. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |