On Wed, Jun 09, 2004 at 06:57:08PM +0200, Johan Meskens CS3 jmcs3 wrote:
> 
> # hello
> 
> # i don't know what comes first
> # , source or question
> 
> # thus
> 
> #!/usr/local/bin/perl
> 
> use CGI;
> use strict;
> use warnings;
> 
YAY!

> my $q=CGI->new();
> 
> print $q->header;
> print $q->start_html;
> 
> # things
> 
> print "<img src=\"http://127.0.0.1/cgi-bin/image.cgi\";>"; # this works
> 
> # first question : what is the cgi-oop-way of dealing with images; 
> $q->img ??
> # i can't find dox on that

print $q->img({-src=>'http://wheremyimagelives.com/image.cgi',
-alt=>'W3C Compliant'});

> 
> # second question : how can i insert more than one image
> # i tried the following:
> 
> # foreach( 1..6 ){
> #    print "<img src=\"http://127.0.0.1/cgi-bin/five.cgi\";>";
> # }
> 

foreach(1..6) 

translates into:

foreach local $_ (1..6) 

which essentially means that $_ will hold the value of the current
element in the list.  Try this:

my @images = ( "dog.jpg", "cat.jpg", "chicken.jpg", "cow.jpg" );

foreach my $file (@images) {
        print $q->img({-src=>"http://server/dir/$file";, -alt=>"$file"});
}

That's probly what you're looking for.

Have you seen perldoc ?

perldoc CGI
perldoc perldsc
perldoc perlfunc

Those should be useful!

Good start though :)

> # but this returns 6 times the same image
> 
> # more things
> 
> print $q->end_html;
> 
> # thank you
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 

-- 
Brad Lhotsky <[EMAIL PROTECTED]>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to