+
+sub recursive_file_listing {
+ my ($ftp,$dir) = @_;
+ my $listing;
+ my $orig_dir = $ftp->pwd();
+ eval {
+ $ftp->cwd($dir) or die "Not a directory $dir";
+ $listing = {};
+ my @files = $ftp->ls();
+ p @files if $DEBUG;
+ for my $file (@files) {
+ print STDERR "file: $file\n";
+ my $subdirs = recursive_file_listing($ftp,$file);
+ if (defined $subdirs) {
+ print STDERR "subdirs is :";
+ print STDERR p($subdirs);
+ $listing->{$file} = $subdirs;
+ } else {
+ print STDERR "No subdirectory\n";
+ $listing->{$file} = $orig_dir.'/'.$dir.'/'.$file;
+ }
+ }
+ };
+ $ftp->cwd($orig_dir);
+ return $listing;
+}
+
+
+