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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |