Mailinglist Archive: opensuse (4343 mails)

< Previous Next >
Redirecting URL with perl
  • From: Togan Muftuoglu <toganm@xxxxxxxxxxxx>
  • Date: Sat, 2 Nov 2002 00:59:39 +0200
  • Message-id: <20021101225939.GD1897@xxxxxxxxxxxx>
Hi,

First I have no idea about writing anything with perl so be gentle :-)

I would like to redirect the incoming http requests randomly to a
selective URL. Below is what I thought would do.

#!/usr/bin/perl -w
# Do I need this module ?
use CGI qw(:cgi);
@URL =("http://susefaq.sourceforge.net";,
"http://dinamizm.ath.cx";,
"http://toganm.tripod.com";,
"http://www.smaug42.com/susefaq";,
"http://www.bmtsolutions.com/suse_faq";,
"http://www.jon.fl.net.au/suse/unofficial-faq";,
"http://www.e-vega.info/susefaq";,
"http://www.ods.co.cr/susefaq";,
"http://www.netbulans.com/susefaq";,
"http://www.wdm.com/susefaq";,
"http://www.myxdu.com/susefaq";,
"http://www.tigersden.co.uk/susefaq";);

srand(time |$$);
$number_of_url=$#URL;
$random =int(rand($numer_of_URL));

$random_URL = $URL[$random];

#We will redirect print "Content-type: text/html", "\n\n";

print "Location: $random_URL\n\n";
exit;


1) First of all is this correct
2) How do I get it work in the HTML




--

Togan Muftuoglu
Unofficial SuSE FAQ Maintainer
http://dinamizm.ath.cx



< Previous Next >