ForExample/ModuleEmbedCatalog.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 48 CC 6 SCAR 34.7
CC
6
Cov
0%
extract
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 32.0
1 package App::ForExample::ModuleEmbedCatalog;
2  
3 use strict;
4 use warnings;
5  
6 {
7 my $catalog;
8 sub extract {
9 my $self = shift;
10 my $module = shift;
11 my $end = shift;
12  
13 $end = '__ASSET__' unless defined $end;
14 $end = qr/^\Q$end\E$/ unless ref $end eq 'Regexp';
15  
16 my $handle = "${module}::DATA";
17  
18 return $catalog ||= do {
19 my %catalog;
20 my ($path, $content);
21 while (<$handle>) {
22 if ( ! $path ) {
23 next unless m/\S/;
24 chomp; $path = $_;
25 $content = '';
26 }
27 elsif ( $_ =~ $end ) {
28 my $__ = $content;
29 $catalog{$path} = \$__;
30 undef $path;
31 undef $content;
32 }
33 else {
34 $content .= $_;
35 }
36 }
37 \%catalog;
38 };
39 }
40 }
41  
42 1;