]>
Dogcows Code - chaz/p5-CGI-Ex/blob - samples/memory_template.pl
8 hash
=> {a
=> 1, b
=> 2},
9 code
=> sub {"($_[0])"},
12 my $txt = "[% one %][% two %][% three %][% hash.keys.join %] [% code(one).length %] [% hash.\$a_var %]\n";
15 ###----------------------------------------------------------------###
20 $module = 'CGI::Ex::Template';
22 $module = 'CGI::Ex::Template::XS';
27 $name = 'Template Stash::XS';
28 require Template
::Stash
::XS
;
30 $module = 'HTML::Template';
32 $module = 'HTML::Template::Expr';
34 $module = 'HTML::Template::Compiled';
36 $module = 'Text::Tmpl';
39 $name = 'Template::Parser::CET';
40 require Template
::Parser
::CET
;
41 Template
::Parser
::CET-
>activate;
48 my $pm = "$module.pm";
52 if ($module =~ /HTML::Template/) {
53 my $t = eval { $module->new };
54 } elsif ($module eq 'Text::Tmpl') {
55 my $t = eval { $module->new->parse_string($txt) };
58 my $t = $module->new(ABSOLUTE
=> 1);
60 $t->process(\
$txt, $swap, \
$out);
62 for (1..30) { my $out; $t->process(\
$txt, $swap, \
$out); };
65 # print "$name $_\n" foreach sort keys %INC;
66 print "$name times: (@{[times]})\n";
72 print grep {/\Q$0\E/} `ps fauwx`;
73 #sleep 15; # go and check the 'ps fauwx|grep perl'
76 ###----------------------------------------------------------------###
79 my $hello2000 = "<html><head><title>[% title %]</title></head><body>
80 [% array = [ \"Hello\", \"World\", \"2000\", \"Hello\", \"World\", \"2000\" ] %]
81 [% sorted = array.sort %]
82 [% multi = [ sorted, sorted, sorted, sorted, sorted ] %]
84 [% FOREACH row = multi %]
85 <tr bgcolor=\"[% loop.count % 2 ? 'gray' : 'white' %]\">
86 [% FOREACH col = row %]
87 <td align=\"center\"><font size=\"+1\">[% col %]</font></td>
93 [% FOREACH i = [ 1 .. 10 ] %]
94 [% var = i + param %]"
95 .("\n [%var%] Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>"x20
)."
This page took 0.042214 seconds and 4 git commands to generate.