in reply to ftp'ing 'Find' results from an array

Ok, I tackled something similar, but not exactly the same. Essentially, in my case, I wanted to build a link tree by ftping into a bunch of different accounts, and then going through each directory, and finding all the physical files, and then printing those out. I belive my situation maybe applicable though, as it would only take a small bit of hacking to put in a ftp->get()

Note: This is code extract! Concept is the same though. Assume that warnings et all are included, and certain parts are excluded for brevity. Also, this was made for ftping into a VMS system. The program does work.

my $ftpSession; if (login($current, getPass($current))) { @dirs = retrDirs(); @goodFiles = retrFiles(); foreach (@goodFiles) { {Insert code here} } if (@dirs) { foreach (@dirs) { _recparseTree ($_,""); } } } #This begins a new ftp session with a passed username and password sub login { my ($user, $pass) = @_; $ftpSession = Net::FTP->new($server, Debug => 0) or die printError +Entry ("", "Error logging into server."); $ftpSession->login($user,$pass) or return 0; $ftpSession->cwd("{base dir}"); return 1; } #This simply gets the current directory. sub getStruct { return $ftpSession->ls(); } #This reads the current directory, and picks out all .html, .htm, .htm +lx, and .pdf files, and returns an array sub retrFiles { my @tempfiles = getStruct(); my @results; foreach (@tempfiles) { if ($_ =~ m{\.HTM} || $_ =~ m{\.PDF} ) { push(@results,$_); } } return @results; } #This reads the current directory, and picks out all subdirectories, r +eturning an array of results sub retrDirs { my @tempdirs = getStruct(); my @results; foreach (@tempdirs) { if ($_ =~ m{\.DIR} ) { push(@results,substr($_,0, index($_,"."))); } } return @results; } sub _recparseTree { #get directory name my ($dir, $dirname) = @_; $dirname.= "\/".$dir; #Change directory to target $ftpSession->cwd("[.$dir]"); #Get the structure my @tempList = retrFiles(); my @tempDirs = retrDirs(); #If there are files in the directory. if (@tempList) { {Insert code here} foreach (@tempList){ {Insert code here} } } if (@tempDirs) { foreach (@tempDirs) { _recparseTree($_, $dirname) +; } } $ftpSession->cwd(".."); }


This is not meant to be a running program, but hopefully an example you can use. Essentially, in order to mimic File::Find, I go through utilizing dual arrays to keep track of all files and directories, and navigate with those.

Edit: Deleted some extraneous lines of code