John W. Krahn wrote:
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
    }

I guess that % means 'wholly divisible by'
And presumably starts out as a 4 digit number, gets tested and overwritten by 0 or 1, 1 being true?




################ 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 ]
    }


Oh oh oh, I think you think I am only working with the current year.
This is how my live prog works using "cgi loading templates"
http://www.absey-vine.co.uk/calendar/

and this is how my "cgi only" runs, it only displays 2006 regardless of the year you input.
http://www.absey-vine.co.uk/calendar/testing123/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to