Gossamer Forum
Home : General : Perl Programming :

Error 500, but why?

Quote Reply
Error 500, but why?
Can anyone see anything wrong with the below code?

Code:
sub ShowDate {

# setup all the variables etc...
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$year = $year + 1900;
my $Date = "Date: $year-$month-$day";

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

}

I've tried everything I can (including commenting out the date grabbing part, and manually populating the values).

fatalsToBrowser doesn't seem to be showing anything either.. which really has me puzled (I don't have an error log I can access, before you ask Paul Wink)

TIA.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Error 500, but why? In reply to
If you use strict mode you must declare all vars.
But var '$month' doesn't declared.
You fetch $mon var via localtime, but not $month
Quote Reply
Re: [hellman] Error 500, but why? In reply to
True about the $month and $mon variables... but even after changing that, it still produces a 500 IS Error Unsure

The whole script is;

Code:
#!/usr/bin/perl

use CGI::Carp qw(fatalsToBrowser);

eval {
&ShowDate;
};

if ($@) {
print "Content-type: text/html \n\n";
print "Error: $@";
exit;
}

sub ShowDate {

# setup all the variables etc...
my ($sec,$min,$hour,$mday,$month,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$year = $year + 1900;
my $Date = "Date: $year-$month-$day";

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

}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Error 500, but why? In reply to
Works fine for me except the day is blank as you are using another non existant variable - $day
Quote Reply
Re: [Paul] Error 500, but why? In reply to
Weird. Its working ok now on my main server, but not locally. Must be a screw up in Perl on my PC Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!