line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Sah::Coerce::perl::To_array::From_str::csv_row; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-04-08'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Data-Sah-Coerce-perl-To_array-From_str-csv_row'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1764
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
9
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
10
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
170
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
13
|
|
|
|
|
|
|
+{ |
14
|
1
|
|
|
1
|
0
|
10
|
v => 4, |
15
|
|
|
|
|
|
|
summary => 'Coerce a single CSV row to array of scalars', |
16
|
|
|
|
|
|
|
prio => 50, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $csv; |
21
|
|
|
|
|
|
|
sub coerce { |
22
|
1
|
|
33
|
1
|
0
|
16
|
$csv //= do { |
23
|
1
|
|
|
|
|
669
|
require Text::CSV; |
24
|
1
|
|
|
|
|
18016
|
Text::CSV->new ({ binary => 1, auto_diag => 1 }); |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
131
|
my %args = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
my $dt = $args{data_term}; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
2
|
my $res = {}; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
4
|
$res->{expr_match} = "!ref($dt)"; |
34
|
1
|
|
|
|
|
5
|
$res->{expr_coerce} = join( |
35
|
|
|
|
|
|
|
"", |
36
|
|
|
|
|
|
|
'do { ', |
37
|
|
|
|
|
|
|
'$' . __PACKAGE__ . "::csv->parse($dt); ", |
38
|
|
|
|
|
|
|
'[$' . __PACKAGE__ . "::csv->fields]; ", |
39
|
|
|
|
|
|
|
' }', |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
4
|
$res; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
# ABSTRACT: Coerce a single CSV row to array of scalars |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Data::Sah::Coerce::perl::To_array::From_str::csv_row - Coerce a single CSV row to array of scalars |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This document describes version 0.001 of Data::Sah::Coerce::perl::To_array::From_str::csv_row (from Perl distribution Data-Sah-Coerce-perl-To_array-From_str-csv_row), released on 2021-04-08. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
To use in a Sah schema: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
["array",{"x.perl.coerce_rules"=>["From_str::csv_row"]}] |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=for Pod::Coverage ^(meta|coerce)$ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 HOMEPAGE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah-Coerce-perl-To_array-From_str-csv_row>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SOURCE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah-Coerce-perl-To_array-From_str-csv_row>. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 BUGS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://github.com/perlancar/perl-Data-Sah-Coerce-perl-To_array-From_str-csv_row/issues> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
83
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
84
|
|
|
|
|
|
|
feature. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Data::Sah::Coerce::perl::To_array::From_str::comma_sep> accomplishes roughly |
89
|
|
|
|
|
|
|
the same thing without handling escapes or quotes. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L<Data::Sah::Coerce::perl::To_array::From_str::tsv_row> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<Data::Sah::Coerce::perl::To_array::From_str::csv> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This software is copyright (c) 2021 by perlancar@cpan.org. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
104
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |