Image presentation via Perl script

E

Ed Jay

I'm using a Perl script to generate html pages. I want to use images in
the html page. The fundamental code I use to display an image is:

print "<p><img src=\"http://www.my-site.com/image.gif\" border=1
width=\"53\" height=\"32\" alt=\"logo\">\n";

The image doesn't display.

I have the same problem importing linked external style sheets and
external javascripts.
 
J

Jonathan N. Little

Ed said:
I'm using a Perl script to generate html pages. I want to use images in
the html page. The fundamental code I use to display an image is:

print "<p><img src=\"http://www.my-site.com/image.gif\" border=1
width=\"53\" height=\"32\" alt=\"logo\">\n";

The image doesn't display.

I have the same problem importing linked external style sheets and
external javascripts.
Best use CGI.pm Then your code would be... I formatted it so your can
see the parts without the NG wordwrap confusing things

use "CGI";

print p(
img(
{
-href=>'http://www.my-site.com/image.gif',
-border=>1,
-width=>53,
-height=>32,
-alt=>'logo'
}
)
);

if your want it all 'prettified' with CR's and TAB's then

use CGI::pretty;
 
M

mbstevens

Ed said:
I'm using a Perl script to generate html pages. I want to use images in
the html page. The fundamental code I use to display an image is:

print "<p><img src=\"http://www.my-site.com/image.gif\" border=1
width=\"53\" height=\"32\" alt=\"logo\">\n";

The image doesn't display.

I have the same problem importing linked external style sheets and
external javascripts.
http://www.mbstevens.com/howtothumb/
....toward the bottom of the article is a Perl script to display an
image, with a lot of explanation. I suggest you read the whole article
to understand why some of the things were done.

You should be able to use external stylesheets and javascripts. You're
addressing them wrong, most probably. Remember that the address is
relative to the place the script executes, not the base address of your
website.
 
E

Ed Jay

mbstevens said:
http://www.mbstevens.com/howtothumb/
...toward the bottom of the article is a Perl script to display an
image, with a lot of explanation. I suggest you read the whole article
to understand why some of the things were done.

You should be able to use external stylesheets and javascripts. You're
addressing them wrong, most probably. Remember that the address is
relative to the place the script executes, not the base address of your
website.
I understand that. That's why I tried, unsuccessfully, to use an absolute
address.
 
E

Ed Jay

Jonathan N. Little said:
Best use CGI.pm Then your code would be... I formatted it so your can
see the parts without the NG wordwrap confusing things

use "CGI";

print p(
img(
{
-href=>'http://www.my-site.com/image.gif',
-border=>1,
-width=>53,
-height=>32,
-alt=>'logo'
}
)
);

if your want it all 'prettified' with CR's and TAB's then

use CGI::pretty;

Thanks. You introduced me to the world of Perl modules. I had no idea...
 
M

mbstevens

Toby said:
Ed Jay wrote:




URL?
To sys op:
Yes, post the actual site and image locations. And, assuming the whole
script is in a place we don't have read access, post it too (possibly
minus your de-tainting code, if you don't want to make that public.)
 
J

Jonathan N. Little

Ed said:
Thanks. You introduced me to the world of Perl modules. I had no idea...
Beats the crap out of all that quote escaping and with the CGI.pm your
are less like to make an HTML (actually XHTML 1.0 Transitional) syntax
error. Can also save you a lot of coding...

my @list=qw(one two three four five six);
print ul(li(\@list));

Just imagine:

print p(\@paragraphs);

Also another tip, lookup functions q(), qq() and qw() that can be your
friends ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top