Hi,
I'n new to the forum + to perl. I have this script below, which displays images at random within the table. What I'm looking is for a way to stop it from displaying the same image more than once - occasionally the same images are displayed within the table. Any advice would be great.
Thank You
#!/usr/bin/perl
#====================== Edit ============================
$basedir="/public_html/cgi-bin/";
@img = ("imag1.JPG",
"imag2.JPG",
"imag3.JPG",
"imag4.JPG",
"imag5.JPG",
"imag6.JPG",
"imag7.JPG",
"imag8.JPG",
"imag9.JPG",
);
#====================== Done ============================
srand($$ & time ^ $$);
$imgnum = rand(@img);
print "Content-type: text/html\n\n";
print "<table width=728px align=center><tr>";
for (my $images = 1; $images <= 4; $images++) {
$imgnum = rand(@img);
print "<td><img src=/";
print "@img[$imgnum]";
print "></a></td>";
}
print "</tr></table>";
$imgnum = "";
I'n new to the forum + to perl. I have this script below, which displays images at random within the table. What I'm looking is for a way to stop it from displaying the same image more than once - occasionally the same images are displayed within the table. Any advice would be great.
Thank You
#!/usr/bin/perl
#====================== Edit ============================
$basedir="/public_html/cgi-bin/";
@img = ("imag1.JPG",
"imag2.JPG",
"imag3.JPG",
"imag4.JPG",
"imag5.JPG",
"imag6.JPG",
"imag7.JPG",
"imag8.JPG",
"imag9.JPG",
);
#====================== Done ============================
srand($$ & time ^ $$);
$imgnum = rand(@img);
print "Content-type: text/html\n\n";
print "<table width=728px align=center><tr>";
for (my $images = 1; $images <= 4; $images++) {
$imgnum = rand(@img);
print "<td><img src=/";
print "@img[$imgnum]";
print "></a></td>";
}
print "</tr></table>";
$imgnum = "";