#!/usr/local/bin/perl -w use strict; use File::Find; my $dir = "/foo/bar"; # the directory you want removed sub remove { if (-d $_) { rmdir $File::Find::name; } else { unlink $File::Find::name; } } finddepth(\&remove, $dir); rmdir $dir;