line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clone::Choose; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
862455
|
use strict; |
|
13
|
|
|
|
|
146
|
|
|
13
|
|
|
|
|
371
|
|
4
|
13
|
|
|
13
|
|
66
|
use warnings; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
326
|
|
5
|
13
|
|
|
13
|
|
63
|
use Carp (); |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
2102
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.006"; |
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
|
13
|
50
|
|
13
|
|
87
|
unless ($use_m) |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
eval "use Module::Runtime (); 1;" |
23
|
|
|
|
|
|
|
and $use_m = Module::Runtime->can("use_module") |
24
|
13
|
50
|
50
|
13
|
|
863
|
unless $ENV{CLONE_CHOOSE_NO_MODULE_RUNTIME}; |
|
13
|
|
|
|
|
4418
|
|
|
13
|
|
|
|
|
20388
|
|
|
13
|
|
|
|
|
143
|
|
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
|
13
|
|
50
|
|
|
6516
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub backend |
37
|
|
|
|
|
|
|
{ |
38
|
2
|
|
|
2
|
1
|
1171
|
my $self = shift; |
39
|
2
|
|
|
|
|
13
|
my @backends = @BACKENDS; |
40
|
|
|
|
|
|
|
|
41
|
2
|
100
|
|
|
|
10
|
if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) |
42
|
|
|
|
|
|
|
{ |
43
|
1
|
|
|
|
|
2
|
my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; |
44
|
1
|
|
|
|
|
4
|
my %b = @backends; |
45
|
1
|
50
|
|
|
|
4
|
Carp::croak "$favourite not found" unless $b{$favourite}; |
46
|
1
|
|
|
|
|
7
|
@backends = ($favourite => $b{$favourite}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
14
|
while (my ($pkg, $rout) = splice @backends, 0, 2) |
50
|
|
|
|
|
|
|
{ |
51
|
3
|
100
|
|
|
|
104
|
eval { $use_m->($pkg, ref $rout ? ($rout->[0]) : ()); 1; } or next; |
|
3
|
100
|
|
|
|
25
|
|
|
2
|
|
|
|
|
85
|
|
52
|
|
|
|
|
|
|
|
53
|
2
|
50
|
|
|
|
28
|
my $fn = $pkg->can(ref $rout ? $rout->[1] : $rout); |
54
|
2
|
50
|
|
|
|
9
|
$fn or next; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
9
|
return $pkg; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub can |
63
|
|
|
|
|
|
|
{ |
64
|
13
|
|
|
13
|
0
|
25
|
my $self = shift; |
65
|
13
|
|
|
|
|
24
|
my $name = shift; |
66
|
13
|
|
|
|
|
30
|
my @backends = @BACKENDS; |
67
|
|
|
|
|
|
|
|
68
|
13
|
50
|
|
|
|
39
|
return __PACKAGE__->SUPER::can($name) unless $name eq "clone"; |
69
|
|
|
|
|
|
|
|
70
|
13
|
100
|
|
|
|
58
|
if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) |
71
|
|
|
|
|
|
|
{ |
72
|
7
|
|
|
|
|
17
|
my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; |
73
|
7
|
|
|
|
|
26
|
my %b = @backends; |
74
|
7
|
50
|
|
|
|
24
|
Carp::croak "$favourite not found" unless $b{$favourite}; |
75
|
7
|
|
|
|
|
31
|
@backends = ($favourite => $b{$favourite}); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
13
|
|
|
|
|
25
|
my $fn; |
79
|
13
|
|
|
|
|
63
|
while (my ($pkg, $rout) = splice @backends, 0, 2) |
80
|
|
|
|
|
|
|
{ |
81
|
18
|
100
|
|
|
|
773
|
eval { $use_m->($pkg, ref $rout ? ($rout->[0]) : ()); 1; } or next; |
|
18
|
100
|
|
|
|
117
|
|
|
11
|
|
|
|
|
19751
|
|
82
|
|
|
|
|
|
|
|
83
|
11
|
50
|
|
|
|
125
|
$fn = $pkg->can(ref $rout ? $rout->[1] : $rout); |
84
|
11
|
50
|
|
|
|
42
|
$fn or next; |
85
|
|
|
|
|
|
|
|
86
|
11
|
|
|
|
|
29
|
last; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
13
|
|
|
|
|
364
|
return $fn; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub import |
93
|
|
|
|
|
|
|
{ |
94
|
13
|
|
|
13
|
|
115
|
my ($me, @params) = @_; |
95
|
13
|
|
|
|
|
38
|
my $tgt = caller(0); |
96
|
|
|
|
|
|
|
|
97
|
13
|
|
|
|
|
40
|
my @B = @BACKENDS; |
98
|
13
|
|
|
|
|
38
|
local @BACKENDS = @B; |
99
|
|
|
|
|
|
|
|
100
|
13
|
50
|
|
|
|
55
|
push @params, "clone" unless grep { /^clone$/ } @params; |
|
1
|
|
|
|
|
5
|
|
101
|
|
|
|
|
|
|
|
102
|
13
|
|
|
|
|
57
|
while (my $param = shift @params) |
103
|
|
|
|
|
|
|
{ |
104
|
14
|
100
|
|
|
|
71
|
if ($param =~ m/^:(.*)$/) |
|
|
50
|
|
|
|
|
|
105
|
|
|
|
|
|
|
{ |
106
|
1
|
|
|
|
|
2
|
my $favourite = $1; |
107
|
|
|
|
|
|
|
$ENV{CLONE_CHOOSE_PREFERRED_BACKEND} |
108
|
1
|
50
|
33
|
|
|
5
|
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
|
|
|
|
4
|
Carp::croak "$favourite not found" unless $b{$favourite}; |
114
|
1
|
|
|
|
|
13
|
@BACKENDS = ($favourite => $b{$favourite}); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ($param eq "clone") |
117
|
|
|
|
|
|
|
{ |
118
|
13
|
|
|
|
|
41
|
my $fn = __PACKAGE__->can("clone"); |
119
|
13
|
100
|
|
|
|
1755
|
$fn or Carp::croak "Cannot find an apropriate clone()."; |
120
|
|
|
|
|
|
|
|
121
|
13
|
|
|
13
|
|
101
|
no strict "refs"; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
2667
|
|
122
|
11
|
|
|
|
|
21
|
*{"${tgt}::clone"} = $fn; |
|
11
|
|
|
|
|
64
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
@params |
125
|
11
|
50
|
|
|
|
40
|
and Carp::croak "Parameters left after clone. Please see description."; |
126
|
|
|
|
|
|
|
|
127
|
11
|
|
|
|
|
11125
|
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__ |