Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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;
Thanks!

Comment on File::Find questions
Select or Download Code
Re: File::Find questions
by GrandFather (Cardinal) 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
    Hi,
    I always use find2perl to construct my wanted sub
    Regards,
    svenXY

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://515097]
Approved by neversaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2014-08-20 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls