Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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('some.host'); $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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://638806]
help
Chatterbox?
[Corion]: I should write some more code for my Jekyll clone, but I don't feel like it, so maybe I should just let that linger instead ;)
[karlgoethebier]: "...mein enemy..."
[marto]: it has finally stopped raining!
[Corion]: marto: Heh - we've got the rain here, now. But it's only intermittently, not permanent. But funny that you should complain about rain ;)
[Discipulus]: rain? i dont remember it..
[marto]: and good news all round, Flash will die come 2020!
[Corion]: So who will be the saviour of the universe, then?!

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-07-26 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (390 votes). Check out past polls.