|
|
||
http://perl.g.hatena.ne.jp/ukme/20081207/1228645848
http://perl.g.hatena.ne.jp/ishiduca/20081209/1228806653
#!/usr/bin/perl use strict; my $year = $ARGV[0] || 2008; print ( ( $year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0 ) ? "$year年は閏年\n" : "$year年は閏年じゃない\n" );
ベストプラクティス的な書き方知りたいす
{
shift;
my $year = shift;
# According to Bjorn Tackmann, this line prevents an infinite loop
# when running the tests under Qemu. I cannot reproduce this on
# Ubuntu or with Strawberry Perl on Win2K.
return 0 if $year == INFINITY() || $year == NEG_INFINITY();
return 0 if $year % 4;
return 1 if $year % 100;
return 0 if $year % 400;
return 1;
}
from DateTimePP
http://iandeth.dyndns.org/mt/ian/archives/000620.html
これですね PPはPurePerlか
ついでに参考:
http://iandeth.dyndns.org/mt/ian/archives/000619.html