# # This software is Copyright 2005 by Elsevier Inc. You may use it # under the terms of the license at http://perl.plover.com/hop/LICENSE.txt . # ### ### dir_walk-iterator ### ## Chapter 4 section 2.2 # iterator version sub dir_walk { my @queue = shift; return Iterator { if (@queue) { my $file = shift @queue; if (-d $file) { opendir my $dh, $file or next; my @newfiles = grep {$_ ne "." && $_ ne ".."} readdir $dh; push @queue, map "$file/$_", @newfiles; } return $file; } else { return; } }; }