perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Peters <mpet...@plusthree.com>
Subject Re: How to display images ?
Date Tue, 21 Aug 2007 16:02:08 GMT
Georg Grabler wrote:
> On Tuesday 21 August 2007 15:48:23 RGKärcher wrote:
>> print " <p><a href=\"http://www.mysite.net/\">  <img
>> src=\"site_images/$image \"  width=\"160\"
>> height=\"180\" alt=\"image \" class=\"float-left\"
>> /></a>\n";
> 
> Perl is just a bit differnt. Either, use ${image} instead of $image or use 
> sprintf.

You can use both of those, but you don't really need to. The above should work
just fine. But don't all those escapes of the double quotes give you a headache?
There are so many better ways of doing that:

print qq|<p><a href="http://www.mysite.net/">
  <img src="site_images/$image" width="160" height="180" alt="image"
    class="float-left" />
  </a></p>
|;

Having said that, when working with HTML you should really be using templates. I
like Template Toolkit (http://search.cpan.org/perldoc?Template) and also use
HTML::Template (http://search.cpan.org/perldoc?HTML::Template) but if you're
coming from PHP then Mason might be more up your alley
(http://search.cpan.org/perldoc?HTML::Mason)

-- 
Michael Peters
Developer
Plus Three, LP


Mime
View raw message