| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::WalkMethods; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26011
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
42
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Acme::WalkMethods - Develope the wrong way |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Your::Package; |
|
13
|
|
|
|
|
|
|
use base qw(Acme::WalkMethods); |
|
14
|
|
|
|
|
|
|
1; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# in a script not far away |
|
17
|
|
|
|
|
|
|
use Your::Package; |
|
18
|
|
|
|
|
|
|
my $object = Your::Package->new(); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$object->foo('5'); |
|
21
|
|
|
|
|
|
|
$object->bar('5'); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
print "Foo:" . $object->foo() . "\n" if $object->foo(); |
|
24
|
|
|
|
|
|
|
print "Bar:" . $object->bar() . "\n" if $object->bar(); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# From command line: |
|
27
|
|
|
|
|
|
|
>perl .pl |
|
28
|
|
|
|
|
|
|
Can I create bar as a method (y/N)?y |
|
29
|
|
|
|
|
|
|
Can I create foo as a method (y/N)?y |
|
30
|
|
|
|
|
|
|
Foo: 5 |
|
31
|
|
|
|
|
|
|
Bar: 5 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Or: |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
>perl .pl |
|
36
|
|
|
|
|
|
|
Can I create bar as a method (y/N)?y |
|
37
|
|
|
|
|
|
|
Can I create foo as a method (y/N)?n |
|
38
|
|
|
|
|
|
|
Bar: 5 |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Want to start developing the wrong way? |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Use this module as your base! |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Write all your end code first and decide |
|
47
|
|
|
|
|
|
|
each time you run your code which methods you want |
|
48
|
|
|
|
|
|
|
to be able to store data into. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 WHY? |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Because acme told me to, this mess has been brought |
|
53
|
|
|
|
|
|
|
to you by the letter L and the colour Orange. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 PROBLEMS? |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Only if someone finds a 'good' use for this module. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHOR |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Leo Lapworth, LLAP@cuckoo.org |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
1
|
|
|
1
|
|
6
|
use vars qw ( $AUTOLOAD $VERSION ); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
300
|
|
|
66
|
|
|
|
|
|
|
$VERSION = '0.1'; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
|
69
|
0
|
|
|
0
|
0
|
|
my ($proto,$conf) = @_; |
|
70
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
|
71
|
0
|
|
|
|
|
|
my $self = {}; |
|
72
|
0
|
|
|
|
|
|
bless($self, $class); |
|
73
|
0
|
|
|
|
|
|
return $self; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
77
|
0
|
|
|
0
|
|
|
my $name = $AUTOLOAD; |
|
78
|
0
|
|
|
|
|
|
$name =~ s/.*://; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
|
if(!defined $_[0]->{$name} && defined $_[1]) { |
|
81
|
0
|
|
|
|
|
|
print "Can I create '$name' as a method (y/N)?"; |
|
82
|
0
|
|
|
|
|
|
my $input = ; |
|
83
|
0
|
|
|
|
|
|
chomp($input); |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
unless($input eq 'y') { |
|
86
|
0
|
|
|
|
|
|
return undef; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if($_[1]) { |
|
91
|
|
|
|
|
|
|
# set it |
|
92
|
0
|
|
|
|
|
|
$_[0]->{$name} = $_[1]; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Return it |
|
96
|
0
|
0
|
|
|
|
|
return $_[0]->{$name} if defined $_[0]->{$name}; |
|
97
|
0
|
|
|
|
|
|
return undef; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
|
|
sub DESTROY {}; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |