| 1 | #!/usr/bin/env perl | ||
| 2 | 1 | ▶ | use v5.20; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Text::Stencil; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | my $csv = Text::Stencil->new( | |
| 7 | # CSV quotes a literal quote by doubling it (RFC 4180); json would escape | ||
| 8 | # it as \" instead, which a standards-conforming parser rejects. | ||
| 9 | row => q{"{name:replace:":""}",{age:int},"{email:replace:":""}"}, | ||
| 10 | separator => "\n", | ||
| 11 | ); | ||
| 12 | |||
| 13 | 1 | my @users = ( | |
| 14 | { name => 'Alice', age => 30, email => 'alice@example.com' }, | ||
| 15 | { name => 'Bob "B"', age => 25, email => 'bob@example.com' }, | ||
| 16 | { name => 'Charlie', age => 35, email => 'charlie@example.com' }, | ||
| 17 | ); | ||
| 18 | |||
| 19 | 1 | say '"Name","Age","Email"'; | |
| 20 | 1 | say $csv->render(\@users); | |