CGI Script Problems

liunx

Guest
Hi,

Truly Baffled.

This script works:

#!/usr/local/bin/perl -wT

use strict;
use CGI qw(:cgi);

my @time = localtime;

my $hour = $time[2];

my $location;

if ($hour >= 20 && $hour <= 23)
{
$location = "http://www.someurl.com/";
}
else
{
$location = "http://www.someotherurl.com/";
}

print redirect($location);


This script does not work :

#!/usr/local/bin/perl -wT

use strict;
use CGI qw(:cgi);

my @time = localtime;

my $hour = $time[2];

my $mday = $day[3];

my $location;

if (($hour >= 20 && $hour <= 23) && ($mday >=0 && $mday <= 4))
{
$location = "http://www.someurl.com/";
}
else
{
$location = "http://www.someotherurl.com/";
}

print redirect($location);


What is wrong? I don't see anything wrong? I'm a newbie.

The scripts purpose is to direct a request to the appropriate web page according to the day and the time of day.

Example: If it's 3pm on Monday the user is directed to page a. If it's 3pm on Sunday the user is directed to page b.

thanksTry this:


#!/usr/local/bin/perl -wT

use strict;
use CGI qw(:cgi);

my @time = localtime;

my $hour = $time[2];

my $mday = $time[3];

my $location;

if (($hour >= 20 && $hour <= 23) && ($mday >=0 && $mday <= 4))
{
$location = "http://www.someurl.com/";
}
else
{
$location = "http://www.someotherurl.com/";
}

print redirect($location);


there is no array (@day) for $day[3] to get a value from, it just needed to be changed to $time[3]

Regards,
KevinCheers! Perl/CGI is cool with me again.
 
Back
Top