#!/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);
In reply to Controlling depth with File::Find by arturo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |