// template ... ... // processed template foo { if(12){ $self->out( <<'EOTT' ); ... EOTT } $self->out( <<'EOTT' ); varsubst($self->getvar('blah'));'' /> EOTT $self->out( <<'EOTT' ); EOTT $self->out( <<'EOTT' ); ... EOTT EOTT } You'll notice some errors, like foo=..., I need to fix the varsubst stuff, as well as the missing $self->out before the tag.