eg/from_file.pl

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 20 / 20 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« eg/csv_export.pl ↑ Summary eg/html_table.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 File::Temp 'tempfile';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Text::Stencil;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # create a template file with section markers
8 1 my ($fh, $fname) = tempfile(SUFFIX => '.tpl', UNLINK => 1);
9 1 print $fh <<'TPL';
10 __HEADER__
11 <ul>
12 __ROW__
13 <li>{name:html} ({score:int})</li>
14 __FOOTER__
15 </ul>
16 TPL
17 1 close $fh;
18  
19 1 my $s = Text::Stencil->from_file($fname);
20  
21 1 say $s->render([
22 { name => 'Alice & Bob', score => 95 },
23 { name => '<Eve>', score => 87 },
24 ]);
« eg/csv_export.pl ↑ Summary eg/html_table.pl »