line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Package::Rename; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
27495
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
75
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
68
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
141
|
|
6
|
2
|
|
|
2
|
|
1880
|
use MRO::Compat; |
|
2
|
|
|
|
|
7537
|
|
|
2
|
|
|
|
|
67
|
|
7
|
2
|
|
|
2
|
|
17
|
use base 'Exporter'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
371
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/copy_package remove_package rename_package link_package/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub copy_package { |
13
|
0
|
|
|
0
|
1
|
0
|
my ($old_name, $new_name) = @_; |
14
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
445
|
|
15
|
0
|
|
|
|
|
0
|
%{"$new_name\::"} = %{"$old_name\::"}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
16
|
0
|
|
|
|
|
0
|
mro::method_changed_in($new_name); |
17
|
0
|
|
|
|
|
0
|
return; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub remove_package { |
21
|
2
|
|
|
2
|
1
|
4
|
my $name = shift; |
22
|
2
|
100
|
|
|
|
20
|
my ($super, $sub) = $name =~ / ^ ( \w+ (?> ::\w+ )* ) :: (\w+) $/xs ? ($1, $2) : ('main', $name); |
23
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
194
|
|
24
|
2
|
|
|
|
|
3
|
undef ${"$super\::"}{"$sub\::"}; |
|
2
|
|
|
|
|
24
|
|
25
|
2
|
|
|
|
|
13
|
mro::method_changed_in($name); |
26
|
2
|
|
|
|
|
5
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub link_package { |
30
|
2
|
|
|
2
|
1
|
5
|
my ($old_name, $new_name) = @_; |
31
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
279
|
|
32
|
2
|
|
|
|
|
4
|
*{"$new_name\::"} = *{"$old_name\::"}; |
|
2
|
|
|
|
|
31
|
|
|
2
|
|
|
|
|
7
|
|
33
|
2
|
|
|
|
|
15
|
mro::method_changed_in($new_name); |
34
|
2
|
|
|
|
|
5
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub rename_package { |
38
|
2
|
|
|
2
|
1
|
5028
|
my ($old_name, $new_name) = @_; |
39
|
2
|
|
|
|
|
7
|
link_package($old_name, $new_name); |
40
|
2
|
|
|
|
|
6
|
remove_package($old_name); |
41
|
2
|
|
|
|
|
9
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; # End of Package::Rename |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |