[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] recursive delete



Jeremy Andrews wrote:
> 
> Is there a good way to recursively delete a directory and all of its
> subdirectories?  I've attempted to do this with the following code,
> but it doesn't work.  (I'm programming this on my Mac, but it's
> intended to work on a Apache UNIX machine...)
> 
> ##########
> # Recursively delete directory
> #       routine is called by passing in a directory to be deleted, in $_[0]

[code snipped]

Camel, 2nd ed., p 440 says:

#!/usr/bin/perl 

use File::Path;

rmtree(['/foo/bar/baz','blurfl/quux'], 1, 1);


In your case, you probably want something like:

-----------------------
#!/usr/bin/perl 

use File::Path;

#your code here..
rmtree($_[0], 1,1);
#your code here

See the docs on File::Path for more info.

Hope that helps,
Geoff

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org