eg/csv_export.pl

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 15 / 15 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« XS.xs ↑ Summary eg/from_file.pl »
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);
« XS.xs ↑ Summary eg/from_file.pl »