Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Parsing FTP ls command results

by randyk (Parson)
on Sep 13, 2007 at 14:31 UTC ( #638806=note: print w/replies, xml ) Need Help??

in reply to Parsing FTP ls command results

You could use the parse_dir function of File::Listing:
use strict; use warnings; use Net::FTP; use File::Listing qw(parse_dir); my $ftp = Net::FTP->new(''); $ftp->login('user', 'password'); my $ls = $ftp->dir('/etc'); foreach my $entry (parse_dir($ls)) { my ($name, $type, $size, $mtime, $mode) = @$entry; if ($type eq 'd') { print "The directory is $name\n"; } else { next unless ($type eq 'f' and $size > 0); print "$name has size $size\n"; } } $ftp->quit;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://638806]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2016-10-21 16:27 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.