line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Scalar::Constant; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
60895
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
97
|
|
4
|
3
|
|
|
3
|
|
18
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
235
|
|
5
|
3
|
|
|
3
|
|
2542
|
use Scalar::Quote 'quote'; |
|
3
|
|
|
|
|
4591
|
|
|
3
|
|
|
|
|
231
|
|
6
|
3
|
|
|
3
|
|
21
|
use Scalar::Util qw(looks_like_number); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
362
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
15
|
use vars qw( $VERSION ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
713
|
|
9
|
|
|
|
|
|
|
$VERSION = 0.001_005; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
4
|
|
|
4
|
|
776
|
my $module = shift; |
14
|
4
|
100
|
|
|
|
54
|
my %constant = @_ |
15
|
|
|
|
|
|
|
or return; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
6
|
my $calling_package = (caller)[0]; |
18
|
2
|
|
|
|
|
5
|
my @code; |
19
|
2
|
|
|
|
|
10
|
while(my($name, $value) = each %constant) { |
20
|
5
|
100
|
|
|
|
56
|
if(ref($value)) { |
21
|
1
|
|
|
|
|
205
|
croak 'References are not supported'; |
22
|
|
|
|
|
|
|
} |
23
|
4
|
100
|
|
|
|
15
|
if(! looks_like_number($value)) { |
24
|
2
|
|
|
|
|
7
|
$value = quote($value); |
25
|
|
|
|
|
|
|
} |
26
|
4
|
|
|
|
|
73
|
push @code, sprintf('*%s::%s = \ %s;', $calling_package, $name, $value); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
5
|
my $code = join("\n", @code); |
30
|
1
|
50
|
|
|
|
122
|
eval $code |
31
|
|
|
|
|
|
|
or confess "This shouldn't happen: $@"; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
35
|
|
|
|
|
|
|
__END__ |