| 1 | 23 | ▶ | use v5.26; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 23 | ▶ | use Object::Pad; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 23 | ▶ | use Getopt::Pad::Type::Number; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | class Getopt::Pad::Type::Float :isa(Getopt::Pad::Type::Number) :strict(params) { | ||||||||||
| 7 | 23 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 23 | our $VERSION = '0.06'; | |||||||||
| 10 | |||||||||||
| 11 | 23 | ▶ | use constant NAMES => ['f', 'float', 'num', 'number']; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 6 | ▶ | method checkFormat($value) { | ||||||||
|
Subroutine
checkFormat: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 14 | 6 | ▶ | return sprintf("'%s' is not a number", $value) if !looks_like_number($value); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | # Catches inf and nan however they are spelled, and values too large | ||||||||||
| 17 | # for a Perl number (1e999): times 0, an infinity becomes nan, and | ||||||||||
| 18 | # nan equals nothing. | ||||||||||
| 19 | 5 | my $number = $value + 0; | |||||||||
| 20 | 5 | ▶ | return sprintf("'%s' is not a finite number", $value) if $number * 0 != 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 2 | return undef; | |||||||||
| 22 | 23 | } | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 23 | 1; | |||||||||
| 26 | |||||||||||
| 27 | __END__ | ||||||||||