開発環境
- macOS Catalina - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Strawberry Perl (WindowsのPerlの言語処理系)
- Visual Studio Code (Text Editor)
- Perl 5.28 (プログラミング言語)
初めてのPerl 第7版 (Randal L. Schwartz(著)、brian d foy(著)、Tom Phoenix(著)、近藤 嘉雪(翻訳)、嶋田 健志(翻訳)、オライリージャパン)の16章(上級テクニック)、16.6(練習問題)3の解答を求めてみる。
コード
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use v5.18;
use Encode::Locale;
binmode STDIN, ':encoding(console_in)';
binmode STDOUT, ':encoding(console_out)';
binmode STDERR, ':encoding(console_out)';
say '3.';
chdir '/usr/';
for (<* .*>) {
my @times = (stat $_)[8, 9];
next unless @times;
printf "%-20s ", $_;
for my $time (@times) {
my ($year, $mon, $day) = (localtime $time)[5, 4, 3];
printf "%4d-%02d-%02d ", $year + 1900, $mon + 1, $day;
}
print "\n";
}
入出力結果(Zsh、cmd.exe(コマンドプロンプト)、Terminal)
% ./sample3.pl 3. bin 2019-09-30 2019-10-23 lib 2019-09-30 2019-10-23 libexec 2019-09-30 2019-10-23 local 2019-10-23 2019-10-23 sbin 2019-09-30 2019-10-08 share 2019-09-30 2019-10-08 standalone 2019-09-30 2019-09-30 . 2019-09-30 2019-10-08 .. 2019-10-23 2019-10-23 %
0 コメント:
コメントを投稿