Brian wrote:
This is what I'm using upto the code that is giving me a headache.
I know it's messy, but I have no training in PERL, I am trying to
forward-engineer this cgi by back-engineering from html templates I
created and which were chosen using $t->src
[ *SNIP* ]
################ whether or not leapyear
{
($myleap = 0 )
}
if ($Calend eq "b" ) {$myleap += 1}
if ($Calend eq "d" ) {$myleap += 1}
if ($Calend eq "f" ) {$myleap += 1}
if ($Calend eq "h" ) {$myleap += 1}
The usual way to calculate a leap year is:
sub is_leap_year {
my $year = shift;
return $year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0
}
################ whether year starts on a Sunday
{
($mystart = 0 )
}
if ($Calend eq "a" || $Calend eq "b") {$mystart -= 0}
if ($Calend eq "c" || $Calend eq "d") {$mystart -= 1}
if ($Calend eq "e" || $Calend eq "f") {$mystart -= 2}
if ($Calend eq "g" || $Calend eq "h") {$mystart -= 3}
use Time::Local;
sub year_starts_sunday {
my $year = shift;
return !( gmtime timegm 0, 0, 12, 1, 0, $year - 1900 )[ 6 ]
}
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/