#!/usr/bin/perl
########## InlineWeb.pm
package InlineWeb;
use Filter::Simple;
FILTER{
my $program="";
while (1){
if (/\G{{/gc){
/\G({+)/gc;
my $braces = $1;
$braces=~tr/{/}/;
/\G(.*?)}}$braces/gcs;
$program.=$1.qq[;\n];
next;
}elsif (/\G{\[/gc){
/\G(\[+)/gc;
my $sq = $1;
$sq=~tr:\[:\]:;
/\G(.*?)$sq]}/gcs;
$program.=q[print scalar ].$1.qq[;\n];
next;
}else{
/\G(.*?)(?=({\[|{{|$))/gcs;
my $txt = $1;
my $delim = $2;
$txt=~s:':\\':g;
$program.=q[print '].$txt.qq[';\n];
next if $delim;
}
last;
}
$_=$program;
return $done=1;
};
1;
This code can handle simple substituions, but how do you handle conditions and loops? Includes? Nested wrappers? Most of the work i deal with involves database lookups and displaying rows of information, which is why i turn to modules such as Template-Toolkit, HTML::Mason, and HTML::Template.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
perlmonks.org content © perlmonks.org and Anonymous Monk, Aristotle, jeffa, wazoox
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03