line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Sah::Coerce::perl::To_array::From_str::comma_sep; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-04-08'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Data-Sah-CoerceBundle-To_array-From_str-comma_sep'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.013'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
2561
|
use 5.010001; |
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
10
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
162
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
13
|
|
|
|
|
|
|
+{ |
14
|
2
|
|
|
2
|
0
|
4086
|
v => 4, |
15
|
|
|
|
|
|
|
summary => 'Coerce array from a comma-separated items in a string', |
16
|
|
|
|
|
|
|
prio => 60, # a bit lower than normal |
17
|
|
|
|
|
|
|
args => { |
18
|
|
|
|
|
|
|
separator => { |
19
|
|
|
|
|
|
|
schema => ['str*', min_len=>1], |
20
|
|
|
|
|
|
|
default => ',', |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
# TODO: separators |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub coerce { |
28
|
2
|
|
|
2
|
0
|
35
|
my %cargs = @_; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
5
|
my $dt = $cargs{data_term}; |
31
|
2
|
|
|
|
|
4
|
my $gen_args = $cargs{args}; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
4
|
my $res = {}; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
6
|
$res->{expr_match} = "!ref($dt)"; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
100
|
|
|
11
|
my $sep = $gen_args->{separator} // ','; |
38
|
2
|
|
|
|
|
6
|
$res->{expr_coerce} = "[split /\\s*\Q$sep\E\\s*/, $dt]"; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
7
|
$res; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
# ABSTRACT: Coerce array from a comma-separated items in a string |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding UTF-8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Data::Sah::Coerce::perl::To_array::From_str::comma_sep - Coerce array from a comma-separated items in a string |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 VERSION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This document describes version 0.013 of Data::Sah::Coerce::perl::To_array::From_str::comma_sep (from Perl distribution Data-Sah-CoerceBundle-To_array-From_str-comma_sep), released on 2021-04-08. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
To use in a Sah schema: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
["array",{"x.perl.coerce_rules"=>["From_str::comma_sep"]}] |
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_array-From_str-comma_sep>. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SOURCE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah-CoerceBundle-To_array-From_str-comma_sep>. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 BUGS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://github.com/perlancar/perl-Data-Sah-CoerceBundle-To_array-From_str-comma_sep/issues> |
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 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<Data::Sah::Coerce::perl::To_array::From_str::csv_row> can accomplish the same |
87
|
|
|
|
|
|
|
thing, with additional ability to handle escapes and quotes. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<Data::Sah::Coerce::perl::To_array::From_str::tsv_row> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This software is copyright (c) 2021, 2020, 2019, 2018, 2016 by perlancar@cpan.org. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |