| 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
| |||||||||||||
| 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
| |||||||||||||
| 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 || ''
MC/DC0%0/1
$object->$method || ''
$object->$method
Truth table50%1/2
A
A= $object->$method
| |||||||||||||
| 40 | } | ||||||||||||
| 41 | 633 | print "\n"; | |||||||||||
| 42 | } | ||||||||||||