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

perldoc perlop

[ *SNIP* ]

    Binary "%" computes the modulus of two numbers.  Given integer
    operands $a and $b: If $b is positive, then "$a % $b" is $a minus
    the largest multiple of $b that is not greater than $a.  If $b is
    negative, then "$a % $b" is $a minus the smallest multiple of $b
    that is not less than $a (i.e. the result will be less than or equal
    to zero).  Note that when "use integer" is in scope, "%" gives you
    direct access to the modulus operator as implemented by your C
    compiler.  This operator is not as well defined for negative
    operands, but it will execute faster.
LOL, I didn't understand any of that. :-)
Apart from the last sentence ;-)



And presumably starts out as a 4 digit number, gets tested and overwritten by 0 or 1, 1 being true?

What starts out as a 4 digit number? What gets tested? What gets
$year
overwritten? You will have to be more specific on what you think is happening for me to either agree with you or correct you.

I'm tired, it's about 5 hours past my bedtime.
I think I had better go hit the sack.

--
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