Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?

by jryan (Vicar)
on Jun 16, 2008 at 21:53 UTC ( #692387=note: print w/replies, xml ) Need Help??


in reply to Re: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?
in thread Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?

Hmmm, thats fair. Give me a minute and I'll attach some code and some test files. Is there any easy way to attach a zip file here?
  • Comment on Re^2: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?

Replies are listed 'Best First'.
Re^3: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?
by Anonymous Monk on Jun 17, 2008 at 06:12 UTC

    Here is some code I wrote back in 2001 that takes advantage of the fact that we can push onto an array we are currently iterating over. So it's called an infinite stream eh, cute name. Anyway this happily recurses a directory (or any other) tree.

    my $root = 'c:/somedir/'; my @dirs = ($root); my @files; for my $path (@dirs){ opendir ( DIR, $path ) or next; # skip dirs we can't read while (my $file = readdir DIR) { next if $file eq '.' or $file eq '..';# skip dot files next if -l $path.$file; # skip sym links if ( -d $path.$file ) { push @dirs, $path.$file.'/'; # add dir to list } else { push @files, $path.$file; # add file to list } } closedir DIR; }
Re^3: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?
by moritz (Cardinal) on Jun 19, 2008 at 11:25 UTC
    Is there any easy way to attach a zip file here?

    No, you have to upload it somewhere else and link it here then.

    But first check if ikegami's solution works for you - if yes, no need to duplicate the effort.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://692387]
help
Chatterbox?
[LanX]: ...
[sierpinski]: test passed?
[sierpinski]: It's really weird seeing that I have 20 votes now.. I've been at 18 for so long
[LanX]: yes, test passed :)
[sierpinski]: woo hoo! you can go home for the day now
[Eily]: does this mean you'll give up the random prefix solution LanX?
[LanX]: yep, sorry ;(

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-03-28 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (331 votes). Check out past polls.