eg/advanced.pl

filter: Statementstmt 100% 25 / 25 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 32 / 32 CC 2 SCAR 2.9
CC
2
Cov
100%
selector_procedure
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« eg/selection.pl ↑ Summary blib/lib/Geo/Postcodes/NO/Selection.pm »
1 #!/usr/bin/perl
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Geo::Postcodes::NO;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Digest::SHA;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 my @arg1 = ('postcode' => '(..)\1');
8 1 print "All postcodes where the first two digits are repeated:\n";
9 1 my @postcodes = Geo::Postcodes::NO::selection(@arg1);
10 1 print join(", ", @postcodes), ".\n\n";
11  
12 1 print "As above, but with the addition of a procedure:\n";
13 1 my @arg2 = (@arg1, 'procedure' => \&selector_procedure);
14 1 @postcodes = Geo::Postcodes::NO::selection(@arg2);
15 1 print join(", ", @postcodes), ".\n\n";
16  
17 sub selector_procedure
18 47 ▶{
Subroutine selector_procedure: called CC=2 SCAR=6.9
19 47 my $postcode = shift;
20 47 my $location = Geo::Postcodes::NO::location_of($postcode);
21 47 my $digest = Digest::SHA::sha1_hex($location);
22 47 ▶ return 1 if substr($digest, 10, 5) =~ /[a-f]/;
Branch: 1 branch
BranchTrueFalseTotal
if substr($digest, 10, 5) =~ /[a-f]/ 46 1 47
23 1 return 0;
24 }
« eg/selection.pl ↑ Summary blib/lib/Geo/Postcodes/NO/Selection.pm »