in reply to creating a list of files under each subfolder in a main directory

A bare bone recursive exploration of a sub-directory tree:
sub explore_dir { my ($path) = @_; my @dir_entries = glob("$path/*"); foreach my $entry (@dir_entries) { print "$path$entry\n" if -f $entry; explore_dir($entry) if -d $entry; } } explore_dir($start_path);
(I know it would be more politically correct to use a module, but, in such a case, it is in my view pedagogically more efficient to show a way to do everything in pure core Perl.)
  • Comment on Re: creating a list of files under each subfolder in a main directory
  • Download Code