Creating Websites That Work! Call Toll Free at 1-877-530-7993 For Assistance With Your Web Needs.
Design Solutions
E-commerce
Hosting Plans
Other Services
PERL - Random Links

1.) Upload to your cgi directory, chmod 755. You can call it either through your browser or using an include statement in your SSI file. Your text file should be in the format(remember the pipe between the link and the image location) :

http://www.yourdomain.com/link_location|location of the corresponding image
http://www.yourdomain.com/link2_location|location of the corresponding image2

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

$db = "location of text file...must be actual path ex. /u/web/your_id/files/txtfile.txt";
open (FID, "<$db");
@contents =<FID>;
$numRecords = scalar(@contents);
$index =int(rand($numRecords + 1));
$line = $contents[$index];
($html,$image)=split/\|/,$line;

print qq~

<img src="<a href="$html"><img src="$image" border="0"></a>

~;

exit;


  

Learning Center
About Us
Create-A-Website provides you with professional custom web solutions at affordable prices!