You will save yourself a lot of work by using a Herepage. You can interpolate variables into them but do not have to \ your ". This save lots of calls to print and makes your code so much easier to read. Here is an example:

sub unindent; # declare unindent proto at top of code so we can use it + as a bareword sub return_html { my %include = %{$_[0]}; open(FH,"/home/coolsite/www/top.html") || die "couldn't open file +$!"; my @html=<FH>; close(FH); my %titles = %{$_[1]}; my $results; foreach my $key (keys %include) { if ($include{$key} eq 'yes') { $results .= "<li class=bullets><span class=bullets><a href=\ +"$baseurl$key\">$titles{$key}</a></span></li>"; } } print unindent <<" HTML"; # print all the stuff until we find H +TML on a line by itself Content-type: text/html @html <center> <h1>Search Results</h1> </center> RESULTS- In No Particular Order:<p><hr size=7 width=75%><p> <ul> $results </ul> </ul> <br> <hr size=7 width=75%> <P> <ul> <li class=bullets><span class=bullets><a href="$search_url">Back + to Search Page</a></span></li> <li class=bullets><span class=bullets><a href="$title_url">$titl +e</a></span></li> </ul> <hr size=7 width=75%> <center> This search powered by<br> <a href=http://www.mysite.com><img src=../nolalogo.jpg width=318 + height=74 border=0 alt=\"Got Funk?\"></a> </center> </body> </html> HTML # herepage ends with token above } # this sub strips all leading whitespace sub unindent { s/^[ \t]+//gm for @_; @_; }

This uses a trick to let you indent your HTML with the sub. The herepage token we use has 4 leading spaces then the letters HTML ie "    HTML" so indents with the HTML. To remove the indentation for efficiency we declare an unindent() sub proto at the top of our code so we can use it as a bareword (effectively like an inbuilt function). This sub strips all the leading whitespace and will reduce the download by 20-50%+ plus depending on how you format your HTML.

PS you have an extra/unmatched </ul> in there which is a little easier to see now too.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Do I need to give a flock? by tachyon
in thread Do I need to give a flock? by jerrygarciuh

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.