#!/usr/bin/perl use strict; use warnings; use Template; #use Template::Parser; my $template = Template->new({}); my $text = "[% SET content='" . ("stuff "x20_000) . "' %]"; my $start = qr/\Q[%/; my $end = qr/\Q%]/; while ($text =~ s/ ^(.*?) # $1 - start of line up to directive (?: $start # start of tag (.*?) # $2 - tag contents $end # end of tag ) //sx) { #print "1=$1\n2=$2\n"; } pos($text) = 0; $template->process(\$text, {}); print "Processed\n";