[EMAIL PROTECTED] wrote: > ----- Original Message ----- > From: Rob Dixon <[EMAIL PROTECTED]> > Date: Thursday, July 10, 2003 11:36 am > Subject: Re: Net::FTP > > > Dan Muey wrote: > > > > > What I'd like to do is simply: > > > > > (WHERE exists() is hopefully a solution to my first > > > > > question) > > > > > > > > > > if($ftp->exists($file)) { > > > > > $ftp->delete($file); > > > > > if($ftp->exists($file)) { print "Could not delete $file"; } > > > > > else { print "$file is all gone"; } } else { print "$file > > > > > does > > > > not exist so > > > > > I did not even try to delete it" } > > > > > > > > 'size' is the way to do it, but remember that it will return > > > > zero for a file of zero size. What you need is 'defined'. > > > > > > > > This little subroutine will fulfil your wishes and make the > > > > code above work. > > > > > > > > sub Net::FTP::exists { > > > > my $ftp = shift; > > > > defined $ftp->size(@_); > > > > } > > > > > > > > HTH, > > > > > > As always Rob a huge help. I'll play around with that. > > > It's makes so much sense when you think about it! > > > I'll tuck that one away under my big hat too! > > > > > > > Glad to help. FTP's a pain: as far as I know there's no way > > of telling whether a filename is a plain file or a directory > > either, without either trying to 'cwd' to it or parsing the > > output or 'dir'. > you probebly can tell if its a directory. just grab the first 1024 > bytes, and look inside it. Will be eassy if its laying on top of > UFS or FFS
That depends on your file system. I don't think most would let you open a directory as a plain file. What I'm pining for is something like $ftp->stat('entity'); Dan will tell us when he's written it :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]