開発環境
- macOS Mojave - 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(著)、近藤 嘉雪(翻訳)、嶋田 健志(翻訳)、オライリージャパン)の13章(ディレクトリ操作)、13.4(練習問題)8の解答を求めてみる。
コード
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use v5.18;
say '8.';
while (<.* *>) {
if (-l $_) {
say "$_ -> ", readlink $_;
}
}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ tree
.
├── a.txt
├── b.txt
├── c.txt -> a.txt
├── e.txt -> tmp/d.txt
├── sample8.pl
├── tmp
│ ├── c.txt
│ ├── d.txt -> b.txt
│ └── e.txt
└── tmp1
└── c.txt -> c.txt
2 directories, 9 files
$ ./sample8.pl
8.
c.txt -> a.txt
e.txt -> tmp/d.txt
$
0 コメント:
コメントを投稿