2020年5月30日土曜日

開発環境

初めてのPerl 第7版 (Randal L. Schwartz(著)brian d foy(著)Tom Phoenix(著)近藤 嘉雪(翻訳)嶋田 健志(翻訳)、オライリージャパン)の13章(ディレクトリ操作)、13.14(練習問題)4の解答を求めてみる。

コード

sample4.pl

#!/usr/bin/env perl
use strict;
use warnings;
use v5.28;

say '4';

unlink @ARGV;

sample4_1.pl

#!/usr/bin/env perl
use strict;
use warnings;
use v5.28;

say '4';

foreach (@ARGV) {
    unlink or warn $!;
}

入出力結果(Zsh、PowerShell、Terminal)

% mkdir temp
% touch temp/temp{1,2,3,4,5}.txt
% ls temp
./  temp1.txt temp3.txt temp5.txt
../  temp2.txt temp4.txt
% ./sample4.pl 
4.
% ./sample4.pl temp/*
4.
% ls temp 
./ ../
% touch temp/temp{1,2,3,4,5}.txt
% chmod 0 temp/temp2.txt 
% ./sample4.pl temp/*
4.
% ls temp 
./ ../
% touch temp/temp{1,2,3,4,5}.txt
% chmod 0 temp
% ./sample4.pl temp 
4.
% ls temp
ls: temp: Permission denied
% ./sample4_1.pl temp/*
zsh: no matches found: temp/*
% chmod 0755 temp
% ./sample4_1.pl temp/*
4.
% ls temp
./ ../
% touch temp/temp{1,2,3,4,5}.txt
% ./sample4_1.pl temp temp/* temp
4.
Is a directory at ./sample4_1.pl line 9.
Is a directory at ./sample4_1.pl line 9.
% ls temp
./ ../
%

0 コメント:

コメントを投稿