>>>>> "DaugeFa" == DaugeFa  <[EMAIL PROTECTED]> writes:

> Hi, 
> I really need some help to delete all the content of a directory. 
> I thought about deleting the directory and then create it again right after 
> the process with rmdir and mkdir...but it seems impossible as the directory 
> is not empty.
> How can I write unlink (every file) ? I tried *.* but it doesn't work.
> Thanks a lot in advance.

You can do this:

opendir(DIR, $your_dir) or die "Can't opendir() $your_dir: $!\n";
my @files = grep(!/^\.\.?$/, readdir(DIR)); # read all files except '.' & '..'
closedir(DIR);
unlink(@files);

or you may be able to try:

# cd to dir first (obviously)
unlink <*>;

but this will not delete files beginning with '.'. Be sure to test
this on some temp dir first.

Sarir

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to