Perl web script to find leap year or not

Let’s write a simple Perl program to find leap year, very useful for beginners and school / college students,

Formula for finding a Leap year is as follows:

1. A year should be evenly divisible by 4 (should not have a reminder):

    year % 4 == 0 ( reminder should be 0 )

2. AND Year should not be evenly divisible by 100 (should have a reminder):

    year % 100 != 0 ( reminder should not be 0 )

3. OR Year should be evenly divisible by 400 (should have a reminder):

    year%400 == 0 ( reminder should be 0 )

So basically 1 && 2 || 3

if (1  and 2) both are true or 3 is true then it is a leap year

 

Here is the Perl web cgi script to find the leap year:

The code is self-explanatory, read the comments in the script to understand it well.

Here is the live demo of this script:

demo

Enjoy learning. Good luck!

Related Posts

Leave a Reply