開発環境
- OS X Lion - Apple(OS)
- BBEdit(Text Editor)
- プログラミング言語:Perl
『初めてのPerl 第6版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2012年、ISBN978-4-87311-567-2)の11章(モジュール)、11.4(練習問題)2を解いてみる。
その他参考書籍
2.
コード(BBEdit)
sample.pl
#!/usr/bin/env perl5.12 use strict; use warnings; use utf8; binmode STDOUT, ':utf8'; binmode STDIN, ':utf8'; # サポートが5.12までって出力された use DateTime; my($t_day, $t_mon, $t_year) = (localtime)[3, 4, 5]; my($year, $mon, $day) = @ARGV; my $dt1 = DateTime->new( year => $t_year + 1900, month => $t_mon + 1, day => $t_day ); my $dt2 = DateTime->new( year => $year, month => $mon, day => $day ); my $duration = $dt1 - $dt2; my @units = $duration->in_units( qw(years months days) ); printf "%d years, %d months, and %d days\n", @units;
入出力結果(Terminal)
$ ./sample.pl 1960 9 30 52 years, 5 months, and 29 days $
0 コメント:
コメントを投稿