| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Stencil; |
|
2
|
4
|
|
|
4
|
|
380075
|
use v5.20; |
|
|
4
|
|
|
|
|
11
|
|
|
3
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
|
4
|
|
|
|
|
18
|
|
|
|
4
|
|
|
|
|
1073
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
5
|
|
|
|
|
|
|
require XSLoader; |
|
6
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub from_file { |
|
9
|
3
|
|
|
3
|
1
|
319691
|
my ($class, $file, %opts) = @_; |
|
10
|
3
|
100
|
|
|
|
354
|
open my $fh, '<:utf8', $file or die "Text::Stencil: can't open $file: $!"; |
|
11
|
2
|
|
|
|
|
10
|
local $/; |
|
12
|
2
|
|
|
|
|
45
|
my $content = <$fh>; |
|
13
|
2
|
|
|
|
|
13
|
close $fh; |
|
14
|
2
|
100
|
|
|
|
16
|
if ($content =~ /^__HEADER__\s*\n(.*?)^__ROW__\s*\n(.*?)^__FOOTER__\s*\n(.*)/ms) { |
|
15
|
1
|
|
|
|
|
20
|
$class->new(%opts, header => $1, row => $2, footer => $3); |
|
16
|
|
|
|
|
|
|
} else { |
|
17
|
1
|
|
|
|
|
19
|
$class->new(%opts, row => $content); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
|
22
|
|
|
|
|
|
|
__END__ |