ディレクトリパースコマンド

 #!/usr/bin/perl    
                    
 use File::Find;  
 use Data::Dumper;
 use Getopt::Long;
 
 $key = '-';
 
 $nodot = 0;
 $help = 0;
 GetOptions('nodot' => \$nodot,'help' => \$help);
 help() if $help;
 
 $d = shift or $d = '.';
 $d =~ s/^(.*)\/$/$1/;
 find(\&show,($d));;
 sub show {
     $tmp = substr($File::Find::name,length $d);
     return if $tmp eq '';
     next if $nodot && $tmp =~ m#/\.#;
     @names = split '/', $tmp;
     shift @names;
     $depth = (scalar @names);
     print $key x $depth;
     if (-d $_){
         print "$_/\n";
     }else{
         print "$_\n";
     }
 }
 
 sub help {
     print <<"EOF";
 usage) $0 [--nodot] [dir]
        nodot: don't show dot files/dirs
 EOF
     exit;
 }

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2006-06-08 (木) 16:26:09