| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Code::Embeddable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-06-18'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
909
|
use 5.010001; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
54
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# BEGIN_BLOCK: import |
|
11
|
|
|
|
|
|
|
sub import { |
|
12
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
509
|
|
|
13
|
1
|
|
|
1
|
|
8
|
my $pkg = shift; |
|
14
|
1
|
|
|
|
|
2
|
my $caller = caller; |
|
15
|
1
|
50
|
|
|
|
4
|
my @imp = @_ ? @_ : @{__PACKAGE__.'::EXPORT'}; |
|
|
1
|
|
|
|
|
5
|
|
|
16
|
1
|
|
|
|
|
33
|
for my $imp (@imp) { |
|
17
|
0
|
0
|
|
|
|
0
|
if (grep {$_ eq $imp} (@{__PACKAGE__.'::EXPORT'}, |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
18
|
|
|
|
|
|
|
@{__PACKAGE__.'::EXPORT_OK'})) { |
|
19
|
0
|
|
|
|
|
0
|
*{"$caller\::$imp"} = \&{$imp}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
20
|
|
|
|
|
|
|
} else { |
|
21
|
0
|
|
|
|
|
0
|
die "$imp is not exported by ".__PACKAGE__; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
# END_BLOCK: import |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# BEGIN_BLOCK: pick |
|
28
|
|
|
|
|
|
|
sub pick { |
|
29
|
2
|
100
|
|
2
|
1
|
721
|
return undef unless @_; |
|
30
|
1
|
|
|
|
|
44
|
return $_[@_*rand]; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
# END_BLOCK: pick |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# BEGIN_BLOCK: pick_n |
|
35
|
|
|
|
|
|
|
sub pick_n { |
|
36
|
4
|
|
|
4
|
1
|
1149
|
my $n = shift; |
|
37
|
4
|
|
|
|
|
6
|
my @res; |
|
38
|
4
|
|
|
|
|
5
|
while (1) { |
|
39
|
6
|
100
|
|
|
|
12
|
last if @res >= $n; |
|
40
|
5
|
100
|
|
|
|
13
|
last unless @_; |
|
41
|
2
|
|
|
|
|
7
|
push @res, splice(@_, @_*rand(), 1); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
4
|
|
|
|
|
20
|
@res; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
# END_BLOCK: pick_n |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# BEGIN_BLOCK: shuffle |
|
48
|
|
|
|
|
|
|
sub shuffle { |
|
49
|
2
|
|
|
2
|
1
|
1487
|
my @res; |
|
50
|
2
|
|
|
|
|
3
|
while (1) { |
|
51
|
3
|
100
|
|
|
|
13
|
last unless @_; |
|
52
|
1
|
|
|
|
|
5
|
push @res, splice(@_, @_*rand(), 1); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
2
|
|
|
|
|
10
|
@res; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
# END_BLOCK: shuffle |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# copy-pasted from List::MoreUtils |
|
59
|
|
|
|
|
|
|
# BEGIN_BLOCK: uniq |
|
60
|
|
|
|
|
|
|
sub uniq (@) { |
|
61
|
1
|
|
|
1
|
1
|
1119
|
my %seen = (); |
|
62
|
1
|
|
|
|
|
1
|
my $k; |
|
63
|
|
|
|
|
|
|
my $seen_undef; |
|
64
|
1
|
50
|
|
|
|
2
|
grep { defined $_ ? not $seen{ $k = $_ }++ : not $seen_undef++ } @_; |
|
|
8
|
|
|
|
|
21
|
|
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
# END_BLOCK: uniq |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
if (0) { <<'_' } |
|
69
|
|
|
|
|
|
|
# BEGIN_BLOCK: stacktrace_printer |
|
70
|
|
|
|
|
|
|
my %OLD_SIG; |
|
71
|
|
|
|
|
|
|
BEGIN { |
|
72
|
|
|
|
|
|
|
@OLD_SIG{qw/__DIE__ __WARN__/} = @SIG{qw/__DIE__ __WARN__/}; |
|
73
|
|
|
|
|
|
|
my $longmess = sub { |
|
74
|
|
|
|
|
|
|
my $mess = ''; |
|
75
|
|
|
|
|
|
|
my $i = 2; |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
|
|
|
|
|
|
package DB; |
|
78
|
|
|
|
|
|
|
while (my @caller = caller($i)) { |
|
79
|
|
|
|
|
|
|
if ($i == 2) { $mess .= $_[0] } |
|
80
|
|
|
|
|
|
|
$mess .= "\t"; |
|
81
|
|
|
|
|
|
|
if ($caller[3]) { # subroutine |
|
82
|
|
|
|
|
|
|
$mess .= "$caller[3]("; |
|
83
|
|
|
|
|
|
|
if ($caller[4]) { # has_args |
|
84
|
|
|
|
|
|
|
my $j = 0; |
|
85
|
|
|
|
|
|
|
for my $arg0 (@DB::args) { |
|
86
|
|
|
|
|
|
|
my $arg = $arg0; # copy |
|
87
|
|
|
|
|
|
|
if ($j++) { $mess .= ", " } |
|
88
|
|
|
|
|
|
|
if (!defined($arg)) { $arg = "undef" } |
|
89
|
|
|
|
|
|
|
elsif (ref($arg)) { } |
|
90
|
|
|
|
|
|
|
else { $arg =~ s/([\\'])/\\$1/g; $arg = "'$arg'" } |
|
91
|
|
|
|
|
|
|
$mess .= $arg; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
$mess .= ") called "; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
$mess .= "at $caller[1] line $caller[2]\n"; |
|
97
|
|
|
|
|
|
|
$i++; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
$mess; |
|
101
|
|
|
|
|
|
|
}; |
|
102
|
|
|
|
|
|
|
$SIG{__DIE__} = sub { die &$longmess }; |
|
103
|
|
|
|
|
|
|
$SIG{__WARN__} = sub { warn &$longmess }; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
END { |
|
106
|
|
|
|
|
|
|
@SIG{qw/__DIE__ __WARN__/} = @OLD_SIG{qw/__DIE__ __WARN__/}; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
# END_BLOCK: stacktrace_printer |
|
109
|
|
|
|
|
|
|
_ |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
# ABSTRACT: Collection of routines that can be embedded e.g. using Dist::Zilla plugin |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |