I have a program that is supposed to send files throw FTP. And I'm
using the Net::FTP. I have a destiny path and I need to create the
directories if they don't exist.

How do I check if a Directory exist?

Actual code +-:

sub fput($$$) {
   my ($ftp, $orig, $dest) = @_;
   
   return if $orig =~ /xpto/;

   $dest = File::Spec->canonpath($dest);
   if (-f $orig) {
       my ($volume,$directories,$file) = File::Spec->splitpath($dest);
       
       $ftp->mkdir($directories, 1) or print "Can't create directory:
", $ftp->message();
       
       if ($ftp->put($orig, $dest)) {
           print "file      '$orig' sent.\n";
       } else {
           print "Can't put: ", $ftp->message();
       }
   } elsif (-d $orig) {
       print "directory '$orig' not sent.\n";
   } else {
       die "Path '$orig' is not recognized\n".HELP;        
   }
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to