Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Directory Recursion

by rob_au (Abbot)
on Jan 06, 2002 at 04:32 UTC ( #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'


Comment on Re: Directory Recursion
Select or Download Code
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
Node Status?
node history
Node Type: note [id://136626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-07-22 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (109 votes), past polls