I'm using Dir.glob to visit the set of all files matching a wildcard pattern.

Dir.glob( '**/*.txt' ) { |file_name|
    parse file_name
}

Because this glob call is recursive and because lots of files are involved, glob takes a long time to build the array of files before the block starts.

What I want instead is a way of visiting all of the same files, but calling the block immediately after Ruby "discovers" each file, so that the first file is processed right away rather than after waiting for the whole directory tree to finish being searched.

Is there such a construction?

Edit
Report