Simple/Base/Parser.pm

filter: Statementstmt 96.1% 150 / 156 Branchbran 72.8% 67 / 92 Conditioncond 72.9% 27 / 37 MC/DCmcdc 59.0% 13 / 22 Subroutinesub 96.0% 24 / 25 Podpod n/a totaltotal 84.6% 281 / 332 CC 63 SCAR 22.1
CC
63
Cov
86%
_walk_unknown
20.0
_add_stack
16.1
_walk
13.0
CRAP 9.1
« Simple/Cache.pm ↑ Summary Simple/Caller.pm »
1 ## no critic (ProhibitUnusedPrivateSubroutines)
2 package Text::Template::Simple::Base::Parser;
3 32 $Text::Template::Simple::Base::Parser::VERSION = '0.91';
4 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 32 ▶use Text::Template::Simple::Util qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use Text::Template::Simple::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 32 ▶use constant MAPKEY_NUM => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 32 my %INTERNAL = __PACKAGE__->_set_internal_templates;
12  
13 137 ▶sub _needs_object {
Subroutine _needs_object: called CC=1 SCAR=0.0
14 137 my $self = shift;
15 137 $self->[NEEDS_OBJECT]++;
16 137 return $self;
17 }
18  
19 140 ▶sub _internal {
Subroutine _internal: called CC=4 SCAR=15.9
20 140 my $self = shift;
21 140 ▶ my $id = shift || fatal('tts.base.parser._internal.id');
Condition33%1/3
shift() || fatal('tts.base.parser._internal.id')
l!l&&r!l&&!r
14000
MC/DC0%0/2
shift() || fatal('tts.base.parser._internal.id')
shift() fatal('tts.base.parser._internal.id')
Truth table33%1/3
A || B
A= shift()B= fatal('tts.base.parser._internal.id')
ABresult
1X1
011
000
22 140 ▶ my $rv = $INTERNAL{ $id } || fatal('tts.base.parser._internal.id');
Condition33%1/3
$INTERNAL{$id} || fatal('tts.base.parser._internal.id')
l!l&&r!l&&!r
14000
MC/DC0%0/2
$INTERNAL{$id} || fatal('tts.base.parser._internal.id')
$INTERNAL{$id} fatal('tts.base.parser._internal.id')
Truth table33%1/3
A || B
A= $INTERNAL{$id}B= fatal('tts.base.parser._internal.id')
ABresult
1X1
011
000
23 140 ▶ LOG( INTERNAL => "TEMPLATE: $id" ) if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 140 140
24 140 return $rv;
25 }
26  
27 251 ▶sub _parse {
Subroutine _parse: called CC=7 SCAR=19.7
28 251 my($self, $raw, $opt) = @_;
29  
30 # $opt->
31 # map_keys: code sections are hash keys
32 # as_is : i.e.: do not parse -> static include
33  
34 #$self->[NEEDS_OBJECT] = 0; # reset
35  
36 251 my($ds, $de) = @{ $self->[DELIMITERS] };
37 251 ▶ my $faker = $self->[INSIDE_INCLUDE] ? $self->_output_buffer_var
Branch: 1 branch
BranchTrueFalseTotal
$self->[22] ? : 250 1 251
38 : $self->[FAKER]
39 ;
40 251 my $buf_hash = $self->[FAKER_HASH];
41 251 my($mko, $mkc) = $self->_parse_mapkeys( $opt->{map_keys}, $faker, $buf_hash );
42  
43 251 ▶ LOG( RAW => $raw ) if DEBUG > DEBUG_LEVEL_INSANE;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() > 3 0 251 251
44  
45 my $h = {
46 205 ▶ raw => sub { ";$faker .= q~$_[0]~;" },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 249 ▶ capture => sub { ";$faker .= sub {" . $_[0] . '}->();'; },
Subroutine __ANON__: called CC=1 SCAR=0.0
48 35 ▶ code => sub { $_[0] . q{;} },
Subroutine __ANON__: called CC=1 SCAR=0.0
49 251 };
50  
51 # little hack to convert delims into escaped delims for static inclusion
52 251 ▶ $raw =~ s{\Q$ds}{$ds!}xmsg if $opt->{as_is};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"as_is"} 11 240 251
53  
54 251 my($code, $inside) = $self->_walk( $raw, $opt, $h, $mko, $mkc );
55  
56 251 ▶ $self->[FILENAME] ||= '<ANON>';
Condition100%2/2
$self->[25] ||= "<ANON>"
l!l
15992
MC/DC100%1/1
$self->[25] ||= "<ANON>"
$self->[25]
Truth table100%2/2
A
A= $self->[25]
Aresult
11
00
57  
58 251 ▶ fatal(
Branch: 2 branches
BranchTrueFalseTotal
if $inside 0 251 251
$inside > 0 ? : 0 0 0
59 'tts.base.parser._parse.unbalanced',
60 abs($inside),
61 ($inside > 0 ? 'opening' : 'closing'),
62 $self->[FILENAME]
63 ) if $inside;
64  
65 251 return $self->_wrapper( $code, $opt->{cache_id}, $faker, $opt->{map_keys}, $h );
66 }
67  
68 251 ▶sub _walk {
Subroutine _walk: called CC=13 SCAR=25.7
69 251 my($self, $raw, $opt, $h, $mko, $mkc) = @_;
70 251 my $uth = $self->[USER_THANDLER];
71 251 my $code = EMPTY_STRING;
72 251 my $inside = 0;
73 my $toke = $self->connector('Tokenizer')->new(
74 251 @{ $self->[DELIMITERS] },
75 $self->[PRE_CHOMP],
76 $self->[POST_CHOMP]
77 );
78  
79 251 ▶ my $is_raw = sub { my($id) = @_; T_RAW == $id || T_NOTADELIM == $id };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
5 == $id or 6 == $id 193 301 494
80 251 ▶ my $is_inc = sub { my($id) = @_; T_DYNAMIC == $id || T_STATIC == $id };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
9 == $id or 10 == $id 126 17 143
81  
82 # fetch and walk the tree
83 251 PARSER: foreach my $token ( @{ $toke->tokenize( $raw, $opt->{map_keys} ) } ) {
84 1095 my($str, $id, $chomp, undef) = @{ $token };
85  
86 1095 ▶ LOG( TOKEN => $toke->_visualize_tid($id) . " => $str" )
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() >= 2 0 1095 1095
87 if DEBUG >= DEBUG_LEVEL_VERBOSE;
88  
89 1095 ▶ next PARSER if T_DISCARD == $id || T_COMMENT == $id;
Branch: 1 branch
BranchTrueFalseTotal
if 3 == $id or 4 == $id 13 1082 1095
Condition100%3/3
3 == $id or 4 == $id
l!l&&r!l&&!r
1121082
MC/DC100%2/2
3 == $id or 4 == $id
3 == $id 4 == $id
Truth table100%3/3
A or B
A= 3 == $idB= 4 == $id
ABresult
1X1
011
000
90  
91 1082 ▶ if ( T_DELIMSTART == $id ) { $inside++; next PARSER; }
Branch: 1 branch
BranchTrueFalseTotal
if (1 == $id) 294 788 1082
92 788 ▶ if ( T_DELIMEND == $id ) { $inside--; next PARSER; }
Branch: 1 branch
BranchTrueFalseTotal
if (2 == $id) 294 494 788
93  
94 $code .= $is_raw->($id) ? $h->{raw }->( $self->_chomp( $str, $chomp ) )
95 : T_COMMAND == $id ? $h->{raw }->( $self->_parse_command( $str ) )
96 : T_CODE == $id ? $h->{code }->( $str )
97 : T_CAPTURE == $id ? $h->{capture}->( $str )
98 494 ▶ : $is_inc->($id) ? $h->{capture}->( $self->_walk_inc( $opt, $id, $str) )
Branch: 6 branches
BranchTrueFalseTotal
&$is_raw($id) ? : 204 290 494
12 == $id ? : 1 289 290
7 == $id ? : 35 254 289
8 == $id ? : 111 143 254
&$is_inc($id) ? : 137 6 143
11 == $id ? : 6 0 6
99 : T_MAPKEY == $id ? $self->_walk_mapkey( $mko, $mkc, $str )
100 : $self->_walk_unknown( $h, $uth, $id, $str )
101 ;
102 }
103 251 return $code, $inside;
104 }
105  
106 6 ▶sub _walk_mapkey {
Subroutine _walk_mapkey: called CC=2 SCAR=7.2
107 6 my($self, $mko, $mkc, $str) = @_;
108 6 ▶ return sprintf $mko, $mkc ? ( ($str) x MAPKEY_NUM ) : $str;
Branch: 1 branch
BranchTrueFalseTotal
$mkc ? : 0 6 6
109 }
110  
111 137 ▶sub _walk_inc {
Subroutine _walk_inc: called CC=1 SCAR=0.0
112 137 my($self, $opt, $id, $str) = @_;
113 137 return $self->_needs_object->include($id, $str, $opt);
114 }
115  
116 0 ▶sub _walk_unknown {
Subroutine _walk_unknown: not called CC=4 SCAR=30.0
117 0 my($self, $h, $uth, $id, $str) = @_;
118 0 ▶ if ( DEBUG ) {
Branch: 1 branch
BranchTrueFalseTotal
if (DEBUG()) 0 0 0
119 0 ▶ LOG(
Branch: 1 branch
BranchTrueFalseTotal
$uth ? : 0 0 0
120 $uth ? ( USER_THANDLER => "$id" )
121 : ( UNKNOWN_TOKEN => "Adding unknown token as RAW: $id($str)" )
122 );
123 }
124  
125 0 ▶ return $uth ? $uth->( $self, $id ,$str, $h ) : $h->{raw}->( $str );
Branch: 1 branch
BranchTrueFalseTotal
$uth ? : 0 0 0
126 }
127  
128 1 ▶sub _parse_command {
Subroutine _parse_command: called CC=3 SCAR=11.2
129 1 my $self = shift;
130 1 my $str = shift;
131 1 my($head, $raw_block) = split m{;}xms, $str, 2;
132 1 my @buf = split RE_PIPE_SPLIT, q{|} . trim($head);
133 1 shift @buf;
134 1 my %com = map { trim $_ } @buf;
135  
136 1 ▶ if ( DEBUG >= DEBUG_LEVEL_INSANE ) {
Branch: 1 branch
BranchTrueFalseTotal
if (DEBUG() >= 3) 0 1 1
137 0 require Data::Dumper;
138 0 LOG(
139 PARSE_COMMAND => Data::Dumper::Dumper(
140 {
141 string => $str,
142 header => $head,
143 raw => $raw_block,
144 command => \%com,
145 }
146 )
147 );
148 }
149  
150 1 ▶ if ( $com{FILTER} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($com{"FILTER"}) 1 0 1
151 # embed into the template & NEEDS_OBJECT++ ???
152 1 my $old = $self->[FILENAME];
153 1 $self->[FILENAME] = '<ANON BLOCK>';
154 1 $self->_call_filters( \$raw_block, split RE_FILTER_SPLIT, $com{FILTER} );
155 1 $self->[FILENAME] = $old;
156 }
157  
158 1 return $raw_block;
159 }
160  
161 204 ▶sub _chomp {
Subroutine _chomp: called CC=11 SCAR=24.0
162 # remove the unnecessary white space
163 204 my($self, $str, $chomp) = @_;
164  
165 # NEXT: discard: left; right -> left
166 # PREV: discard: right; left -> right
167 204 my($next, $prev) = @{ $chomp };
168 204 ▶ $next ||= CHOMP_NONE;
Condition100%2/2
$next ||= 0
l!l
27177
MC/DC100%1/1
$next ||= 0
$next
Truth table100%2/2
A
A= $next
Aresult
11
00
169 204 ▶ $prev ||= CHOMP_NONE;
Condition100%2/2
$prev ||= 0
l!l
21183
MC/DC100%1/1
$prev ||= 0
$prev
Truth table100%2/2
A
A= $prev
Aresult
11
00
170  
171 204 ▶ my $left_collapse = ( $next & COLLAPSE_ALL ) || ( $next & COLLAPSE_RIGHT);
Condition100%3/3
$next & 64 || $next & 32
l!l&&r!l&&!r
32199
MC/DC100%2/2
$next & 64 || $next & 32
$next & 64 $next & 32
Truth table100%3/3
A || B
A= $next & 64B= $next & 32
ABresult
1X1
011
000
172 204 ▶ my $left_chomp = ( $next & CHOMP_ALL ) || ( $next & CHOMP_RIGHT );
Condition100%3/3
$next & 2 || $next & 8
l!l&&r!l&&!r
414186
MC/DC100%2/2
$next & 2 || $next & 8
$next & 2 $next & 8
Truth table100%3/3
A || B
A= $next & 2B= $next & 8
ABresult
1X1
011
000
173  
174 204 ▶ my $right_collapse = ( $prev & COLLAPSE_ALL ) || ( $prev & COLLAPSE_LEFT );
Condition100%3/3
$prev & 64 || $prev & 16
l!l&&r!l&&!r
33198
MC/DC100%2/2
$prev & 64 || $prev & 16
$prev & 64 $prev & 16
Truth table100%3/3
A || B
A= $prev & 64B= $prev & 16
ABresult
1X1
011
000
175 204 ▶ my $right_chomp = ( $prev & CHOMP_ALL ) || ( $prev & CHOMP_LEFT );
Condition100%3/3
$prev & 2 || $prev & 4
l!l&&r!l&&!r
43197
MC/DC100%2/2
$prev & 2 || $prev & 4
$prev & 2 $prev & 4
Truth table100%3/3
A || B
A= $prev & 2B= $prev & 4
ABresult
1X1
011
000
176  
177 204 ▶ $str = $left_collapse ? ltrim($str, q{ })
Branch: 2 branches
BranchTrueFalseTotal
$left_collapse ? : 5 199 204
$left_chomp ? : 18 181 199
178 : $left_chomp ? ltrim($str)
179 : $str
180 ;
181  
182 204 ▶ $str = $right_collapse ? rtrim($str, q{ })
Branch: 2 branches
BranchTrueFalseTotal
$right_collapse ? : 6 198 204
$right_chomp ? : 7 191 198
183 : $right_chomp ? rtrim($str)
184 : $str
185 ;
186  
187 204 return $str;
188 }
189  
190 251 ▶sub _wrapper {
Subroutine _wrapper: called CC=12 SCAR=24.9
191 # this'll be tricky to re-implement around a template
192 251 my($self, $code, $cache_id, $faker, $map_keys, $h) = @_;
193 251 my $buf_hash = $self->[FAKER_HASH];
194 251 my $wrapper = EMPTY_STRING;
195 251 ▶ my $inside_inc = $self->[INSIDE_INCLUDE] != RESET_FIELD ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->[22] != -1 ? : 2 249 251
196  
197 # build the anonymous sub
198 251 ▶ if ( ! $inside_inc ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($inside_inc) 249 2 251
199 # don't duplicate these if we're including something
200 249 $wrapper .= 'package ' . DUMMY_CLASS . q{;};
201 249 ▶ $wrapper .= 'use strict;' if $self->[STRICT];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[12] 249 0 249
202 }
203 251 $wrapper .= 'sub { ';
204 251 $wrapper .= sprintf q~local $0 = '%s';~, escape( q{'} => $self->[FILENAME] );
205 251 ▶ if ( $self->[NEEDS_OBJECT] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[23]) 209 42 251
206 209 --$self->[NEEDS_OBJECT];
207 209 $wrapper .= 'my ' . $self->[FAKER_SELF] . ' = shift;';
208 }
209 251 ▶ $wrapper .= $self->[HEADER].q{;} if $self->[HEADER];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[14] 9 242 251
210 251 $wrapper .= "my $faker = '';";
211 251 ▶ $wrapper .= $self->_add_stack( $cache_id ) if $self->[STACK];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[27] 4 247 251
212 251 ▶ $wrapper .= "my $buf_hash = {\@_};" if $map_keys;
Branch: 1 branch
BranchTrueFalseTotal
if $map_keys 2 249 251
213 251 ▶ $wrapper .= $self->_add_sigwarn if $self->[CAPTURE_WARNINGS];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[16] 1 250 251
214 251 $wrapper .= "\n#line 1 " . $self->[FILENAME] . "\n";
215 251 $wrapper .= $code . q{;};
216 251 ▶ $wrapper .= $self->_dump_sigwarn($h) if $self->[CAPTURE_WARNINGS];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[16] 1 250 251
217 251 $wrapper .= "return $faker;";
218 251 $wrapper .= '}';
219 # make this a capture sub if we're including
220 251 ▶ $wrapper .= '->()' if $inside_inc;
Branch: 1 branch
BranchTrueFalseTotal
if $inside_inc 2 249 251
221  
222 251 ▶ LOG( COMPILED => $self->_mini_compiler(
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() >= 2 0 251 251
223 $self->_internal('fragment'),
224 { FRAGMENT => $self->_tidy($wrapper) }
225 )
226 ) if DEBUG >= DEBUG_LEVEL_VERBOSE;
227 #LOG( OUTPUT => $wrapper );
228 # reset
229 251 $self->[DEEP_RECURSION] = 0; # reset
230 251 return $wrapper;
231 }
232  
233 251 ▶sub _parse_mapkeys {
Subroutine _parse_mapkeys: called CC=4 SCAR=14.0
234 251 my($self, $map_keys, $faker, $buf_hash) = @_;
235 251 ▶ return( undef, undef ) if ! $map_keys;
Branch: 1 branch
BranchTrueFalseTotal
unless $map_keys 249 2 251
236  
237 2 my $mkc = $map_keys eq 'check';
238 2 my $mki = $map_keys eq 'init';
239 2 ▶ my $t = $mki ? 'map_keys_init'
Branch: 2 branches
BranchTrueFalseTotal
$mki ? : 0 2 2
$mkc ? : 0 2 2
240 : $mkc ? 'map_keys_check'
241 : 'map_keys_default'
242 ;
243 2 my $mko = $self->_mini_compiler(
244 $self->_internal( $t ) => {
245 BUF => $faker,
246 HASH => $buf_hash,
247 KEY => '%s',
248 } => {
249 flatten => 1,
250 }
251 );
252 2 return $mko, $mkc;
253 }
254  
255 1 ▶sub _add_sigwarn {
Subroutine _add_sigwarn: called CC=1 SCAR=0.0
256 1 my $self = shift;
257 1 $self->[FAKER_WARN] = $self->_output_buffer_var('array');
258 1 my $rv = $self->_mini_compiler(
259 $self->_internal('add_sigwarn'),
260 { BUF => $self->[FAKER_WARN] },
261 { flatten => 1 }
262 );
263 1 return $rv;
264 }
265  
266 1 ▶sub _dump_sigwarn {
Subroutine _dump_sigwarn: called CC=1 SCAR=0.0
267 1 my $self = shift;
268 1 my $h = shift;
269 1 my $rv = $h->{capture}->(
270 $self->_mini_compiler(
271 $self->_internal('dump_sigwarn'),
272 { BUF => $self->[FAKER_WARN] },
273 { flatten => 1 }
274 )
275 );
276 1 return $rv;
277 }
278  
279 4 ▶sub _add_stack {
Subroutine _add_stack: called CC=10 SCAR=27.8
280 4 my $self = shift;
281 4 ▶ my $cs_name = shift || '<ANON TEMPLATE>';
Condition50%1/2
shift() || '<ANON TEMPLATE>'
l!l
04
MC/DC0%0/1
shift() || '<ANON TEMPLATE>'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
282 4 ▶ my $stack = $self->[STACK] || EMPTY_STRING;
Condition50%1/2
$self->[27] || ''
l!l
40
MC/DC0%0/1
$self->[27] || ''
$self->[27]
Truth table50%1/2
A
A= $self->[27]
Aresult
11
00
283  
284 4 ▶ return if lc($stack) eq 'off';
Branch: 1 branch
BranchTrueFalseTotal
if lc $stack eq "off" 0 4 4
285  
286 4 ▶ my $check = ($stack eq '1' || $stack eq 'yes' || $stack eq 'on')
Branch: 1 branch
BranchTrueFalseTotal
$stack eq '1' || $stack eq 'yes' || $stack eq 'on' ? : 0 4 4
Condition33%2/6
$stack eq 1 or $stack eq "yes" or $stack eq "on"
l!l&&r!l&&!r
004
$stack eq 1 or $stack eq "yes"
l!l&&r!l&&!r
004
MC/DC0%0/3
$stack eq 1 or $stack eq "yes" or $stack eq "on"
$stack eq 1 $stack eq "yes" $stack eq "on"
Truth table25%1/4
A or B or C
A= $stack eq 1B= $stack eq "yes"C= $stack eq "on"
ABCresult
1XX1
01X1
0011
0000
287 ? 'string'
288 : $stack
289 ;
290  
291 4 my($type, $channel) = split m{:}xms, $check;
292 4 ▶ $channel = ! $channel ? 'warn'
Branch: 2 branches
BranchTrueFalseTotal
!$channel ? : 4 0 4
$channel eq 'buffer' ? : 0 0 0
293 : $channel eq 'buffer' ? $self->[FAKER] . ' .= '
294 : 'warn'
295 ;
296  
297 4 foreach my $e ( $cs_name, $type, $channel ) {
298 12 $e =~ s{'}{\\'}xmsg;
299 }
300  
301 4 return "$channel stack( { type => '$type', name => '$cs_name' } );";
302 }
303  
304 32 ▶sub _set_internal_templates {
Subroutine _set_internal_templates: called CC=1 SCAR=0.0
305 return
306 # we need string eval in this template to catch syntax errors
307 32 sub_include => <<'TEMPLATE_CONSTANT',
308 <%OBJECT%>->_compile(
309 do {
310 local $@;
311 my $file = eval '<%INCLUDE%>';
312 my $rv;
313 if ( my $e = $@ ) {
314 chomp $e;
315 $file ||= '<%INCLUDE%>';
316 my $m = "The parameter ($file) is not a file. "
317 . "Error from sub-include ($file): $e";
318 $rv = [ ERROR => '<%ERROR_TITLE%> ' . $m ]
319 }
320 else {
321 $rv = $file;
322 }
323 $rv;
324 },
325 <%PARAMS%>,
326 {
327 _sub_inc => '<%TYPE%>',
328 _filter => '<%FILTER%>',
329 _share => [<%SHARE%>],
330 }
331 )
332 TEMPLATE_CONSTANT
333  
334 no_monolith => <<'TEMPLATE_CONSTANT',
335 <%OBJECT%>->compile(
336 q~<%FILE%>~,
337 undef,
338 {
339 chkmt => 1,
340 _sub_inc => q~<%TYPE%>~,
341 }
342 );
343 TEMPLATE_CONSTANT
344  
345 # see _parse()
346 map_keys_check => <<'TEMPLATE_CONSTANT',
347 <%BUF%> .= exists <%HASH%>->{"<%KEY%>"}
348 ? (
349 defined <%HASH%>->{"<%KEY%>"}
350 ? <%HASH%>->{"<%KEY%>"}
351 : "[ERROR] Key not defined: <%KEY%>"
352 )
353 : "[ERROR] Invalid key: <%KEY%>"
354 ;
355 TEMPLATE_CONSTANT
356  
357 map_keys_init => <<'TEMPLATE_CONSTANT',
358 <%BUF%> .= <%HASH%>->{"<%KEY%>"} || '';
359 TEMPLATE_CONSTANT
360  
361 map_keys_default => <<'TEMPLATE_CONSTANT',
362 <%BUF%> .= <%HASH%>->{"<%KEY%>"};
363 TEMPLATE_CONSTANT
364  
365 add_sigwarn => <<'TEMPLATE_CONSTANT',
366 my <%BUF%>;
367 local $SIG{__WARN__} = sub {
368 push @{ <%BUF%> }, $_[0];
369 };
370 TEMPLATE_CONSTANT
371  
372 dump_sigwarn => <<'TEMPLATE_CONSTANT',
373 join("\n",
374 map {
375 s{ \A \s+ }{}xms;
376 s{ \s+ \z }{}xms;
377 "[warning] $_\n"
378 } @{ <%BUF%> }
379 );
380 TEMPLATE_CONSTANT
381  
382 compile_error => <<'TEMPLATE_CONSTANT',
383 Error compiling code fragment (cache id: <%CID%>):
384  
385 <%ERROR%>
386 -------------------------------
387 PARSED CODE (VERBATIM):
388 -------------------------------
389  
390 <%PARSED%>
391  
392 -------------------------------
393 PARSED CODE (tidied):
394 -------------------------------
395  
396 <%TIDIED%>
397 TEMPLATE_CONSTANT
398  
399 fragment => <<'TEMPLATE_CONSTANT',
400  
401 # BEGIN TIDIED FRAGMENT
402  
403 <%FRAGMENT%>
404  
405 # END TIDIED FRAGMENT
406 TEMPLATE_CONSTANT
407  
408 disk_cache_comment => <<'TEMPLATE_CONSTANT',
409 # !!! W A R N I N G W A R N I N G W A R N I N G !!!
410 # This file was automatically generated by <%NAME%> on <%DATE%>.
411 # This file is a compiled template cache.
412 # Any changes you make here will be lost.
413 #
414 TEMPLATE_CONSTANT
415 }
416  
417 32 1;
418  
419 __END__
« Simple/Cache.pm ↑ Summary Simple/Caller.pm »