[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Re: Listing Folders and Subfol



Robert Sweeney @DG&Astl writes:
>> I was asked to provide a directory tree for a website I'm working on, so I
>>created the following code, which worked. My question of the more
>>experienced MacPerl programmers: Was there a better/faster way to do this?

I use this.
This is bit faster. But not fastest, maybe...

#!/usr/bin/perl

$dc = 0;
&listup($ARGV[0]) if -d $ARGV[0];

sub listup {
    my(@files) = @_;
    foreach $fd (@files) {
        $fd =~ /([^:]+):?$/;
        print "\t"x$dc, "$1\/\n";
        opendir(DIR, $fd);
        $fd =~ s/:$//; # volume?
        @files2 = grep {-d ($_="$fd:$_")} readdir(DIR);
        closedir(DIR);
        if(@files2) {
            $dc++;
            &listup(@files2);
            $dc--;
        }
    }
}

--
Toshiaki Umemura
PXI07463@nifty.ne.jp
http://member.nifty.ne.jp/Nowral/

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org