line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Code::Embeddable; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-06-18'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
423
|
use 5.010001; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# BEGIN_BLOCK: import |
11
|
|
|
|
|
|
|
sub import { |
12
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
424
|
|
13
|
1
|
|
|
1
|
|
7
|
my $pkg = shift; |
14
|
1
|
|
|
|
|
2
|
my $caller = caller; |
15
|
1
|
50
|
|
|
|
4
|
my @imp = @_ ? @_ : @{__PACKAGE__.'::EXPORT'}; |
|
1
|
|
|
|
|
6
|
|
16
|
1
|
|
|
|
|
29
|
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
|
547
|
return undef unless @_; |
30
|
1
|
|
|
|
|
46
|
return $_[@_*rand]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
# END_BLOCK: pick |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# BEGIN_BLOCK: pick_n |
35
|
|
|
|
|
|
|
sub pick_n { |
36
|
4
|
|
|
4
|
1
|
1077
|
my $n = shift; |
37
|
4
|
|
|
|
|
4
|
my @res; |
38
|
4
|
|
|
|
|
4
|
while (1) { |
39
|
6
|
100
|
|
|
|
13
|
last if @res >= $n; |
40
|
5
|
100
|
|
|
|
11
|
last unless @_; |
41
|
2
|
|
|
|
|
8
|
push @res, splice(@_, @_*rand(), 1); |
42
|
|
|
|
|
|
|
} |
43
|
4
|
|
|
|
|
16
|
@res; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
# END_BLOCK: pick_n |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# BEGIN_BLOCK: shuffle |
48
|
|
|
|
|
|
|
sub shuffle { |
49
|
2
|
|
|
2
|
1
|
1028
|
my @res; |
50
|
2
|
|
|
|
|
3
|
while (1) { |
51
|
3
|
100
|
|
|
|
8
|
last unless @_; |
52
|
1
|
|
|
|
|
5
|
push @res, splice(@_, @_*rand(), 1); |
53
|
|
|
|
|
|
|
} |
54
|
2
|
|
|
|
|
17
|
@res; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
# END_BLOCK: shuffle |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# copy-pasted from List::MoreUtils |
59
|
|
|
|
|
|
|
# BEGIN_BLOCK: uniq |
60
|
|
|
|
|
|
|
sub uniq (@) { |
61
|
1
|
|
|
1
|
1
|
1034
|
my %seen = (); |
62
|
1
|
|
|
|
|
2
|
my $k; |
63
|
|
|
|
|
|
|
my $seen_undef; |
64
|
1
|
50
|
|
|
|
2
|
grep { defined $_ ? not $seen{ $k = $_ }++ : not $seen_undef++ } @_; |
|
8
|
|
|
|
|
30
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
# END_BLOCK: uniq |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
# ABSTRACT: Collection of routines that can be embedded e.g. using Dist::Zilla plugin |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |