One thing though that isn't working is that it isn't going into this section:
Code:
#!/usr/local/bin/perl -w
# Prints the
Gossamer Threads Home Page greeting.
# Author: Alex Krohn (alex@gossamer-threads.com)
# NOTE: You need the list of domains to country names. I got mine from Analog and
# you can find it here:
#
# http://www.gossamer-threads.com/scripts/source/domains.tab
#
use strict;
print "Content-type: text/html\n\n";
my ($time, $greeting) = &get_date;
my $country = &get_country;
print qq~
<P><font face="arial,verdana,helvetica,tahoma" size=3><b>$greeting, and thanks for visiting
Gossamer Threads' website. Your interest in our site is appreciated.</b>
<P>Its $time in beautiful Vancouver, British Columbia, Canada where
Gossamer Threads is located. Country - $country
~;
if (defined $country and ($country =~ /Canada/i)) {
print qq|It's good to see someone else from Canada!|;
}
elsif (defined $country) {
print qq|What's it like in $country? Let me <a href="/feedback.htm">know</a>!\n"|;
}
exit;
sub get_country {
# --------------------------------------------------------------
my ($match, $code, $name);
if (exists $ENV{'REMOTE_HOST'} and ($ENV{'REMOTE_HOST'} =~ /\.(..)$/)) {
$match = $1;
open (DOMAINS, "domains.tab") or (print "SYSTEM ERR: CANT OPEN FILE" and exit);
while (<DOMAINS>) {
chomp;
($code, $name) = split (/:/);
($code eq $match) and close DOMAINS and return $name;
}
close DOMAINS;
}
return undef;
}
sub get_date {
# --------------------------------------------------------------
my @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
my @months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time - 10800);
($hour < 10) and ($hour = "0$hour");
($min < 10) and ($min = "0$min");
($sec < 10) and ($sec = "0$sec");
my $date = "$days[$wday] $months[$mon] $mday";
my ($greeting, $noon);
if ($hour < 12) { $greeting = "Good Morning"; }
elsif ($hour >=12 && $hour < 17) { $greeting = "Good Afternoon"; }
elsif ($hour >=17 && $hour < 24) { $greeting = "Good Evening"; }
else { $greeting = "Hello"; }
($hour < 12) and ($noon = "am");
($hour > 12) and ($hour = $hour - 12) and ($noon = "pm");
($hour == 00) and ($hour = 12);
($hour == 12) and ($noon = "pm");
return "$hour\:$min $noon on $days[$wday], $months[$mon] $mday", $greeting;
}