Search notes:

Perl module Net::FTP - ls vs dir

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;
Github repository PerlModules, path: /Net/FTP/ls-vs-dir.pl

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759398183, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/Net/FTP/ls-vs-dir(84): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78