Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: I need a help! regarding with SELECT html with Perl

by GrandFather (Sage)
on Sep 20, 2012 at 21:47 UTC ( #994765=note: print w/replies, xml ) Need Help??

in reply to I need a help! regarding with SELECT html with Perl

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();


<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

Replies are listed 'Best First'.
Re^2: I need a help! regarding with SELECT html with Perl
by huchister (Acolyte) on Sep 28, 2012 at 13:14 UTC
    Thanks, I didn't solved problem this way, but looks a lot lot easier than what I have wrote. I shall take a look at template also. However I made a function that receive array of selected value, while loop to sort out which one to sent or not. Have nice day!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994765]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2017-02-27 03:13 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.