line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::WarnGlobal; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Helps track down and eliminate globals |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6281
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.09'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
65
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
554
|
use Devel::WarnGlobal::Scalar; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
405
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
11
|
my $type = shift; |
18
|
1
|
|
|
|
|
3
|
my (@var_ties) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
4
|
my $tie_params = $type->_rearrange(\@var_ties); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
6
|
while ( my ($var_name, $options) = each %$tie_params ) { |
23
|
2
|
|
|
|
|
2
|
tie ${ $type->_fix_name($var_name) }, $type->_get_tie_type(), $options; |
|
2
|
|
|
|
|
5
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
28
|
1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _rearrange { |
30
|
1
|
|
|
1
|
|
2
|
my $type = shift; |
31
|
1
|
|
|
|
|
1
|
my ($var_ties_in) = @_; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
2
|
my @var_ties = @$var_ties_in; |
34
|
1
|
|
|
|
|
2
|
my %fixed_ties = (); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
4
|
while ( scalar @var_ties ) { |
37
|
2
|
|
|
|
|
10
|
my $var_name = shift @var_ties; |
38
|
2
|
|
|
|
|
3
|
my $var_arg = shift @var_ties; |
39
|
2
|
|
|
|
|
5
|
my %var_opts = ( name => $var_name ); |
40
|
|
|
|
|
|
|
|
41
|
2
|
100
|
|
|
|
7
|
if (ref $var_arg eq 'ARRAY') { |
|
|
50
|
|
|
|
|
|
42
|
1
|
50
|
|
|
|
4
|
$var_opts{'get'} = $var_arg->[0] if defined $var_arg->[0]; |
43
|
1
|
50
|
|
|
|
4
|
$var_opts{'set'} = $var_arg->[1] if defined $var_arg->[1]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif (ref $var_arg eq 'CODE') { |
46
|
1
|
|
|
|
|
1
|
$var_opts{'get'} = $var_arg; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
|
|
|
|
0
|
croak("${$type}::import() called improperly; stopped"); |
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
} |
51
|
2
|
|
|
|
|
8
|
$fixed_ties{$var_name} = \%var_opts; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
2
|
return \%fixed_ties; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _get_tie_type { |
58
|
2
|
|
|
2
|
|
9
|
return 'Devel::WarnGlobal::Scalar'; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _fix_name { |
62
|
2
|
|
|
2
|
|
2
|
my $type = shift; |
63
|
2
|
|
|
|
|
2
|
my ($var_name) = @_; |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
6
|
my $var = substr($var_name, 1); |
66
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
5
|
$var_name =~ m{::} and return $var; |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
12
|
return ( caller(2) )[0] . '::' . $var; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |