Create/OrderBy/Age.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 1 SCAR 6.9
CC
1
Cov
0%
add_file
2.0
finish
2.0
BEGIN
2.0
CRAP 2.0
1 package BackPAN::Index::Create::OrderBy::Age;
2 $BackPAN::Index::Create::OrderBy::Age::VERSION = '0.13';
3 use Moo;
4 use CPAN::DistnameInfo;
5  
6 has filehandle => (is => 'ro');
7 has entries => (is => 'ro', default => sub { return [] });
8  
9 sub add_file
10 {
11 my $self = shift;
12 my ($path, $time, $size) = @_;
13 my $entries = $self->entries;
14  
15 push(@{ $entries }, [$path,$time,$size] );
16 }
17  
18 sub finish
19 {
20 my $self = shift;
21 my $entries = $self->entries;
22 my $fh = $self->filehandle;
23  
24 foreach my $entry (sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] }
25 @{ $entries })
26 {
27 printf $fh "%s %d %d\n", @$entry;
28 }
29 }
30  
31 1;