This script demonstrates the difference between the ls and dir methods of Net::FTP.
$ftp->ls returns file names only:
test
subdomains
httpdocs
.
error_docs
prod
cgi-bin
php
…
$ftp->dir returns more information:
drwx--x--- 16 username groupname 4096 Feb 10 12:55 .
drwxr-x--- 2 username groupname 4096 Feb 7 14:45 cgi-bin
drwxr-xr-x 2 username groupname 4096 Oct 16 2014 error_docs
drwxr-x--- 21 username groupname 4096 Feb 9 07:08 httpdocs
drwxr-xr-x 5 username groupname 4096 Feb 10 12:55 prod
drwxr-xr-x 2 username groupname 4096 Apr 12 2013 subdomains
drwxr-xr-x 5 username groupname 4096 Feb 10 12:55 test
…
ls-vs-dir.pl
#!/usr/bin/perl
use warnings;
use strict;
use Net::FTP;
my $host = shift or die;
my $username = shift or die;
my $password = shift or die;
my $path = shift or die;
my $ftp = Net::FTP->new($host) or die "Could not connect to $host";
$ftp->login($username, $password) or die "Could not login as $username";
$ftp->cwd($path);
my @dir = $ftp->dir;
my @ls = $ftp->ls;
print "dir:\n ";
print join "\n ", @dir;
print "\nls\n ";
print join "\n ", @ls;