line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
493
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Array::Split; |
5
|
|
|
|
|
|
|
$Array::Split::VERSION = '1.173190'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: split an array into sub-arrays |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
208
|
use Sub::Exporter::Simple qw( split_by split_into ); |
|
1
|
|
|
|
|
8382
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
224
|
use List::Util 'max'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
99
|
|
11
|
1
|
|
|
1
|
|
319
|
use POSIX 'ceil'; |
|
1
|
|
|
|
|
4622
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub split_by { |
14
|
2
|
|
|
2
|
1
|
793
|
my $split_size = shift; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
6
|
$split_size = max( $split_size, 1 ); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
2
|
my @sub_arrays; |
19
|
2
|
|
|
|
|
6
|
while ( @_ ) { |
20
|
5
|
|
|
|
|
11
|
push @sub_arrays, [ splice @_, 0, $split_size ]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
5
|
return @sub_arrays; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub split_into { |
27
|
1
|
|
|
1
|
1
|
899
|
my ( $count, @original ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
3
|
$count = max( $count, 1 ); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
16
|
my $size = ceil @original / $count; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
3
|
return split_by( $size, @original ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |