| 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
| |||||||||||
| 23 | 1 | return 0; | |||||||||
| 24 | } | ||||||||||