First, I have to ask why (maybe there's a reason e.g. legacy, install/enviroment issues, etc) you're going with this home grown solution and not Template::Toolkit or Mason which both support include files and embedded perl.

As for the < causing problems, that's curious.. First thought of a work-around is to use a here-doc instead of qq[].

For the explaination I think that this perldoc perlop snippet holds the answer (hopefully someone more knowledgeable of qq[] can elaborate):

   Finding the end
   The first pass is finding the end of the quoted construct, whether it be a multicharacter delimiter
    ""\nEOF\n"" in the "<<EOF" construct, a "/" that terminates a "qq//" construct, a "]" which terminates
    "qq[]" construct, or a ">" which terminates a fileglob started with "<".


Update: I'm having troubling reproducing the error -- do you have a simple test case (e.g. one that reads from <DATA>)? The following script works for me:
#!/usr/bin/perl use strict; use warnings; my $text; my %h_self = (form_data =>{page=>'confirmation'}); while(<DATA>){ if (m/\<!-- Begin Perl Block --\>/i) { my $perlcode = ''; # Pull in all the perl code while (<DATA>) { # This is the end of the block last if m/\<!-- End Perl Block --\>/i; $perlcode .= $_; } # Execute the anonymous sub warn &{eval $perlcode;}; } } __DATA__ BLAH <!-- Begin Perl Block --> sub { $text = ''; if ($h_self{form_data}{page} =~ /confirmation|application/i) { $text .= qq[<style type="text/css"> body {font-size: 8pt;font-family: Arial, Helvetica;} table {font-size: 8pt;font-family: Arial, Helvetica;} tr {font-size: 8pt;font-family: Arial, Helvetica;} td {font-size: 8pt;font-family: Arial, Helvetica;} select {font-size: 8pt;font-family: Arial, Helvetica;} input {font-size: 8pt;font-family: Arial, Helvetica;} form {font-size: 8pt;font-family: Arial, Helvetica;} div {font-size: 8pt;font-family: Arial, Helvetica;} p {font-size: 8pt;font-family: Arial, Helvetica;} .red {font-weight: bold;font-size: 10pt;color: red;text-align:right;} .black {font-weight: bold;font-size: 10pt;color: black;text-align:righ +t;} .backfill {background-color:003399;text-align:center;color:white;font- +weight:bold;border: 1px solid white;} .cell {border: 1px solid white;} .edit {width: 50;} </style>]; } return $text; } <!-- End Perl Block --> STUFF

In reply to Re: < Woes by davidrw
in thread < Woes by rongoral

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.