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