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