I am a beginner with perl and as a way to get some practice using it I decided to try to do random imaging with it. I have my own apache server set up on windows, which is where I intended to run it. I'm almost 100% sure that I have the server configured correctly because when I run the perl script it shows up on the server, the only problem is that the actual image does not appear. However, the area that it should be in shows up, but it shows up like it would if a image doesn't load on a webpage. I'm not sure if I need something else to allow me to get the images to appear or what. Here is the code that I have, if you have any suggestions or ideas let me know.
#!c:\perl\bin\perl.exe -w
use strict;
use strict "vars";
my @imgArray = ("./pics/blink.gif","./pics/sum41.jpg","./pics/ul.jpg",
+"./pics/ltj.jpg","./pics/mest.jpg","./pics/blink2.jpg","./pics/blink3
+.jpg");
srand(time ^ $$);
my $num = rand(@imgArray);
print "Content-type: text/html\n\n";
print "Index: $num <br>Image: $imgArray[$num]<br><br>";
print "<center>Random imaging with Perl.....<br><br></center>";
if($num < 1)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=320 width=240><br><br><font>Blink 182 (1)</font></center
+></body>\n";}
elsif($num < 2)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=316 width=500><br><br><font>Sum 41</font></center></body
+>\n";}
elsif($num < 3)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=600 width=450><br><br><font>Unwritten Law</font></center
+></body>\n";}
elsif($num < 4)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=320 width=240><br><br><font>Less Than Jake</font></cente
+r></body>\n";}
elsif($num < 5)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=365 width=550><br><br><font>Mest</font></center></body>\
+n";}
elsif($num < 6)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=322 width=356><br><br><font>Blink 182 (2)</font></center
+></body>\n";}
elsif($num < 7)
{print "<body bgcolor=lightgrey><center><img src=$imgArray[$num] bor
+der=1 height=536 width=678><br><br><font>Blink 182 (3)</font></center
+></body>\n";}
else
{print "Error loading picture!";}
Thanks,
KP
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|