Learning PERL, needing a real-world example to hurl myself upon, I picked a problem I've already resolved using BASH.

What I need: Login to an FTP server. Using a list of directories, move all files in that directory tree to another directory, renaming to standard.

So this

/test1/in/foo.edi /test1/in/dir/bar.edi

becomes this

/composite/test1_YYYYMMDDHHSS_foo.edi /composite/test1_YYYYMMDDHHSS_bar.edi

I've got the move and rename down. For 'a' directory.

Where I appear to be stuck is getting that sucker to walk the directory tree.

It's executing without error, I just don't see where I've gone wrong, why it's not calling wanted subroutine.

Script
#!/usr/bin/perl -s use strict; use warnings; use diagnostics; use Net::FTP::Find; my($host) = "ftp2.site.com"; my($user) = "redacted"; my($password) = "redacted"; my($ftpdir) = "/test1/in"; my $ftpfind = Net::FTP::Find->new($host) or die "Can't open $host: $@\ +n"; $ftpfind->login($user, $password) or die "Can't log $user in: $ftpfind +\n"; $ftpfind->cwd($ftpdir) or die "Can't cwd to $ftpdir: $ftpfind\n"; print "this is ftpfind $ftpfind\n"; # sanity check so I know it's doin +g _something_ $ftpfind->finddepth (\&wanted, "/test1/in"); sub wanted { print "hello"; print $_; }
$ ./dirwalkftp.pl this is ftpfind Net::FTP::Find=GLOB(0x10083ce10) $
edited to add shell type and variable $ftpdir. Thanks, dulwar.

In reply to Walking a directory tree with net:FTP:find by bdunbar

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.