line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::dategrep::Iterator::Uncompress; |
2
|
8
|
|
|
8
|
|
26
|
use strict; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
179
|
|
3
|
8
|
|
|
8
|
|
24
|
use warnings; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
186
|
|
4
|
8
|
|
|
8
|
|
22
|
use Moo; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
30
|
|
5
|
8
|
|
|
8
|
|
6265
|
use IPC::Cmd 'can_run'; |
|
8
|
|
|
|
|
278056
|
|
|
8
|
|
|
|
|
2310
|
|
6
|
|
|
|
|
|
|
extends 'App::dategrep::Iterator::Fh'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has filename => ( is => 'ro', required => 1 ); |
9
|
|
|
|
|
|
|
has fh => ( is => 'lazy' ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _build_fh { |
12
|
4
|
|
|
4
|
|
326
|
my $self = shift; |
13
|
4
|
|
|
|
|
5
|
my $fh; |
14
|
4
|
100
|
|
|
|
39
|
if ( $self->filename =~ /\.(bz|bz2)$/ ) { |
|
|
50
|
|
|
|
|
|
15
|
2
|
100
|
66
|
|
|
24
|
if ( $^O eq 'MSWin32' or !can_run('bzcat') ) { |
16
|
1
|
|
|
|
|
595
|
require IO::Uncompress::Bunzip2; |
17
|
1
|
|
|
|
|
3182
|
$fh = IO::Uncompress::Bunzip2->new( $self->filename ) |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
1
|
|
|
|
|
383
|
my @uncompress = qw(bzcat); |
22
|
1
|
50
|
|
|
|
2499
|
open( $fh, '-|', @uncompress, $self->filename ) |
23
|
|
|
|
|
|
|
or die "Can't open @uncompress: $!\n"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ( $self->filename =~ /\.(gz|z)$/ ) { |
27
|
2
|
100
|
66
|
|
|
20
|
if ( $^O eq 'MSWin32' or !can_run('gzip') ) { |
28
|
1
|
|
|
|
|
787
|
require IO::Uncompress::Gunzip; |
29
|
1
|
|
|
|
|
25275
|
$fh = IO::Uncompress::Gunzip->new( $self->filename ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
1
|
|
|
|
|
66692
|
my @uncompress = qw(gzip -c -d); |
33
|
1
|
50
|
|
|
|
2673
|
open( $fh, '-|', @uncompress, $self->filename ) |
34
|
|
|
|
|
|
|
or die "Can't open @uncompress: $!\n"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
0
|
|
|
|
|
0
|
die "unknown ending for compressed file " . $self->filename . "\n"; |
39
|
|
|
|
|
|
|
} |
40
|
4
|
|
|
|
|
1990
|
return $fh; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |