Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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&&[@.]/&&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?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2021-04-17 14:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found