line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Scalar::Util::Numeric::PP; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-01-22'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
708
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
512
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
isint |
14
|
|
|
|
|
|
|
isnum |
15
|
|
|
|
|
|
|
isnan |
16
|
|
|
|
|
|
|
isinf |
17
|
|
|
|
|
|
|
isneg |
18
|
|
|
|
|
|
|
isfloat |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub isint { |
22
|
22
|
|
|
22
|
1
|
40
|
local $_ = shift; |
23
|
22
|
100
|
|
|
|
53
|
return 0 unless defined; |
24
|
21
|
100
|
|
|
|
155
|
return 1 if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s; |
25
|
12
|
|
|
|
|
37
|
0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub isnan($) { |
29
|
21
|
|
|
21
|
1
|
28
|
local $_ = shift; |
30
|
21
|
100
|
|
|
|
48
|
return 0 unless defined; |
31
|
20
|
100
|
|
|
|
87
|
return 1 if /\A\s*[+-]?nan\s*\z/is; |
32
|
14
|
|
|
|
|
47
|
0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub isinf($) { |
36
|
19
|
|
|
19
|
1
|
30
|
local $_ = shift; |
37
|
19
|
100
|
|
|
|
44
|
return 0 unless defined; |
38
|
18
|
100
|
|
|
|
84
|
return 1 if /\A\s*[+-]?inf(?:inity)?\s*\z/is; |
39
|
12
|
|
|
|
|
54
|
0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub isneg($) { |
43
|
6
|
|
|
6
|
1
|
13
|
local $_ = shift; |
44
|
6
|
100
|
|
|
|
17
|
return 0 unless defined; |
45
|
5
|
100
|
|
|
|
31
|
return 1 if /\A\s*-/; |
46
|
2
|
|
|
|
|
7
|
0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub isnum($) { |
50
|
14
|
|
|
14
|
1
|
28
|
local $_ = shift; |
51
|
14
|
100
|
|
|
|
39
|
return 0 unless defined; |
52
|
13
|
100
|
|
|
|
25
|
return 1 if isint($_); |
53
|
9
|
100
|
|
|
|
18
|
return 1 if isfloat($_); |
54
|
4
|
|
|
|
|
15
|
0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub isfloat($) { |
58
|
29
|
|
|
29
|
1
|
51
|
local $_ = shift; |
59
|
29
|
100
|
|
|
|
75
|
return 0 unless defined; |
60
|
28
|
100
|
66
|
|
|
327
|
return 1 if /\A\s*[+-]? |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
61
|
|
|
|
|
|
|
(?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) |
62
|
|
|
|
|
|
|
([eE][+-]?[0-9]+)?\s*\z/sx && $1 || $2 || $3; |
63
|
15
|
100
|
100
|
|
|
33
|
return 1 if isnan($_) || isinf($_); |
64
|
11
|
|
|
|
|
36
|
0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
# ABSTRACT: Pure-perl drop-in replacement/approximation of Scalar::Util::Numeric |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Scalar::Util::Numeric::PP - Pure-perl drop-in replacement/approximation of Scalar::Util::Numeric |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This document describes version 0.04 of Scalar::Util::Numeric::PP (from Perl distribution Scalar-Util-Numeric-PP), released on 2016-01-22. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESCRIPTION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This module is written mainly for the convenience of L<Data::Sah>, as a drop-in |
89
|
|
|
|
|
|
|
pure-perl replacement for the XS module L<Scalar::Util::Numeric>, in the case |
90
|
|
|
|
|
|
|
when Data::Sah needs to generate code that uses PP modules instead of XS ones. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Not all functions from Scalar::Util::Numeric have been provided. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 FUNCTIONS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 isint |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 isfloat |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 isnum |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 isneg |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 isinf |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 isnan |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 HOMEPAGE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Scalar-Util-Numeric-PP>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SOURCE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Scalar-Util-Numeric-PP>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 BUGS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Scalar-Util-Numeric-PP> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
121
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
122
|
|
|
|
|
|
|
feature. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SEE ALSO |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L<Data::Sah> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<Scalar::Util::Numeric> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This software is copyright (c) 2016 by perlancar@cpan.org. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
139
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |