Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

File::Find questions

by Anonymous Monk
on Dec 08, 2005 at 01:11 UTC ( [id://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!

Replies are listed 'Best First'.
Re: File::Find questions
by GrandFather (Saint) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-03-28 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found