[Perl] Two Filesystem Questions

lsprilus at bioinfo2.weizmann.ac.il lsprilus at bioinfo2.weizmann.ac.il
Sat Jan 18 22:40:31 PST 2003

According to Shlomi Fish:
> 2. How do I delete an entire directory tree portably? (without starting to
> hack away on one of those File::Finders.)

sub removeDir {
  use File::Find;
  finddepth(sub{if (-f $_){unlink $_;}else{rmdir $_;}},$dir);
  rmdir $dir;

 Dr Jaime Prilusky                | Jaime.Prilusky at weizmann.ac.il
 Weizmann Institute of Science    | fax: 972-8-9344113
 76100 Rehovot - Israel           | tel: 972-8-9344959

 info URL http://bioinformatics.weizmann.ac.il/jaime_prilusky.html
 OCA is at http://bioinformatics.weizmann.ac.il:8500
 Perl Users in Rehovot http://rehovot.pm.org/

More information about the Perl mailing list