blib/lib/Tie/Anon.pm

filter: Statementstmt 87.5% 28 / 32 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 84.4% 38 / 45 CC 4 SCAR 5.1
CC
4
Cov
84%
__ANON__
2.1
__ANON__
2.1
__ANON__
2.1
CRAP 1.7
↑ Summary
1 package Tie::Anon;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our $VERSION = "0.02";
8  
9 4 our @EXPORT = our @EXPORT_OK = qw(tiea tieh ties);
10  
11 4 my %sigil_for = (
12 tiea => '@',
13 tieh => '%',
14 ties => '$'
15 );
16  
17 4 foreach my $method (keys %sigil_for) {
18 12 my $sigil = $sigil_for{$method};
19 0 ▶ *{$method} = eval(<<"DEF");
Subroutine __ANON__: called CC=2 SCAR=7.5
Subroutine __ANON__: called CC=2 SCAR=7.5
Subroutine __ANON__: not called CC=2 SCAR=7.5
Branch: 3 branches
BranchTrueFalseTotal
unless defined $result 1 1 2
unless defined $result 2 2 4
unless defined $result 0 0 0
20 sub {
21 my \$class = shift;
22 my \$result = tie(my ${sigil}tied, \$class, \@_);
23 return undef if not defined \$result;
24 return \\${sigil}tied;
25 }
26 DEF
27 }
28  
29 4 1;
30 __END__
↑ Summary