I found some code on this forum regarding a random image script.
Here is the code:
#! /usr/local/bin/perl
$basedir = "http://www.mydomain.net/images/";
@files = qw(1.bmp 2.bmp 3.bmp);
srand(time ^ $$);
$num = rand(@files);
print "Location: $basedir$files[$num]\n\n";
Here is the error:
failed to open log file
fopen: Permission denied
[Sat Jun 14 16:47:01 2003] [error] [client 142.161.128.92] Premature end of script headers: /usr/local/plesk/apache/vhosts/domain.net/cgi-bin/rand_image.pl
I'd really appreciate any help you all can offer on this. I've been looking for a script to display a random image for quite a while, and haven't found one that worked for me. I'd love to get this one going.
Thanks in advance!
Jarett
[edited by: jarett at 8:54 pm (utc) on June 14, 2003]
@files = qw(1.bmp 2.bmp 3.bmp);
@files = array("1.bmp","2.bmp","3.bmp");
are identical. qw is a special that tells perl to QuoteWord. The parenthesis assume an array list. Thus you can do this:
($var1,$var2,$var3) = split(@array);
A LIST is contained in ( ) and an array is a LIST.
Second: I copied your code directly and ran it on the command line and it worked. One thing to check, where is perl located on your system? On mine it is /usr/bin/perl, so I made that change at the top after the shebang.
Scott Geiger