#
# 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 .
#



###
### interesting_files
###

## Chapter 4 section 3

sub interesting_files {
 my $is_interesting = shift;
  my @queue = @_;
  return Iterator {
    while (@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 if $is_interesting->($file);
    } 
    return;
  };
}
