line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Utils; |
2
|
2
|
|
|
2
|
|
2864
|
use Modern::Perl; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
3
|
2
|
|
|
2
|
|
260
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
152
|
|
4
|
2
|
|
|
2
|
|
831
|
use PerlIO::gzip; |
|
2
|
|
|
|
|
1090
|
|
|
2
|
|
|
|
|
50
|
|
5
|
2
|
|
|
2
|
|
10
|
use Exporter; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
491
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.0.4'; # VERSION |
8
|
|
|
|
|
|
|
# ABSTRACT: Provide various of file operation |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = ('Exporter'); |
11
|
|
|
|
|
|
|
our @EXPORT = (); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw/read_handle write_handle/; |
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
14
|
|
|
|
|
|
|
gz => [qw/read_handle write_handle/] |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub read_handle { |
20
|
1
|
|
|
1
|
1
|
4606
|
my $file = shift; |
21
|
1
|
|
|
|
|
4
|
my $handle; |
22
|
1
|
50
|
|
|
|
14
|
if ($file =~/\.gz$/) { |
23
|
1
|
|
|
|
|
69
|
open $handle, "<:gzip", $file; |
24
|
|
|
|
|
|
|
} else { |
25
|
0
|
|
|
|
|
0
|
open $handle, "<", $file; |
26
|
|
|
|
|
|
|
} |
27
|
1
|
|
|
|
|
19
|
$handle->autoflush; |
28
|
1
|
|
|
|
|
109
|
return $handle; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub write_handle { |
33
|
0
|
|
|
0
|
1
|
|
my $file = shift; |
34
|
0
|
|
|
|
|
|
my $handle; |
35
|
0
|
0
|
|
|
|
|
if ($file =~/\.gz$/) { |
36
|
0
|
|
|
|
|
|
open $handle, ">:gzip", $file; |
37
|
|
|
|
|
|
|
} else { |
38
|
0
|
|
|
|
|
|
open $handle, ">", $file; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
$handle->autoflush; |
41
|
0
|
|
|
|
|
|
return $handle; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |