開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの機能制限無料版、light版)
- Script言語:Perl
『続・初めてのPerl 改訂版』(Randal L. Schwartz, brian d foy, Tom Phoenix 著、伊藤 直也、田中 慎司、吉川 英興 監訳、株式会社ロングテール/長尾 高弘 訳、オライリー・ジャパン、2006年、ISBN4-87311-305-9) の15章(Exporter), 15.7(練習問題)2を解いてみる。
その他参考書籍
2.
コード(TextWrangler)
sample.pl
#!/usr/bin/env perl use strict; use warnings; use utf8; use 5.016; binmode STDIN, ':utf8'; binmode STDOUT, ':utf8'; use Oogaboogoo::date qw(:all); my($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime; $year += 1900; print "Today is ", wday($wday), ", ", month($mon), " $mday, $year\n";
Oogaboogoo/date.pm
#!/usr/bin/env perl package Oogaboogoo::date; use strict; use warnings; use utf8; use 5.016; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(wday month); our %EXPORT_TAGS =( all => [@EXPORT] ); my @wday = qw(ark dip wap sen pop sep kir); my @month = qw(dir pod bod rod sip wax lin sen kun fiz nap dep); sub wday{ my $n = shift @_; die unless $n >= 0 and $n <= 6; $wday[$n]; } sub month{ my $n = shift; die unless $n >= 0 and $n <= 11; $month[$n]; } return 1;
入出力結果(Terminal)
$ ./sample.pl Today is ark, nap 11, 2012 $
0 コメント:
コメントを投稿