in reply to Get contents in an FTP path using glob

glob works directly on file system so doesn't somehow extend ftp protocol beyond it's RFC implementation. In other words, you can only execute ftp commands (and parse their output), which includes a very basic filename matching similar to DOS in the limited FTP command set.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re: Get contents in an FTP path using glob

Replies are listed 'Best First'.
Re^2: Get contents in an FTP path using glob
by Khen1950fx (Canon) on Feb 02, 2010 at 00:00 UTC
    As a followup to aquarium's post, here's an example that uses a simple print and Dumper:
    #!/usr/bin/perl use Net::FTP; use Data::Dumper::Concise; use constant HOST => 'ftp.cpan.org'; use constant DIR1 => '/pub/CPAN/authors'; my $ftp = Net::FTP->new( HOST, Debug => 1, Passive => 1, Timeout => 1 ); $ftp->login('anonymous'); $ftp->cwd(DIR1); print Dumper $ftp->dir(<DIR1>); $ftp->quit;
    Note: The list of authors isn't current because its not maintained anymore. I only use it for examples. Update: Or you could use a glob and ls:
    #!/usr/bin/perl use Net::FTP; use Data::Dumper::Concise; use constant HOST => 'ftp.cpan.org'; use constant DIR1 => '/pub/CPAN/authors'; use constant GLOB => '*.???'; my $ftp = Net::FTP->new( HOST, Debug => 1, Passive => 1, Timeout => 1 ); $ftp->login('anonymous'); $ftp->cwd(DIR1); print Dumper $ftp->ls(<GLOB>); $ftp->quit;