I would like to delete all the file in a directory using only "rmdir" in perl script. I'm trying to clean up a directory first and then trying to write file. I know i can just use rmtree (" directory path"); but i'm unable to use that for FTP server (use Net::FTP;). and rmdir looks for empty directory. i have tried "remove_tree" and "rm -rf". i do have read/write access to the server, but i'm unable to delete files. Perl script:
finddepth (\&remove_dir, "$path"); rmdir ( "$path" ) or die ("Could not remove $path"); sub remove_dir { # for a path, this will be 0 if ( ! (stat("$File::Find::name"))[7] ) { $ftp->rmdir("$File::Find::name"); } else { $ftp->unlink("$File::Find::name"); } }

In reply to Recursive delete files using perl script by tipu123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.