line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: mods.pm 1.11 Fri, 12 Sep 1997 23:21:20 -0400 jesse $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package mods; |
4
|
1
|
|
|
1
|
|
753
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
1244
|
use integer; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
31
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
225
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# $Format: "$VERSION='$modsRelease$';"$ |
9
|
|
|
|
|
|
|
$VERSION='0.004'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# $list: undef ~ use Foo; [] ~ use Foo(); [...] ~ use Foo (...) |
12
|
|
|
|
|
|
|
sub sim_use($$;$$) { |
13
|
6
|
|
|
6
|
0
|
11
|
my ($callpack, $pkg, $un, $list)=@_; |
14
|
6
|
|
|
|
|
7
|
my $filename=$pkg; |
15
|
6
|
|
|
|
|
12
|
$filename =~ s!::!/!g; |
16
|
6
|
|
|
|
|
2328
|
require "$filename.pm"; |
17
|
5
|
50
|
66
|
|
|
24
|
unless ($list and not @$list) { # Null import: use Foo (); |
18
|
|
|
|
|
|
|
# Black magic commencing. Yes there is a reason for all this fuss... |
19
|
5
|
50
|
|
|
|
10
|
my $meth=($un ? 'unimport' : 'import'); |
20
|
1
|
|
|
1
|
|
6
|
no strict qw(refs); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1594
|
|
21
|
5
|
|
|
|
|
441
|
local (*{"${callpack}::__FNORD__"})= |
|
5
|
|
|
|
|
18
|
|
22
|
|
|
|
|
|
|
eval "package $callpack; sub {\$pkg->\$meth(\@\$list)}"; |
23
|
5
|
|
|
|
|
7
|
&{"${callpack}::__FNORD__"}(); |
|
5
|
|
|
|
|
194
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub import { |
28
|
1
|
|
|
1
|
|
8
|
my ($class, @in)=@_; |
29
|
1
|
50
|
33
|
|
|
14
|
if (@in==1 and $in[0] !~ /[^0-9.]/) { |
30
|
0
|
0
|
|
|
|
0
|
if ($VERSION < $in[0]) { |
31
|
0
|
|
|
|
|
0
|
require Carp; |
32
|
0
|
|
|
|
|
0
|
Carp::croak "mods $in[0] requested, only have $VERSION"; |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
0
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
1
|
|
|
|
|
2
|
my $callpack=caller; |
38
|
1
|
|
|
|
|
3
|
my $in=join "\n", @in; |
39
|
1
|
50
|
|
|
|
5
|
unless ($in =~ s/^\s*~//) { |
40
|
|
|
|
|
|
|
# Defaults. |
41
|
1
|
|
|
|
|
3
|
sim_use $callpack, q(strict); |
42
|
1
|
|
|
|
|
2
|
sim_use $callpack, q(integer); |
43
|
1
|
|
|
|
|
15
|
sim_use $callpack, q(vars), 0, |
44
|
|
|
|
|
|
|
[qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @EXPORT_FAIL $AUTOLOAD $VERSION)]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
# Custom. |
47
|
1
|
|
|
|
|
9
|
$in =~ s/(^|\s)\#.*$/$1/gm; # Comments. |
48
|
1
|
|
|
|
|
15
|
while ($in =~ m{ |
49
|
|
|
|
|
|
|
( # Import directive |
50
|
|
|
|
|
|
|
(!)? # Unimport? |
51
|
|
|
|
|
|
|
\s* |
52
|
|
|
|
|
|
|
([\w:]+) # Package name |
53
|
|
|
|
|
|
|
\s* |
54
|
|
|
|
|
|
|
( # Import list, maybe none |
55
|
|
|
|
|
|
|
\( |
56
|
|
|
|
|
|
|
( [^()]* ) # Imports themselves |
57
|
|
|
|
|
|
|
\) |
58
|
|
|
|
|
|
|
)? |
59
|
|
|
|
|
|
|
) | |
60
|
|
|
|
|
|
|
( # BEGIN directive |
61
|
|
|
|
|
|
|
\{ |
62
|
|
|
|
|
|
|
([^{}]*) # Actual code |
63
|
|
|
|
|
|
|
\} |
64
|
|
|
|
|
|
|
) | |
65
|
|
|
|
|
|
|
( # Export directive |
66
|
|
|
|
|
|
|
< |
67
|
|
|
|
|
|
|
([^<>]*) # Exportables |
68
|
|
|
|
|
|
|
> |
69
|
|
|
|
|
|
|
) | |
70
|
|
|
|
|
|
|
( # Inherit |
71
|
|
|
|
|
|
|
\[ |
72
|
|
|
|
|
|
|
([^][]*) # Superclasses |
73
|
|
|
|
|
|
|
\] |
74
|
|
|
|
|
|
|
) | |
75
|
|
|
|
|
|
|
( |
76
|
|
|
|
|
|
|
[\$\@\%] \w+ # Variable |
77
|
|
|
|
|
|
|
) |
78
|
|
|
|
|
|
|
}sgx) { |
79
|
4
|
100
|
|
|
|
22
|
if ($1) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Importation |
81
|
1
|
|
|
|
|
4
|
my ($un, $pack, $list, $sublist)=($2, $3, $4, $5); |
82
|
1
|
50
|
|
|
|
5
|
sim_use $callpack, $pack, $un, ($list ? [$sublist =~ /([^\s,]+)/g] : undef); |
83
|
|
|
|
|
|
|
} elsif ($6) { |
84
|
|
|
|
|
|
|
# Compile code |
85
|
1
|
|
|
1
|
|
7
|
no strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
86
|
1
|
|
|
1
|
|
4
|
no integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
87
|
1
|
|
|
|
|
48
|
eval "package $callpack; $7"; |
88
|
|
|
|
|
|
|
} elsif ($8) { |
89
|
|
|
|
|
|
|
# Exporting |
90
|
0
|
|
|
|
|
0
|
my @what=($9 =~ /([^\s,]+)/g); |
91
|
0
|
|
|
|
|
0
|
sim_use $callpack, q(Exporter), 0, []; |
92
|
1
|
|
|
1
|
|
171
|
no strict qw(refs); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
279
|
|
93
|
0
|
|
|
|
|
0
|
push @{"${callpack}::ISA"}, q(Exporter) |
|
0
|
|
|
|
|
0
|
|
94
|
0
|
0
|
|
|
|
0
|
unless grep {$_ eq q(Exporter)} @{"${callpack}::ISA"}; |
|
0
|
|
|
|
|
0
|
|
95
|
0
|
|
|
|
|
0
|
foreach (@what) { |
96
|
0
|
0
|
|
|
|
0
|
my $where=(s/!$// ? 'EXPORT' : 'EXPORT_OK'); |
97
|
0
|
|
|
|
|
0
|
push @{"${callpack}::$where"}, $_; |
|
0
|
|
|
|
|
0
|
|
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
|
|
0
|
sim_use $callpack, q(vars), 0, [grep {/^[\$\@\%]/} @what]; |
|
0
|
|
|
|
|
0
|
|
100
|
|
|
|
|
|
|
} elsif ($10) { |
101
|
|
|
|
|
|
|
# Inheritance |
102
|
1
|
|
|
1
|
|
12
|
no strict qw(refs); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
248
|
|
103
|
0
|
|
|
|
|
0
|
push @{"${callpack}::ISA"}, ($11 =~ /([\w:]+)/g); |
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
} elsif ($12) { |
105
|
|
|
|
|
|
|
# Variable |
106
|
2
|
|
|
|
|
7
|
sim_use $callpack, q(vars), 0, [$12]; |
107
|
|
|
|
|
|
|
} # Else comment. |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
__END__ |