Is the template much more complex than the example you provide? If not, you could just concatenate the strings, i.e.

$top_of_template = qq( <html> <head> <title> test </title> </head> <body bgcolor='red' > ); $bottom_of_template = qq( <table> <tr colspan='2'> <td> text </td> <td> text2 </td> </tr> </table> </body> </html> ); $middle_of_template = (your code); $output = $top_of_template . $middle_of_template . $end_of_template;
Alternately, you could just use HTML::Template to do this same task:
<errors> <TMPL_IF NAME="INVALID_WIDGET_SIZE"><TMPL_VAR NAME="INVALID_WIDGET_SI +ZE"></TMPL_IF> <TMPL_IF NAME="INVALID_WIDGET_COLOR"><TMPL_VAR NAME="INVALID_WIDGET_C +OLOR"></TMPL_IF> </errors>

and then just pass the invalid widget color (or any other variable you'd like) (instead of a simple boolean?) and not have to worry about dealing with XML::Simple and all of its nastiness.


In reply to Re: XML::Simple problem, or How to convert HTML to Perl and then back again. by saintbrie
in thread XML::Simple problem, or How to convert HTML to Perl and then back again. by Wonko the sane

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.