Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Directory Recursion

by rob_au (Abbot)
on Jan 06, 2002 at 04:32 UTC ( [id://136626]=note: print w/replies, xml ) Need Help??


in reply to Directory Recursion

An interesting comment which I thought I might make is the fact that recent versions of File::Find, well at least that shipped with Perl 5.6.1, no longer use recursion (in the truest sense of the term) in order to generate a list of files. By recursion in the truest sense of the term, I refer to a single block of re-entrant code that is called for each new iteration through a directory - Instead, newer versions of File::Find make use of a stack method (search newer File::Find code for @Stack within the _find_dir subroutine) which allows for the processing of directories either by depth first or by breadth first, depending on where you expect files to reside.

A comparison of the File::Find code between versions 5.005.03 and 5.6.1 highlights a number of differences between recursion and stack processing which may be interesting to some.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

Replies are listed 'Best First'.
Directory-non-recursion (was Re: Re: Directory Recursion)
by merlyn (Sage) on Jan 06, 2002 at 05:19 UTC
      I'm a few years late to the party - but you are iterating over an array that you are extending, (@files) not sure what the party line is on this, but it caused me grief. Create a temporary array, then append the two together at the end. Then throw it all away and use File::Find.
        You replied to a wrong node. merlyn does not iterate over an array, he runs while (@array), which is correct.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://136626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-03-29 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found