初めてのPerl ~ 11章 ファイルハンドルとファイルテスト ~

練習問題 11.7.2

 コマンドラインからファイル名のリストを受け取って、その1つ1つについて、
 読み出し可能か、書き込み可能か、実行可能か、存在しないかを表示するプログラムを
 書く。

#! /usr/bin/perl

use strict;
use warnings;

sub check_file{
  foreach( @_ ){
    if( -e $_ ){
       print "$_ \n";
       print "\treadable \n" if -r _ ;
       print "\twritable\n" if -w _ ;
       print "\texecutable \n" if -e _ ;
    }
    else{
       print "There is not file or folder\n";
    }
  }
}

&check_file(@ARGV);

参考書

初めてのPerl

初めてのPerl