#!/usr/bin/perl -w use strict; use File::Find; @ARGV = "." unless @ARGV; my $depth = 2; # or whatever makes sense sub showdirs { # line altered from original as per merlyn's # advice below (thanks!) $File::Find::prune = 1 if $File::Find::name =~ tr/\/// >= $depth; # do something, like this if you just want to print the subdirecto +ries print "$File::Find::name/\n" if -d; } find (\&showdirs, @ARGV);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Controlling depth with File::Find
by merlyn (Sage) on Oct 13, 2000 at 10:49 UTC |