line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Teddy; |
2
|
|
|
|
|
|
|
# For we doeth darke magiks. |
3
|
|
|
|
|
|
|
#use strict; |
4
|
|
|
|
|
|
|
#use warnings; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#~ use Devel::Comments; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 1.002003; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#=========# EXTERNAL FUNCTION |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# use Acme::Teddy qw( your $user @symbols ); # calls import() |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Purpose : Exports all arguments to caller. |
15
|
|
|
|
|
|
|
# Parms : $pkg : Provided by use() |
16
|
|
|
|
|
|
|
# : @imports : Anything |
17
|
|
|
|
|
|
|
# Writes : Caller's symbol table. |
18
|
|
|
|
|
|
|
# Throws : When passed something bizzare, maybe. |
19
|
|
|
|
|
|
|
# See also : Exporter::Heavy::heavy_export() |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# Exports almost *anything* passed in. |
22
|
|
|
|
|
|
|
# Note that this module defines very little, |
23
|
|
|
|
|
|
|
# so you need to define stuff to export it. |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
sub import { |
26
|
3
|
|
|
3
|
|
27
|
my $pkg = shift; |
27
|
3
|
|
|
|
|
6
|
my @imports = @_; # anything you like, baby |
28
|
3
|
|
|
|
|
12
|
my $callpkg = caller(1); |
29
|
3
|
|
|
|
|
4
|
my $type ; |
30
|
|
|
|
|
|
|
my $sym ; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
### $callpkg |
33
|
|
|
|
|
|
|
### $pkg |
34
|
|
|
|
|
|
|
### @imports |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Ripped from Exporter::Heavy::heavy_export() |
37
|
3
|
|
|
|
|
43
|
foreach $sym (@imports) { |
38
|
|
|
|
|
|
|
# shortcut for the common case of no type character |
39
|
2
|
100
|
|
|
|
11
|
(*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"}, next) |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
40
|
|
|
|
|
|
|
unless $sym =~ s/^(\W)//; |
41
|
1
|
|
|
|
|
3
|
$type = $1; |
42
|
1
|
|
|
|
|
27
|
*{"${callpkg}::$sym"} = |
|
0
|
|
|
|
|
0
|
|
43
|
1
|
|
|
|
|
3
|
$type eq '&' ? \&{"${pkg}::$sym"} : |
44
|
0
|
|
|
|
|
0
|
$type eq '$' ? \${"${pkg}::$sym"} : |
45
|
0
|
|
|
|
|
0
|
$type eq '@' ? \@{"${pkg}::$sym"} : |
46
|
0
|
|
|
|
|
0
|
$type eq '%' ? \%{"${pkg}::$sym"} : |
47
|
1
|
0
|
|
|
|
5
|
$type eq '*' ? *{"${pkg}::$sym"} : |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
die "$pkg: Can't export symbol: $type$sym\n", $!; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
}; ## import |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# For we enter thee sonne. |
53
|
3
|
|
|
3
|
|
52140
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
131
|
|
54
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1274
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#=========# CLASS METHOD |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
# my $bear = Acme::Teddy->new(); |
59
|
|
|
|
|
|
|
# my $bear = Acme::Teddy->new({ -a => 'x' }); |
60
|
|
|
|
|
|
|
# my $bear = Acme::Teddy->new([ 1, 2, 3, 4 ]); |
61
|
|
|
|
|
|
|
# my $bear = Acme::Teddy->new( {}, @some_data ); |
62
|
|
|
|
|
|
|
# |
63
|
|
|
|
|
|
|
# Purpose : Dummy constructor |
64
|
|
|
|
|
|
|
# Parms : $class : Any subclass of this class |
65
|
|
|
|
|
|
|
# : $self : Any reference |
66
|
|
|
|
|
|
|
# : @init : All remaining args |
67
|
|
|
|
|
|
|
# Returns : $self |
68
|
|
|
|
|
|
|
# Invokes : init() |
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
# If invoked with $class only, |
71
|
|
|
|
|
|
|
# blesses an empty hashref and calls init() with no args. |
72
|
|
|
|
|
|
|
# |
73
|
|
|
|
|
|
|
# If invoked with $class and a reference, |
74
|
|
|
|
|
|
|
# blesses the reference and calls init() with any remaining args. |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
sub new { |
77
|
1
|
|
|
1
|
1
|
13
|
my $class = shift; |
78
|
1
|
|
50
|
|
|
7
|
my $self = shift || {}; # default: hashref |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
3
|
bless ($self => $class); |
81
|
1
|
|
|
|
|
6
|
$self->init(@_); |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
3
|
return $self; |
84
|
|
|
|
|
|
|
}; ## new |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
87
|
|
|
|
|
|
|
# |
88
|
|
|
|
|
|
|
# $obj->init(@_); # initialize object |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
# Purpose : Discard any extra arguments to new(). |
91
|
|
|
|
|
|
|
# Returns : $self |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# This is a placeholder method. You might want to override it in a subclass. |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
sub init { |
96
|
1
|
|
|
1
|
1
|
2
|
return shift; |
97
|
|
|
|
|
|
|
}; ## init |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#=========# INTERNAL FUNCTION |
100
|
|
|
|
|
|
|
# |
101
|
|
|
|
|
|
|
# _egg(); # short |
102
|
|
|
|
|
|
|
# |
103
|
|
|
|
|
|
|
# Purpose : Bunny rabbits have Easter eggs. Why not Teddy? |
104
|
|
|
|
|
|
|
# |
105
|
|
|
|
|
|
|
# This function is undocumented, because it's mine. |
106
|
|
|
|
|
|
|
# |
107
|
|
|
|
|
|
|
sub _egg { |
108
|
0
|
|
|
0
|
|
|
my @parms = @_; |
109
|
0
|
|
|
|
|
|
my $product = 1; |
110
|
0
|
|
|
|
|
|
my $prepend = __PACKAGE__ . q{: }; |
111
|
0
|
|
|
|
|
|
my $message = $prepend; |
112
|
0
|
|
|
|
|
|
my $crack = qr/crack/; |
113
|
0
|
|
|
|
|
|
my $drop = qr/drop/; |
114
|
0
|
|
|
|
|
|
my $integer = qr/^\d$/; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
foreach (@parms) { |
117
|
0
|
0
|
|
|
|
|
if (/$crack/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
warn $prepend, q{Crack! }, $!; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
elsif (/$drop/) { |
121
|
0
|
|
|
|
|
|
die $prepend, q{~~=@__.! }, $!; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
elsif (/$integer/) { |
124
|
0
|
|
|
|
|
|
$product *= $_; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
else { |
127
|
0
|
|
|
|
|
|
$message .= $_; |
128
|
|
|
|
|
|
|
}; ## if-else tree |
129
|
|
|
|
|
|
|
}; ## foreach |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
print $message, qq{\n}; |
132
|
0
|
|
|
|
|
|
return $product; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
}; ## _egg |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
## END MODULE |
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
#============================================================================# |
140
|
|
|
|
|
|
|
__END__ |