| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::Tao; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
8257
|
use constant 1.01; |
|
|
4
|
|
|
|
|
151
|
|
|
|
4
|
|
|
|
|
122
|
|
|
4
|
4
|
|
|
4
|
|
22
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
166
|
|
|
5
|
4
|
|
|
4
|
|
40
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
117
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
20
|
use vars qw(@messages $VERSION); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
2228
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = 0.03; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@messages = ( |
|
12
|
|
|
|
|
|
|
qq( |
|
13
|
|
|
|
|
|
|
The Tao doesn't take sides; |
|
14
|
|
|
|
|
|
|
it gives birth to both wins and losses. |
|
15
|
|
|
|
|
|
|
), |
|
16
|
|
|
|
|
|
|
qq( |
|
17
|
|
|
|
|
|
|
A novice asked the master: "I have a program that sometimes runs and |
|
18
|
|
|
|
|
|
|
sometimes aborts. I have followed the rules of programming, yet I am totally |
|
19
|
|
|
|
|
|
|
baffled. What is the reason for this?" |
|
20
|
|
|
|
|
|
|
The master replied: "You are confused because you do not understand |
|
21
|
|
|
|
|
|
|
the Tao. Only a fool expects rational behavior from his fellow humans. Why |
|
22
|
|
|
|
|
|
|
do you expect it from a machine that humans have constructed? Computers |
|
23
|
|
|
|
|
|
|
simulate determinism; only the Tao is perfect. |
|
24
|
|
|
|
|
|
|
The rules of programming are transitory; only the Tao is eternal. |
|
25
|
|
|
|
|
|
|
Therefore you must contemplate the Tao before you receive enlightenment." |
|
26
|
|
|
|
|
|
|
"But how will I know when I have received enlightenment?" asked the |
|
27
|
|
|
|
|
|
|
novice. |
|
28
|
|
|
|
|
|
|
"Your program will then run correctly," replied the master. |
|
29
|
|
|
|
|
|
|
-- Geoffrey James, "The Tao of Programming" |
|
30
|
|
|
|
|
|
|
), |
|
31
|
|
|
|
|
|
|
qq( |
|
32
|
|
|
|
|
|
|
In the beginning was the Tao. The Tao gave birth to Space and Time. |
|
33
|
|
|
|
|
|
|
Therefore, Space and Time are the Yin and Yang of programming. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Programmers that do not comprehend the Tao are always running out of |
|
36
|
|
|
|
|
|
|
time and space for their programs. Programmers that comprehend the Tao always |
|
37
|
|
|
|
|
|
|
have enough time and space to accomplish their goals. |
|
38
|
|
|
|
|
|
|
How could it be otherwise? |
|
39
|
|
|
|
|
|
|
-- Geoffrey James, "The Tao of Programming" |
|
40
|
|
|
|
|
|
|
), |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub import { |
|
44
|
5
|
|
|
5
|
|
70
|
my $class = shift; |
|
45
|
5
|
100
|
|
|
|
18
|
if(@_) { |
|
46
|
2
|
|
|
|
|
6
|
my($pkg, $file, $line) = caller; |
|
47
|
2
|
|
|
|
|
3
|
foreach my $v (@_) { |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# this is based on the perl 5.6.1 perldoc (perldoc constant) |
|
50
|
|
|
|
|
|
|
# not sure why we have to pass $v through a regex -- otherwise, |
|
51
|
|
|
|
|
|
|
# it gives us an error that we are trying to modify a constant |
|
52
|
|
|
|
|
|
|
# value (which might be due to the pos($v) being modified) |
|
53
|
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
5
|
$v =~ m{(.*)}; |
|
55
|
2
|
|
|
|
|
5
|
my $u = $1; |
|
56
|
2
|
|
|
|
|
3
|
$u =~ s/^::/main::/; |
|
57
|
2
|
100
|
|
|
|
5
|
my $full_name = $v =~ m{::} ? $u : "${pkg}::$u"; |
|
58
|
2
|
50
|
|
|
|
17
|
die "Uh, Oh! $full_name was declared constant before line $line of $file.\n" |
|
59
|
|
|
|
|
|
|
if $constant::declared{$full_name}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
else { |
|
63
|
3
|
50
|
|
|
|
78
|
if(grep /::Tao$/, keys %constant::declared) { |
|
64
|
3
|
|
|
|
|
4
|
my @isas = ($class, @{"${class}::ISA"}); |
|
|
3
|
|
|
|
|
14
|
|
|
65
|
3
|
|
|
|
|
7
|
my $messages; |
|
66
|
3
|
|
|
|
|
10
|
while(@isas) { |
|
67
|
3
|
|
|
|
|
6
|
my $c = shift @isas; |
|
68
|
3
|
100
|
|
|
|
5
|
if(@{"${c}::ISA"}) { |
|
|
3
|
|
|
|
|
16
|
|
|
69
|
1
|
|
|
|
|
2
|
unshift @isas, @{"${c}::ISA"}; |
|
|
1
|
|
|
|
|
3
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
3
|
50
|
|
|
|
8
|
if(@{"${c}::messages"}) { |
|
|
3
|
|
|
|
|
14
|
|
|
72
|
3
|
|
|
|
|
3
|
$messages = \@{"${c}::messages"}; |
|
|
3
|
|
|
|
|
7
|
|
|
73
|
3
|
|
|
|
|
8
|
last; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
# randomly determine if we die or not |
|
77
|
3
|
100
|
|
|
|
102
|
return if rand(rand) < rand(rand); |
|
78
|
2
|
|
|
|
|
20
|
die "The Tao is not constant:\n", $messages->[rand @$messages], "\n" |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |