line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::ValidOp::Check::number; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use base qw/ CGI::ValidOp::Check /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
679
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub default { |
8
|
|
|
|
|
|
|
( |
9
|
12
|
|
|
12
|
1
|
56
|
qr/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/, |
10
|
|
|
|
|
|
|
'$label must be a number.', |
11
|
|
|
|
|
|
|
) |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub integer { |
15
|
|
|
|
|
|
|
( |
16
|
13
|
|
|
13
|
1
|
60
|
qr/^[+-]?\d+$/, |
17
|
|
|
|
|
|
|
'$label must be an integer.', |
18
|
|
|
|
|
|
|
) |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub decimal { |
22
|
|
|
|
|
|
|
( |
23
|
12
|
|
|
12
|
1
|
53
|
qr/^-?(?:\d+(?:\.\d*)?|\.\d+)$/, |
24
|
|
|
|
|
|
|
'$label must be a decimal number.', |
25
|
|
|
|
|
|
|
) |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub positive_int { |
29
|
|
|
|
|
|
|
( |
30
|
0
|
|
|
0
|
0
|
0
|
qr/^[+]?\d+$/, |
31
|
|
|
|
|
|
|
'$label must be a positive integer.', |
32
|
|
|
|
|
|
|
) |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub positive_list { |
36
|
12
|
|
|
12
|
0
|
17
|
my $self = shift; |
37
|
|
|
|
|
|
|
sub { |
38
|
12
|
|
|
12
|
|
22
|
my ( $input ) = @_; |
39
|
12
|
50
|
|
|
|
41
|
return $self->pass() unless defined $input; |
40
|
|
|
|
|
|
|
|
41
|
12
|
|
|
|
|
34
|
$input =~ m/(.*)/g; |
42
|
12
|
|
|
|
|
25
|
$input = $1; |
43
|
|
|
|
|
|
|
|
44
|
12
|
|
|
|
|
57
|
my @values = split(/\s*,\s*/, $input ); |
45
|
12
|
|
|
|
|
13
|
my @bad; |
46
|
12
|
|
|
|
|
23
|
for my $value ( @values ) { |
47
|
35
|
100
|
|
|
|
107
|
next if $value =~ m/^[+]?\d+$/; |
48
|
15
|
|
|
|
|
31
|
push( @bad, $value ); |
49
|
|
|
|
|
|
|
} |
50
|
12
|
100
|
|
|
|
28
|
if ( @bad ) { |
51
|
8
|
|
|
|
|
20
|
my $error = '$label: "' . join( ', ', @bad ); |
52
|
8
|
100
|
|
|
|
24
|
$error .= (@bad > 1) ? '" are not positive integers.' |
53
|
|
|
|
|
|
|
: '" is not a positive integer.'; |
54
|
8
|
|
|
|
|
27
|
return $self->fail( $error ); |
55
|
|
|
|
|
|
|
} |
56
|
4
|
|
|
|
|
18
|
return $self->pass( join(', ', @values )); |
57
|
|
|
|
|
|
|
} |
58
|
12
|
|
|
|
|
67
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |