2008-02-21から1日間の記事一覧
# 方法1 $seconds = $recent - $earlier
$when = $now + $difference $then = $now - $difference
# 方法 ($seconds, $minutes, $hour, $day_of_month, $month, $year, $wday, $yday, $isisdst) = localtime($time);
use Time::Local; $time = timelocal($sec, $min, $hours, $mday, $mon, $year); $time = timegm($sec, $min, $hours, $mday, $mon, $year);
# 方法1 ($day, $month, $year) = (localtime)[3,4,5]; # 方法2 use Time::localtime; $tm = localtime; ($day, $month, $year) = ($tm->mday, $tm->mon, $tm->year);
printf "It took %d hour%s\n", $time, $time == 1 ? "" : "s"; printf "%d hour%s %s enough.\n", $time, $time == 1 ? "" : "s", $time == 1 ? "is" : "are";
sub commify { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,g; return scalar reverse $text; }