Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, which function is better to delete a folder in windows platform $path="c:/temp"; rm $path rmtree $path any example or better way to do this?

Replies are listed 'Best First'.
Re: remove directory in perl
by ikegami (Patriarch) on May 20, 2009 at 14:54 UTC

    There is rmdir (for empty dirs) and File::Path::rmtree (for entire trees).

      i want to delete directories/sub directories based on their modified date
        See stat for some information on how to get Modify Time of a directory. It returns an array with various data on a supplied file or directory.
        #last modify time of /usr/bin: print scalar localtime((stat("/usr/bin"))[9]); # Thu May 14 13:52:17 2009 my $SECONDS_IN_DAY = 60*60*24; $days_old = (time-(stat($dirname))[9]) / $SECONDS_IN_DAY; if($days_old > 5){ #do_something }