line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Sah::Coerce::perl::num::str_num_id; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-07-26'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1773
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
145
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub meta { |
11
|
|
|
|
|
|
|
+{ |
12
|
3
|
|
|
3
|
0
|
42
|
v => 4, |
13
|
|
|
|
|
|
|
might_fail => 1, |
14
|
|
|
|
|
|
|
prio => 50, |
15
|
|
|
|
|
|
|
precludes => [qr/\Astr_num_(\w+)\z/], |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub coerce { |
20
|
3
|
|
|
3
|
0
|
41
|
my %args = @_; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
6
|
my $dt = $args{data_term}; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
5
|
my $res = {}; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
8
|
$res->{expr_match} = "!ref($dt)"; |
27
|
3
|
|
50
|
|
|
18
|
$res->{modules}{"Parse::Number::ID"} //= 0; |
28
|
3
|
|
|
|
|
12
|
$res->{expr_coerce} = join( |
29
|
|
|
|
|
|
|
"", |
30
|
|
|
|
|
|
|
"do { ", |
31
|
|
|
|
|
|
|
" my \$text = $dt; my \$res = Parse::Number::ID::parse_number_id(text=>$dt); ", |
32
|
|
|
|
|
|
|
" if (!defined \$res) { [qq(Invalid number: \$text)] } ", |
33
|
|
|
|
|
|
|
" else { [undef, \$res] } ", |
34
|
|
|
|
|
|
|
"}", |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
9
|
$res; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
# ABSTRACT: Parse number using Parse::Number::ID |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding UTF-8 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Data::Sah::Coerce::perl::num::str_num_id - Parse number using Parse::Number::ID |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 VERSION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This document describes version 0.003 of Data::Sah::Coerce::perl::num::str_num_id (from Perl distribution Data-Sah-CoerceBundle-Num-str_num_id), released on 2019-07-26. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 DESCRIPTION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The rule is not enabled by default. You can enable it in a schema using e.g.: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
["num", "x.perl.coerce_rules"=>["str_num_id"]] |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=for Pod::Coverage ^(meta|coerce)$ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 HOMEPAGE |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah-CoerceBundle-Num-str_num_id>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SOURCE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah-CoerceBundle-Num-str_num_id>. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 BUGS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah-CoerceBundle-Num-str_num_id> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
78
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
79
|
|
|
|
|
|
|
feature. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2018 by perlancar@cpan.org. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
90
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |