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

In reply to Re: ftp'ing 'Find' results from an array by Ebany
in thread ftp'ing 'Find' results from an array by ortsac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.