line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Amazon::MechanicalTurk::IOUtil; |
2
|
22
|
|
|
22
|
|
113
|
use strict; |
|
22
|
|
|
|
|
46
|
|
|
22
|
|
|
|
|
703
|
|
3
|
22
|
|
|
22
|
|
113
|
use warnings; |
|
22
|
|
|
|
|
38
|
|
|
22
|
|
|
|
|
545
|
|
4
|
22
|
|
|
22
|
|
110
|
use IO::File; |
|
22
|
|
|
|
|
57
|
|
|
22
|
|
|
|
|
3823
|
|
5
|
22
|
|
|
22
|
|
118
|
use Carp; |
|
22
|
|
|
|
|
38
|
|
|
22
|
|
|
|
|
7723
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub readContents { |
10
|
0
|
|
|
0
|
0
|
|
my ($class, $io) = @_; |
11
|
0
|
|
|
|
|
|
my $text = ''; |
12
|
0
|
0
|
|
|
|
|
if (UNIVERSAL::isa($io, "GLOB")) { |
13
|
0
|
|
|
|
|
|
while (my $line = <$io>) { |
14
|
0
|
|
|
|
|
|
$text .= $line; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
else { |
18
|
0
|
|
|
|
|
|
my $in = IO::File->new($io, "r"); |
19
|
0
|
0
|
|
|
|
|
if (!$in) { |
20
|
0
|
|
|
|
|
|
Carp::croak("Couldn't open $io - $!"); |
21
|
|
|
|
|
|
|
} |
22
|
0
|
|
|
|
|
|
while (my $line = <$in>) { |
23
|
0
|
|
|
|
|
|
$text .= $line; |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
$in->close; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
return $text; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub writeContents { |
31
|
0
|
|
|
0
|
0
|
|
my ($class, $io, $content) = @_; |
32
|
0
|
|
|
|
|
|
my $text = ''; |
33
|
0
|
0
|
|
|
|
|
if (UNIVERSAL::isa($io, "GLOB")) { |
34
|
0
|
|
|
|
|
|
print $io $content; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
|
|
|
|
my $out = IO::File->new($io, "w"); |
38
|
0
|
0
|
|
|
|
|
if (!$out) { |
39
|
0
|
|
|
|
|
|
Carp::croak("Couldn't open $io - $!"); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
print $out $content; |
42
|
0
|
|
|
|
|
|
$out->close; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return 1; |