sub new { my $class = shift; my $base = shift; my $self = {}; bless $self, $class; # store my base for later $self->{base} = $base; $debug && print "spawned with base [$base]\n"; # read in contents of current directory opendir (BASE, $base); my @entries = grep !/^\.\.?\z/, readdir BASE; chomp(@entries); closedir(BASE); for my $entry (@entries) { print "DEBUG: processing '$base/$entry'\n"; # if entry is a directory, launch a new File::List to explore it # and store a reference to the new object in the dirlist hash if (-d "$base/$entry") { $debug && print _trace(),"following directory $base/$entry\n"; my $newbase = new File::List("$base/$entry"); $self->{dirlist}{ $entry } = $newbase; } # if entry is a file, store it's name in the dirlist hash elsif ( -f "$base/$entry"){ $debug && print _trace(),"Found file : $base/$entry\n"; $self->{dirlist}{ $entry } = 1; } else { print "DEBUG: '$base/$entry' is not -f nor -d\n"; } } return $self; }