開発環境
- OS X Mavericks - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs (Text Editor)
- Perl (プログラミング言語)
初めてのPerl 第6版 (Randal L. Schwartz (著)、brian d foy (著)、Tom Phoenix (著)、近藤 嘉雪 (翻訳)、オライリージャパン)、12章(ファイルテスト)の12.5(練習問題)2.を解いてみる。
その他参考書籍
12.5(練習問題)2.
コード(BBEdit, Emacs)
sample266_2.pl
#!/usr/bin/env perl
use strict;
use warnings;
use 5.016;
use utf8;
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
binmode STDERR, ':utf8';
die 'Usage: <file> [file] ... ' unless @ARGV;
my $filename;
my $days = 0;
my $t;
for (@ARGV) {
$t = -M $_;
if ($t > $days) {
$filename = $_;
$days = $t;
}
}
say '最も古いファイルとその古さ';
printf "%s\n%d日\n", $filename, $days;
入出力結果(Terminal)
$ ./sample266_2.pl * 最も古いファイルとその古さ fred~ 48日 $ ./sample266_2.pl Usage:[file] ... at ./sample266_2.pl line 10. $
0 コメント:
コメントを投稿