line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 Exports
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Export routines from a package with names specified by caller of the
|
5
|
|
|
|
|
|
|
package.
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head2 Synopsis
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Math::Zap::Vector vector=>'v', units=>'u';
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $x = v(1,0,0);
|
13
|
|
|
|
|
|
|
my $y = u();
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Rather than:
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $x = Math::Zap::Vector::vector(1,0,0);
|
18
|
|
|
|
|
|
|
my $y = Math::Zap::Vector::units();
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 Description
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Export routines from a package with names specified by caller of the
|
24
|
|
|
|
|
|
|
package. The routines to be exported are defined in the exporting
|
25
|
|
|
|
|
|
|
package Math::Zap::As:
|
26
|
|
|
|
|
|
|
$VERSION=1.07;
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Math::Zap::Exports qw(
|
29
|
|
|
|
|
|
|
vector ($$$)
|
30
|
|
|
|
|
|
|
units ()
|
31
|
|
|
|
|
|
|
);
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
A suitable sub import() is created, allowing the caller to specify:
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Math::Zap::Vector vector=>'v', units=>'u';
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The caller may then refer to Math::Zap::Vector::vector() as v() and
|
38
|
|
|
|
|
|
|
Math::Zap::Vector::units() as u().
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The first routine exported is always imported by its export name unless
|
41
|
|
|
|
|
|
|
a new name is supplied. Thus:
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use Math::Zap::Vector;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
and
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use Math::Zap::Vector vector=>'vector';
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
have identical effects.
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The advantage of this is approach is that it allows the importing
|
52
|
|
|
|
|
|
|
package Math::Zap::To control the names of the exported routines in its name space
|
53
|
|
|
|
|
|
|
$VERSION=1.07;
|
54
|
|
|
|
|
|
|
rather than the developer of the exporting package, a facility I have
|
55
|
|
|
|
|
|
|
not been able to discover in the standard Perl Exporter.pm.
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
PhilipRBrenan@yahoo.com, 2004, Perl licence
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 Method: Exports
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Construct import routine.
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
##1
|
68
|
|
|
|
|
|
|
package Math::Zap::Exports;
|
69
|
|
|
|
|
|
|
$VERSION=1.07;
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#______________________________________________________________________
|
72
|
|
|
|
|
|
|
# Import for exports: export from exporting package.
|
73
|
|
|
|
|
|
|
#______________________________________________________________________
|
74
|
|
|
|
|
|
|
|
75
|
51
|
|
|
51
|
|
132
|
sub import(@)
|
76
|
|
|
|
|
|
|
{shift @_; # Remove 'exports'
|
77
|
51
|
50
|
|
|
|
197
|
scalar(@_) % 2 and # Check number of parameters is even
|
78
|
|
|
|
|
|
|
die "use exports: Odd number of parameters";
|
79
|
51
|
|
|
|
|
659
|
my $q = join(' ', @_); # Stringify parameters
|
80
|
51
|
|
|
|
|
157
|
my $p = (caller())[0]; # Exporting package
|
81
|
51
|
|
|
|
|
154
|
my $s = # Push data into space of exporting package
|
82
|
|
|
|
|
|
|
'@'.$p.'::EXPORTS = qw('.$q.');';
|
83
|
51
|
50
|
|
|
|
3553
|
eval $s; die $@ if $@; # Perform push and check it worked
|
|
49
|
|
|
|
|
215
|
|
84
|
|
|
|
|
|
|
# print "AAAA ", join(' ', @zzz::EXPORTS), "\n"; # Print pushed data
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#______________________________________________________________________
|
87
|
|
|
|
|
|
|
# Construct import routine for exporting package.
|
88
|
|
|
|
|
|
|
#______________________________________________________________________
|
89
|
|
|
|
|
|
|
|
90
|
49
|
|
|
|
|
176
|
$s = 'pack'."age $p;\n". <<'END'; # Switch to exporting package
|
91
|
|
|
|
|
|
|
sub import(@)
|
92
|
|
|
|
|
|
|
{shift @_;
|
93
|
|
|
|
|
|
|
my @p = ($EXPORTS[0], $EXPORTS[0], @_);
|
94
|
|
|
|
|
|
|
scalar(@p) % 2 and die "Odd number of parameters";
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Edit parameters and convert to hash
|
97
|
|
|
|
|
|
|
s/^-// for(@p);
|
98
|
|
|
|
|
|
|
my %p = @p;
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Switch to package requesting exported methods
|
101
|
|
|
|
|
|
|
my $c = __PACKAGE__; # Save exporting package
|
102
|
|
|
|
|
|
|
my $s = # Switch to importing package
|
103
|
|
|
|
|
|
|
'pack'.'age '.(caller())[0].";\n".
|
104
|
|
|
|
|
|
|
'no warnings \'redefine\';'."\n";
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Export valid methods
|
107
|
|
|
|
|
|
|
my %e = @EXPORTS;
|
108
|
|
|
|
|
|
|
for my $p(keys(%p))
|
109
|
|
|
|
|
|
|
{defined $e{$p} or
|
110
|
|
|
|
|
|
|
die "use $c: Bad method: $p requested.\nValid methods are ".
|
111
|
|
|
|
|
|
|
join(', ', sort(keys(%e))). "\n";
|
112
|
|
|
|
|
|
|
$s .= 'sub '.$p{$p}.$e{$p}.' {&'.$c.'::'.$p.'(@_)}'."\n";
|
113
|
|
|
|
|
|
|
}
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# Back to exporting package
|
116
|
|
|
|
|
|
|
$s .= 'use warnings \'redefine\';'."\n".
|
117
|
|
|
|
|
|
|
'pack'.'age '.$c.";\n";
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Push exports
|
120
|
|
|
|
|
|
|
# print "BBBB $s\n";
|
121
|
|
|
|
|
|
|
eval($s); die $@ if $@;
|
122
|
|
|
|
|
|
|
}
|
123
|
|
|
|
|
|
|
END
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#______________________________________________________________________
|
126
|
|
|
|
|
|
|
# Push import routine
|
127
|
|
|
|
|
|
|
#______________________________________________________________________
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# print "CCCC $s\n";
|
130
|
22
|
50
|
|
22
|
0
|
125
|
eval($s); die $@ if $@;
|
|
22
|
50
|
|
22
|
0
|
37
|
|
|
22
|
50
|
|
16
|
0
|
2051
|
|
|
22
|
50
|
|
16
|
0
|
115
|
|
|
22
|
50
|
|
16
|
0
|
40
|
|
|
22
|
50
|
|
11
|
0
|
1239
|
|
|
16
|
50
|
|
20
|
0
|
96
|
|
|
16
|
50
|
|
27
|
0
|
29
|
|
|
16
|
50
|
|
18
|
1
|
1441
|
|
|
16
|
50
|
|
12
|
0
|
99
|
|
|
16
|
50
|
|
10
|
1
|
54
|
|
|
16
|
50
|
|
11
|
0
|
835
|
|
|
49
|
50
|
|
8
|
0
|
14433
|
|
|
49
|
50
|
|
8
|
0
|
1743
|
|
|
14
|
50
|
|
11
|
0
|
36
|
|
|
11
|
50
|
|
57
|
0
|
311
|
|
|
20
|
50
|
|
6
|
0
|
74
|
|
|
27
|
50
|
|
6
|
0
|
26273
|
|
|
27
|
50
|
|
36
|
0
|
508
|
|
|
27
|
50
|
|
62
|
0
|
113
|
|
|
27
|
50
|
|
18
|
0
|
123
|
|
|
27
|
50
|
|
13
|
0
|
330
|
|
|
26
|
50
|
|
6
|
|
85
|
|
|
26
|
50
|
|
10
|
|
123
|
|
|
26
|
50
|
|
21
|
|
390
|
|
|
26
|
50
|
|
88
|
|
90
|
|
|
41
|
50
|
|
36
|
|
124
|
|
|
41
|
50
|
|
18
|
|
337
|
|
|
26
|
|
|
132
|
|
123
|
|
|
26
|
|
|
57
|
|
1530
|
|
|
26
|
|
|
79
|
|
2983
|
|
|
17
|
|
|
0
|
|
156
|
|
|
17
|
|
|
0
|
|
52
|
|
|
17
|
|
|
66
|
|
228
|
|
|
16
|
|
|
48
|
|
69
|
|
|
16
|
|
|
59
|
|
64
|
|
|
16
|
|
|
0
|
|
350
|
|
|
16
|
|
|
45
|
|
139
|
|
|
16
|
|
|
1
|
|
47
|
|
|
16
|
|
|
1
|
|
183
|
|
|
26
|
|
|
|
|
76
|
|
|
26
|
|
|
|
|
100
|
|
|
16
|
|
|
|
|
323
|
|
|
16
|
|
|
|
|
825
|
|
|
16
|
|
|
|
|
301
|
|
|
11
|
|
|
|
|
228
|
|
|
11
|
|
|
|
|
44
|
|
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
226
|
|
|
11
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
174
|
|
|
10
|
|
|
|
|
38
|
|
|
10
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
211
|
|
|
15
|
|
|
|
|
56
|
|
|
10
|
|
|
|
|
28
|
|
|
10
|
|
|
|
|
627
|
|
|
8
|
|
|
|
|
193
|
|
|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
|
|
|
|
26
|
|
|
10
|
|
|
|
|
36
|
|
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
311
|
|
|
5
|
|
|
|
|
189
|
|
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
27
|
|
|
8
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
36
|
|
|
8
|
|
|
|
|
27
|
|
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
40
|
|
|
8
|
|
|
|
|
47
|
|
|
8
|
|
|
|
|
23
|
|
|
17
|
|
|
|
|
47
|
|
|
17
|
|
|
|
|
59
|
|
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
533
|
|
|
8
|
|
|
|
|
195
|
|
|
54
|
|
|
|
|
167
|
|
|
4
|
|
|
|
|
108
|
|
|
4
|
|
|
|
|
120
|
|
|
34
|
|
|
|
|
109
|
|
|
61
|
|
|
|
|
199
|
|
|
17
|
|
|
|
|
62
|
|
|
14
|
|
|
|
|
182
|
|
|
7
|
|
|
|
|
58
|
|
|
11
|
|
|
|
|
33
|
|
|
23
|
|
|
|
|
69
|
|
|
90
|
|
|
|
|
692
|
|
|
37
|
|
|
|
|
100
|
|
|
19
|
|
|
|
|
232
|
|
|
133
|
|
|
|
|
424
|
|
|
57
|
|
|
|
|
1348
|
|
|
79
|
|
|
|
|
241
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
66
|
|
|
|
|
180
|
|
|
48
|
|
|
|
|
157
|
|
|
59
|
|
|
|
|
259
|
|
|
0
|
|
|
|
|
0
|
|
|
45
|
|
|
|
|
130
|
|
|
1
|
|
|
|
|
34
|
|
|
1
|
|
|
|
|
752
|
|
131
|
|
|
|
|
|
|
}
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
##2
|
134
|
|
|
|
|
|
|
#______________________________________________________________________
|
135
|
|
|
|
|
|
|
# Package installed successfully
|
136
|
|
|
|
|
|
|
#______________________________________________________________________
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1;
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 Credits
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head3 Author
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
philiprbrenan@yahoo.com
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head3 Copyright
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
philiprbrenan@yahoo.com, 2004
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head3 License
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Perl License.
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut
|