Take a look at HTML::Template. It has the potential to make your life much easier. Consider:

use strict; use warnings; use HTML::Template qw(); my $tmplStr = <<TMPL; <tr class='<TMPL_VAR name="className">'> <TMPL_LOOP name="pictures"> <td onmouseout='showPicture("<TMPL_VAR +name="file">",0, "<TMPL_VAR name="path">")' onmouseover='showPicture("<TMPL_VAR name="file">",1, "<TMPL_VA +R name="path">")' ><TMPL_VAR name="file"></td> </TMPL_LOOP></tr> TMPL my $tmpl = HTML::Template->new(scalarRef => \$tmplStr); my @pictures = ( {file => 'wibble.jpg', path => '/here/there/everywhere'} +, {file => 'wobble.jpg', path => '/here/there/everywhere'} +, {file => 'floop.jpg', path => '/here/there/elsewhere'}, ); $tmpl->param( className => 'pinkAsAnything', pictures => \@pictures, ); print $tmpl->output();

Prints:

<tr class='pinkAsAnything'> <td onmouseout='showPicture("wibble.jpg",0, "/here/there/everywher +e")' onmouseover='showPicture("wibble.jpg",1, "/here/there/everywhe +re")' >wibble.jpg</td> <td onmouseout='showPicture("wobble.jpg",0, "/here/there/everywher +e")' onmouseover='showPicture("wobble.jpg",1, "/here/there/everywhe +re")' >wobble.jpg</td> <td onmouseout='showPicture("floop.jpg",0, "/here/there/elsewhere" +)' onmouseover='showPicture("floop.jpg",1, "/here/there/elsewhere +")' >floop.jpg</td> </tr>

which isn't the answer you thought you were looking for, but should head you in a useful direction. Note that you can load the template HTML from a file instead of a string so the HTML becomes independent of your script to make maintnance of both clearer and easier.

True laziness is hard work

In reply to Re: I need a help! regarding with SELECT html with Perl by GrandFather
in thread I need a help! regarding with SELECT html with Perl by huchister

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.