]> Dogcows Code - chaz/p5-CGI-Ex/blob - samples/memory_template.pl
CGI::Ex 2.00
[chaz/p5-CGI-Ex] / samples / memory_template.pl
1 #!/usr/bin/perl -w
2
3 my $swap = {
4 one => "ONE",
5 two => "TWO",
6 three => "THREE",
7 a_var => "a",
8 hash => {a => 1, b => 2},
9 code => sub {"($_[0])"},
10 };
11
12 my $txt = "[% one %][% two %][% three %][% hash.keys.join %] [% code(one).length %] [% hash.\$a_var %]\n";
13
14 ###----------------------------------------------------------------###
15
16 my $module;
17 if (! fork) {
18 $module = 'CGI::Ex::Template';
19 $0 = "perl $module";
20 } elsif (! fork) {
21 $module = 'Template';
22 $0 = "perl $module";
23 }
24
25 if ($module) {
26 my $pm = "$module.pm";
27 $pm =~ s|::|/|g;
28 require $pm;
29
30 my $t = $module->new(ABSOLUTE => 1);
31 my $out = '';
32 $t->process(\$txt, $swap, \$out);
33 print $out;
34 }
35
36 sleep 15; # go and check the 'ps fauwx|grep perl'
37
38
39 ###----------------------------------------------------------------###
This page took 0.032112 seconds and 4 git commands to generate.