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