blib/lib/Tie/File/AnyData.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 45 / 45 CC 3 SCAR 5.1
CC
3
Cov
100%
TIEARRAY
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
↑ Summary
1 package Tie::File::AnyData;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Tie::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = '0.03';
9  
10 sub TIEARRAY
11 5 ▶ {
Subroutine TIEARRAY: called CC=3 SCAR=11.0
12 5 my ($pack,$file,%opts) = @_;
13 5 my $code;
14 ## We process $opts{'code'} (if present).
15 5 ▶ if (defined $opts{'code'}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"code"}) 3 2 5
16 3 $code = $opts{'code'};
17 3 delete $opts{'code'};
18  
19 ## We override Tie::File::_read_record.
20 3 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 512 ▶ *Tie::File::_read_record = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 512 my ($self) = @_;
23 512 my $rec;
24 512 $rec = $self -> {_get_next_rec} -> ($self->{'fh'});
25 512 return $rec;
26 }
27 3 }
28 ## After processing the (optional) extra option we call Tie::File::TIEARRAY
29 5 my $self;
30 5 eval { $self = Tie::File::TIEARRAY("Tie::File",$file,%opts) };
31 5 $@ =~ s/at.+//s;
32 5 ▶ croak $@ if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 4 5
33 4 $self->{_get_next_rec} = $code;
34 4 return $self;
35 }
36  
37 3 1;
38  
39 __END__
↑ Summary