toadi has asked for the wisdom of the Perl Monks concerning the following question:

hello,

I wrote a perl program the recusivly does things in directorys. But I want to give the user the option to not recurse the directorys.
find (sub { return unless -f;# only files &putid($File::Find::name); }, $ARGV[0]);
This is my code if file do something in sub. But how can i say not recurse directories in this code?

It's probably a option in File::Find I can't seem to find :)

--
My opinions may have changed,
but not the fact that I am right

Replies are listed 'Best First'.
Re: File::Find not recursive
by merlyn (Sage) on May 31, 2001 at 18:44 UTC
    You have (at least) two choices:
    1. Don't use File::Find on the times when you don't want to recurse. Globbing or directory handles are pretty easy to wrangle.
    2. Turn on $File::Find::prune = 1; each time you enter the subroutine and the value of $File::Find::name is not your top-level directory. This tells File::Find that this subdirectory should not be entered. It'll be ignored for files.

    -- Randal L. Schwartz, Perl hacker

Re: File::Find not recursive
by Beatnik (Parson) on May 31, 2001 at 20:31 UTC