X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=samples%2Fmemory_template.pl;fp=samples%2Fmemory_template.pl;h=28b17105331b72f6328abd0bb60894ba259827a8;hb=4eee158dce82376f2f37de29d91c53f60a24aebe;hp=0000000000000000000000000000000000000000;hpb=85070b46d0a93ddbeef07341421adb8389a55418;p=chaz%2Fp5-CGI-Ex diff --git a/samples/memory_template.pl b/samples/memory_template.pl new file mode 100644 index 0000000..28b1710 --- /dev/null +++ b/samples/memory_template.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl -w + +my $swap = { + one => "ONE", + two => "TWO", + three => "THREE", + a_var => "a", + hash => {a => 1, b => 2}, + code => sub {"($_[0])"}, +}; + +my $txt = "[% one %][% two %][% three %][% hash.keys.join %] [% code(one).length %] [% hash.\$a_var %]\n"; + +###----------------------------------------------------------------### + +my $module; +if (! fork) { + $module = 'CGI::Ex::Template'; + $0 = "perl $module"; +} elsif (! fork) { + $module = 'Template'; + $0 = "perl $module"; +} + +if ($module) { + my $pm = "$module.pm"; + $pm =~ s|::|/|g; + require $pm; + + my $t = $module->new(ABSOLUTE => 1); + my $out = ''; + $t->process(\$txt, $swap, \$out); + print $out; +} + +sleep 15; # go and check the 'ps fauwx|grep perl' + + +###----------------------------------------------------------------###