raphael() wrote:
> Hi,
>
> How can I stop File::Find to go below current dir? i.e. no recursion.
>
> Although I can use glob or <*> to get file names in current dir.
> But I wanted to know if File::Find has a maxdepth limit like linux "find".
>
> The script I created uses a switch which decides if recursion is allowed or
> not.
> It uses the system find like this..
>
> open(FIND, "find -maxdepth $recursive |" );
>
> I wanted to remove this dependency on system find. Is it possible with
> File::Find?
>
> I tried this after googling
>
> http://www.perlmonks.org/?node_id=676958
>
> sub wanted
> {
> if ( -d ) { # should I write this as -d $File::Find::name
# No, this is shorthand for:
if( -d $_ ){
> $File::Find::prune = 1;
> return;
> }
> print $File::Find::name . "\n";
> }
>
And didn't it work? The if statement works on all directories. This
means that all directories except the top-level one will not be searched.
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/