eg/selection.pl

filter: Statementstmt 100% 28 / 28 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 94.8% 37 / 39 CC 3 SCAR 7.0
CC
3
Cov
97%
print_it
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Geo/Postcodes/NO.pm ↑ Summary eg/advanced.pl »
1 #!/usr/bin/perl
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Geo::Postcodes::NO;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶unless (@ARGV == 2)
Branch: 1 branch
BranchTrueFalseTotal
unless (@ARGV == 2) 1 2 3
7 {
8 1 print "Usage: selection.pl <field> <value>\n";
9 1 print "Legal fields: ", join(" ", Geo::Postcodes::NO::get_fields()), ".\n";
10 1 exit;
11 }
12  
13 2 my $field = shift(@ARGV);
14 2 my $value = shift(@ARGV);
15 2 my @fields;
16  
17 2 ▶if (Geo::Postcodes::NO::is_field($field))
Branch: 1 branch
BranchTrueFalseTotal
if (Geo::Postcodes::NO::is_field($field)) { } 1 1 2
18 {
19 1 @fields = Geo::Postcodes::NO::get_fields();
20 1 foreach my $m (@fields)
21 {
22 7 printf("%-14s", ucfirst($m));
23 }
24 1 print "\n";
25  
26 1 Geo::Postcodes::NO->selection_loop(\&print_it, $field, $value);
27 1 print "\n";
28 }
29 else # illegal field.
30 {
31 1 print "Not a legal field '$field'.\n";
32 }
33  
34 sub print_it
35 633 ▶{
Subroutine print_it: called CC=3 SCAR=11.1
36 633 my $object = shift;
37 633 foreach my $method (@fields)
38 {
39 4431 ▶ printf("%-14s", $object->$method() || "");
Condition50%1/2
$object->$method || ''
l!l
44310
MC/DC0%0/1
$object->$method || ''
$object->$method
Truth table50%1/2
A
A= $object->$method
Aresult
11
00
40 }
41 633 print "\n";
42 }
« blib/lib/Geo/Postcodes/NO.pm ↑ Summary eg/advanced.pl »