FreeBSD-6.2 Apache22 I suck at programming, Therefore I am hoping that someone here can assist me. I have the following Perl scrip that works file from within an HTML document as long as the document and the scrip and the files it calls all in the same directory. This is the Perl script: #!/usr/local/bin/perl # find out the day of the year my $day_of_year = (localtime(time()))[7]; # define the path where the images live "." is the current directory $path = "/usr/local/www/apache22/data/s-pics"; # read all the jpg filenames from the directory into an array opendir(DIR, $path); @files = grep { /\.(jpg|gif|png)$/i } readdir(DIR); closedir(DIR); # sort the filenames alphabetically @files = sort( {lc $a cmp lc $b} @files); /usr/local/www/apache22/data $ /usr/local/www/apache22/data/s-pics/display-pic.pl Illegal modulus zero at /usr/local/www/apache22/data/s-pics/display-pic.pl line 28. # count the number of images $no_of_images = scalar(@files); # Now the fun bit :) We loop through the images once before # repeating them in the same order. If we divide the current # number of day of the year by the number of images in the # directory we get the number of times have repeated the images. # We are interested in the remainder of this calculation (this # is calculated using the % operator). Note - there must be # less than 365 images in the directory! We need to subtract # one from this number because arrays start at zero not 1! if ( $no_of_images <= $day_of_year ) { $image_to_use = ($day_of_year % $no_of_images)-1; } else { $image_to_use = $day_of_year-1; }; print "Location: $files[$image_to_use]\n\n"; If my web page calls this script from the 'data' directory, I receive this error message: Illegal modulus zero at /usr/local/www/apache22/data/s-pics/display-pic.pl line 28. Even if I put the script in the same directory as the web page, it will fail, I need to have everything in the same directory, and that is not practical. I have no idea what I am doing wrong (what else is new). How can I fix this? Thanks! -- Gerard Love is in the offing. The Homicidal Maniac
Attachment:
signature.asc
Description: PGP signature