There is a bug in Template -- ok, supposidly this is actually a bug in perl, but I am sure that the author of Template could have worked around the issue. Basically, you cannot use the 'Interpolate' feature of the module when loading a template larger than ~30k; if you do, perl will dump core, segfault, or do something of the sort.

Here's the example that I have in which Template fails:

my $TMPL = Template->new( { DELIMITER => ';', INCLUDE_PATH => 'C:/Apache2/sites/foobar/template', INTERPOLATE => 1 } ); $TMPL->process( \*DATA, { screen => qw(screen1 screen2)[rand 2] } ); __END__ [% INCLUDE primary/html_head.tmpl %] [% INCLUDE "$screen" %] [% INCLUDE primary/html_foot.tmpl %] [% BLOCK screen1 %] This is screen #1. [% END %] [% BLOCK screen2 %] This is screen #2. [% END %]

Of course, it is possible to work around this in this fashion:

__END__ [% INCLUDE primary/html_head.tmpl %] [% IF screen == 'screen1' %] [% INCLUDE screen1 %] [% ELSIF screen == 'screen2' %] [% INCLUDE screen2 %] [% END %] [% INCLUDE primary/html_foot.tmpl %]

But if I have several screens, this can get very annoying to code and is definitely ugly. Can anybody think of a way to get around this alternative of mine?


In reply to Interpolate within Template by saskaqueer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.