line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clone::Choose; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
1792554
|
use strict; |
|
26
|
|
|
|
|
312
|
|
|
26
|
|
|
|
|
778
|
|
4
|
26
|
|
|
26
|
|
158
|
use warnings; |
|
26
|
|
|
|
|
51
|
|
|
26
|
|
|
|
|
666
|
|
5
|
26
|
|
|
26
|
|
175
|
use Carp (); |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
4608
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.010"; |
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @BACKENDS = ( |
11
|
|
|
|
|
|
|
Clone => [0.10, "clone"], |
12
|
|
|
|
|
|
|
Storable => "dclone", |
13
|
|
|
|
|
|
|
"Clone::PP" => "clone", |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $use_m; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
BEGIN |
19
|
|
|
|
|
|
|
{ |
20
|
26
|
50
|
|
26
|
|
189
|
unless ($use_m) |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
eval "use Module::Runtime (); 1;" |
23
|
|
|
|
|
|
|
and $use_m = Module::Runtime->can("use_module") |
24
|
26
|
50
|
100
|
26
|
|
1914
|
unless $ENV{CLONE_CHOOSE_NO_MODULE_RUNTIME}; |
|
26
|
|
|
|
|
6478
|
|
|
14
|
|
|
|
|
22452
|
|
|
14
|
|
|
|
|
128
|
|
25
|
|
|
|
|
|
|
$use_m ||= sub { |
26
|
24
|
|
|
|
|
68
|
my ($pkg, @imports) = @_; |
27
|
24
|
|
|
|
|
65
|
my $use_stmt = "use $pkg"; |
28
|
24
|
100
|
|
|
|
162
|
@imports and $use_stmt = join(" ", $use_stmt, @imports); |
29
|
24
|
|
|
12
|
|
1588
|
eval $use_stmt; |
|
12
|
|
|
8
|
|
111
|
|
|
6
|
|
|
2
|
|
13
|
|
|
6
|
|
|
2
|
|
299
|
|
|
8
|
|
|
|
|
82
|
|
|
8
|
|
|
|
|
23571
|
|
|
8
|
|
|
|
|
367
|
|
|
2
|
|
|
|
|
24
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
30
|
24
|
100
|
|
|
|
1508
|
$@ and die $@; |
31
|
16
|
|
|
|
|
48
|
1; |
32
|
26
|
|
100
|
|
|
19469
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub backend |
37
|
|
|
|
|
|
|
{ |
38
|
8
|
|
|
8
|
1
|
2672
|
my $self = shift; |
39
|
8
|
|
|
|
|
39
|
my @backends = @BACKENDS; |
40
|
|
|
|
|
|
|
|
41
|
8
|
100
|
|
|
|
42
|
if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) |
42
|
|
|
|
|
|
|
{ |
43
|
4
|
|
|
|
|
12
|
my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; |
44
|
4
|
|
|
|
|
20
|
my %b = @backends; |
45
|
4
|
50
|
|
|
|
18
|
Carp::croak "$favourite not found" unless $b{$favourite}; |
46
|
4
|
|
|
|
|
22
|
@backends = ($favourite => $b{$favourite}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
8
|
|
|
|
|
61
|
while (my ($pkg, $rout) = splice @backends, 0, 2) |
50
|
|
|
|
|
|
|
{ |
51
|
12
|
100
|
|
|
|
429
|
eval { $use_m->($pkg, ref $rout ? ($rout->[0]) : ()); 1; } or next; |
|
12
|
100
|
|
|
|
119
|
|
|
8
|
|
|
|
|
158
|
|
52
|
|
|
|
|
|
|
|
53
|
8
|
50
|
|
|
|
91
|
my $fn = $pkg->can(ref $rout ? $rout->[1] : $rout); |
54
|
8
|
50
|
|
|
|
35
|
$fn or next; |
55
|
|
|
|
|
|
|
|
56
|
8
|
|
|
|
|
37
|
return $pkg; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub can |
61
|
|
|
|
|
|
|
{ |
62
|
25
|
|
|
25
|
0
|
53
|
my $self = shift; |
63
|
25
|
|
|
|
|
42
|
my $name = shift; |
64
|
25
|
|
|
|
|
103
|
my @backends = @BACKENDS; |
65
|
|
|
|
|
|
|
|
66
|
25
|
50
|
|
|
|
86
|
return __PACKAGE__->SUPER::can($name) unless $name eq "clone"; |
67
|
|
|
|
|
|
|
|
68
|
25
|
100
|
|
|
|
90
|
if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) |
69
|
|
|
|
|
|
|
{ |
70
|
12
|
|
|
|
|
31
|
my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; |
71
|
12
|
|
|
|
|
48
|
my %b = @backends; |
72
|
12
|
50
|
|
|
|
46
|
Carp::croak "$favourite not found" unless $b{$favourite}; |
73
|
12
|
|
|
|
|
54
|
@backends = ($favourite => $b{$favourite}); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
25
|
|
|
|
|
45
|
my $fn; |
77
|
25
|
|
|
|
|
126
|
while (my ($pkg, $rout) = splice @backends, 0, 2) |
78
|
|
|
|
|
|
|
{ |
79
|
37
|
100
|
|
|
|
1265
|
eval { $use_m->($pkg, ref $rout ? ($rout->[0]) : ()); 1; } or next; |
|
37
|
100
|
|
|
|
178
|
|
|
25
|
|
|
|
|
22910
|
|
80
|
|
|
|
|
|
|
|
81
|
25
|
50
|
|
|
|
264
|
$fn = $pkg->can(ref $rout ? $rout->[1] : $rout); |
82
|
25
|
50
|
|
|
|
99
|
$fn or next; |
83
|
|
|
|
|
|
|
|
84
|
25
|
|
|
|
|
68
|
last; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
25
|
|
|
|
|
80
|
return $fn; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub import |
91
|
|
|
|
|
|
|
{ |
92
|
26
|
|
|
26
|
|
236
|
my ($me, @params) = @_; |
93
|
26
|
|
|
|
|
69
|
my $tgt = caller(0); |
94
|
|
|
|
|
|
|
|
95
|
26
|
|
|
|
|
75
|
my @B = @BACKENDS; |
96
|
26
|
|
|
|
|
79
|
local @BACKENDS = @B; |
97
|
|
|
|
|
|
|
|
98
|
26
|
50
|
|
|
|
120
|
push @params, "clone" unless grep { /^clone$/ } @params; |
|
2
|
|
|
|
|
10
|
|
99
|
|
|
|
|
|
|
|
100
|
26
|
|
|
|
|
105
|
while (my $param = shift @params) |
101
|
|
|
|
|
|
|
{ |
102
|
27
|
100
|
|
|
|
140
|
if ($param =~ m/^:(.*)$/) |
|
|
100
|
|
|
|
|
|
103
|
|
|
|
|
|
|
{ |
104
|
1
|
|
|
|
|
2
|
my $favourite = $1; |
105
|
|
|
|
|
|
|
$ENV{CLONE_CHOOSE_PREFERRED_BACKEND} |
106
|
1
|
50
|
33
|
|
|
5
|
and $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} ne $favourite |
107
|
|
|
|
|
|
|
and Carp::croak |
108
|
|
|
|
|
|
|
"Environment CLONE_CHOOSE_PREFERRED_BACKEND($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) not equal to imported ($favourite)"; |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
4
|
my %b = @BACKENDS; |
111
|
1
|
50
|
|
|
|
3
|
Carp::croak "$favourite not found" unless $b{$favourite}; |
112
|
1
|
|
|
|
|
13
|
@BACKENDS = ($favourite => $b{$favourite}); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
elsif ($param eq "clone") |
115
|
|
|
|
|
|
|
{ |
116
|
25
|
|
|
|
|
79
|
my $fn = __PACKAGE__->can("clone"); |
117
|
25
|
50
|
|
|
|
93
|
$fn or Carp::croak "Cannot find an apropriate clone()."; |
118
|
|
|
|
|
|
|
|
119
|
26
|
|
|
26
|
|
207
|
no strict "refs"; |
|
26
|
|
|
|
|
53
|
|
|
26
|
|
|
|
|
5927
|
|
120
|
25
|
|
|
|
|
53
|
*{"${tgt}::clone"} = $fn; |
|
25
|
|
|
|
|
186
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
@params |
123
|
25
|
50
|
|
|
|
98
|
and Carp::croak "Parameters left after clone. Please see description."; |
124
|
|
|
|
|
|
|
|
125
|
25
|
|
|
|
|
35119
|
return; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
else |
128
|
|
|
|
|
|
|
{ |
129
|
1
|
|
|
|
|
174
|
Carp::croak "$param is not exportable by " . __PACKAGE__; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub get_backends |
135
|
|
|
|
|
|
|
{ |
136
|
4
|
|
|
4
|
1
|
349
|
my $self = shift; |
137
|
4
|
|
|
|
|
24
|
my %backends = @BACKENDS; |
138
|
|
|
|
|
|
|
|
139
|
4
|
100
|
|
|
|
18
|
if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) |
140
|
|
|
|
|
|
|
{ |
141
|
2
|
|
|
|
|
6
|
my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; |
142
|
2
|
50
|
|
|
|
9
|
Carp::croak "$favourite not found" unless $backends{$favourite}; |
143
|
2
|
|
|
|
|
10
|
%backends = ($favourite => $backends{$favourite}); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
4
|
|
|
|
|
26
|
return keys %backends; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |