Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* ディレクトリパースコマンド [#i7db67f3]
#!/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;
}
終了行:
* ディレクトリパースコマンド [#i7db67f3]
#!/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;
}
ページ名: