use strict; use Net::FTP; use constant SERVER => 'server.somewhere.com'; use constant USERID => 'anonymous'; use constant PASSWORD => 'my.mail@somewhere.com'; use constant RMTDIR => '/tmp'; my $mFTP; #-- Open the connection $mFTP = Net::FTP->new(SERVER, Debug => 0); $mFTP->login(USERID,PASSWORD); #-- Process the contents $mFTP->cwd(RMTDIR); foreach ($mFTP->ls) { $mFTP->rmdir($_); if ($mFTP->ls($_)) { print $_," is a file...\n"; } else { print $_," *was* a directory...\n"; #-- Add file create code here... } } #-- Close the connection $mFTP->quit;