File Coverage

lib/Perlmazing/Perlmazing/fout.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 8 50.0
condition 1 3 33.3
subroutine 4 4 100.0
pod 0 1 0.0
total 30 37 81.0


line stmt bran cond sub pod time code
1 1     1   14 use Perlmazing qw(croak);
  1         2  
  1         10  
2              
3             sub main {
4 1     1 0 2 my $filename = shift;
5 1         2 my $data = shift;
6 1         2 my $binmode = shift;
7 1         1 my $encoding;
8             {
9 1     1   9 no warnings 'numeric';
  1         2  
  1         243  
  1         2  
10 1 50 33     8 if ($binmode and ($binmode + 0) ne '1') {
11 1         1 $encoding = $binmode;
12 1         2 undef $binmode;
13             }
14             }
15 1 50   1   680 open my $out, '>'.($encoding ? ":encoding($encoding)" : ''), $filename or croak "Cannot write to $filename: $!";
  1 50       13  
  1         5  
  1         34  
16 1 50       1149 binmode($out) if $binmode;
17 1         4 print $out $data;
18 1         60 close $out;
19             }
20              
21             1;