Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

File::Find questions

by Anonymous Monk
on Dec 08, 2005 at 01:11 UTC ( #515097=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have 2 questions concerning File::Find.

1. Considering the following code snippet, can someone tell me what is going on?

@path{@INC} = (); # Then later in the find sub, we see: $File::Find::prune = 1, return if exists $path{$File::Find::dir} and $File::Find::dir ne $File +::Find::topdir; # What is going in the above line? What is the purpose?
2. The following gives me the desired results (the file name without its location), except when the starting directory is /. Why? And what could I do to fix it?
$name = substr $File::Find::name, length $File::Find::topdir;

Replies are listed 'Best First'.
Re: File::Find questions
by GrandFather (Sage) on Dec 08, 2005 at 02:37 UTC

    $File::Find::prune = 1 indicates that Find shouldn't recurse any further down the directory tree from the current folder.

    DWIM is Perl's answer to Gödel
Re: File::Find questions
by vek (Prior) on Dec 08, 2005 at 07:57 UTC

    If you're finding File::Find a little confusing, have a peek at File::Find::Rule. I've found the interface far nicer than File::Find. YMMV of course :-)

    -- vek --
Re: File::Find questions
by svenXY (Deacon) on Dec 08, 2005 at 09:51 UTC
    I always use find2perl to construct my wanted sub

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://515097]
Approved by neversaint
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-07-27 06:14 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (404 votes). Check out past polls.