MechanicalTurk/IOUtil.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 53 CC 5 SCAR 20.8
CC
5
Cov
0%
readContents
12.0
writeContents
12.0
BEGIN
2.0
CRAP 8.0
1 package Net::Amazon::MechanicalTurk::IOUtil;
2 use strict;
3 use warnings;
4 use IO::File;
5 use Carp;
6  
7 our $VERSION = '1.00';
8  
9 sub readContents {
10 my ($class, $io) = @_;
11 my $text = '';
12 if (UNIVERSAL::isa($io, "GLOB")) {
13 while (my $line = <$io>) {
14 $text .= $line;
15 }
16 }
17 else {
18 my $in = IO::File->new($io, "r");
19 if (!$in) {
20 Carp::croak("Couldn't open $io - $!");
21 }
22 while (my $line = <$in>) {
23 $text .= $line;
24 }
25 $in->close;
26 }
27 return $text;
28 }
29  
30 sub writeContents {
31 my ($class, $io, $content) = @_;
32 my $text = '';
33 if (UNIVERSAL::isa($io, "GLOB")) {
34 print $io $content;
35 }
36 else {
37 my $out = IO::File->new($io, "w");
38 if (!$out) {
39 Carp::croak("Couldn't open $io - $!");
40 }
41 print $out $content;
42 $out->close;
43 }
44 }
45  
46 return 1;