in reply to How can I remove a Dir?

use File::Path; my $dir = '/to_remove'; rmtree([$dir], 0, 0);
File::Path comes with the standard distribution.

Replies are listed 'Best First'.
RE: Re: How can I remove a Dir?
by plaid (Chaplain) on Feb 21, 2000 at 03:36 UTC
    Let's try that again, now that I've actually tried reading something..
    use File::Path; my $dir = '/to_remove'; rmpath([$dir], 0, 0);
    File::Path comes with the standard distribution
      In fact, it's rmtree() instead rmpath() (at least in perl 5) 8^)

      Jose Quesada
        I'm still working with baby perl but this code will display all of the contents of a directory and prompt you with a yes or no to delete the entire directory and it's contents. This code works on perl 5.6.1 on a win32 system. Have fun!
        #!/usr/bin/perl-w use strict; use win32; my $dir = "U:\\foo\\bar\\perl"; system ("dir $dir"); system ("del $dir"); # here the /s includes subtrees and /q supresses the prompt # uncomment this and you won't get the prompt! # system ("del /s /q $dir"); system ("rmdir $dir");