blib/lib/Poem.pm

filter: Statementstmt 61.3% 27 / 44 Branchbran 30.0% 6 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 54.1% 39 / 72 CC 11 SCAR 32.9
CC
11
Cov
52%
read_poem
41.0
unimport
2.0
import
1.0
CRAP 26.9
↑ Summary
1 #
2 # $Id: Poem.pm,v 0.1 2006/03/25 10:43:27 dankogai Exp dankogai $
3 #
4 package Poem;
5 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our $VERSION = sprintf "%d.%02d", q$Revision: 0.1 $ =~ /(\d+)/g;
9  
10 1 ▶use Filter::Util::Call;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 my %opt = ();
12 1 ▶sub import{
Subroutine import: called CC=1 SCAR=0.2
13 1 my $class = shift;
14 0 %opt = map { $_ => 1 } @_;
15 1 filter_add(\&read_poem);
16 }
17 0 ▶sub unimport{
Subroutine unimport: not called CC=1 SCAR=6.9
18 0 my $class = shift;
19 0 filter_del();
20 0 %opt = ();
21 }
22 1 ▶sub read_poem{
Subroutine read_poem: called CC=11 SCAR=37.1
Pod undocumented
23 1 my $pkg = __PACKAGE__;
24 1 my ($status, $no_seen, @poem);
25 1 ▶ while ($status = filter_read()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status = &filter_read()) 6 1 7
26 6 ▶ if (/^\s*no\s+$pkg\s*;\s*?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*no\s+$pkg\s*;\s*?$/) 0 6 6
27 0 $no_seen=1;
28 0 last;
29 }
30 6 push @poem, $_;
31 6 $_ = q();
32 }
33 1 ▶ if ($opt{-review}){
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{'-review'}) { } 0 1 1
34 # eval does not work in filter. So we ask via pipe
35 0 print "# Your Poem:\n";
36 0 print @poem;
37 my $perlopt =
38 $opt{-deparse} ? "-MO=Deparse" :
39 0 ▶ $opt{-act} ? '-T' : '-Twc';
Branch: 2 branches
BranchTrueFalseTotal
$opt{'-deparse'} ? : 0 0 0
$opt{'-act'} ? : 0 0 0
40 0 print "# Review by $^X $perlopt\n";
41 0 ▶ open my $perl, "| $^X $perlopt 2>&1" or die "$!";
Branch: 1 branch
BranchTrueFalseTotal
open my $perl, "| $^X $perlopt 2>&1" or die "$!" 0 0 0
42 0 ▶ $opt{-strict} and print $perl "use strict;\n";
Branch: 1 branch
BranchTrueFalseTotal
$opt{"-strict"} and print $perl "use strict;\n" 0 0 0
43 0 ▶ $opt{-utf8} and print $perl "use utf8;\n";
Branch: 1 branch
BranchTrueFalseTotal
$opt{"-utf8"} and print $perl "use utf8;\n" 0 0 0
44 0 print $perl @poem;
45 0 close $perl;
46 }else{
47 1 ▶ print @poem unless $opt{-quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $opt{"-quiet"} 1 0 1
48 }
49 1 ▶ if ($no_seen){
Branch: 1 branch
BranchTrueFalseTotal
if ($no_seen) { } 0 1 1
50 0 $_ .= "no $pkg;\n";
51 0 return 1;
52 }else{
53 1 return 0;
54 }
55 }
56  
57 # Preloaded methods go here.
58  
59 1 1;
60 __END__
↑ Summary