You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
394 B
Perl

$my_year = 2000;
if ( is_leap_year( $my_year ) ) {
print "$my_year is a leap year\n";
}
else {
print "$my_year is not a leap year";
}
sub is_leap_year {
my $year = shift(@_); # Shift off the year from the parameter list, @_
return ((($year % 4 == 0) && ($year % 100 != 0)) ||
($year % 400 == 0)) ? 1 : 0; # What is returned from the function
}