The ls -l is the only way I can think of, and it is pretty easy to parse the
output.

# Your @data will come from the FTP server, mine came from
# the command line.
my @data = `ls -l`;

for ( @data ) {
        my $idDirectory = (/^/) ? 1 : 0;
        my $filename = [split /\s+/]->[8];
        
        if ( $isDirectory ) {
                print "$filename is a directory\n";
        }
        else {
                print "$filename is a file\n";
        }
}

Rob


-----Original Message-----
From: Dhiraj P Nilange [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 3:45 PM
To: [EMAIL PROTECTED]
Subject: dir/file from ftp site



I want to connect to a ftp site
and in I want to get a list of
all files and directories in some
given directory. I know how to do
that using Net::FTP package. I want
to know that after issuing what will
be easiest way to check whether each
entry in the directory list is a file
or a directory? I used ->ls('-l') but
thats giving whole long text list. Well
I know that if the first character in the list is 'd'
then its directory otherwise its file. but in that case i will have to
extract file/dir names from each entry. Is there any other way? Assume that
that site has UNIX system.

thanks
-dhiraj 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to