#!/usr/bin/perl
use strict;
my $dir = $ARGV[0];
&fun ($dir);
sub
fun ()
{
my $current = shift;
opendir DIR, $current or die "can not open dir";
my @ list = readdir DIR;
foreach my $item (@list)
{
if (-f $current."/".$item)
{
print $item." is a file\n";
}
else
{
if (-d $current."/".$item && $item ! ~/^[\.]{1, 2}/)
{
print $item." is a directory\n";
&fun ($current."/".$item);
}
}
}
}
阅读(2112) | 评论(1) | 转发(1) |