#!/usr/bin/perl use Cwd; use File::Path; my $tree = $ARGV[0]; die "$tree does not exist or cannot be processed\n" unless ( -d $tree ); sub saw ($) { my($leaf) = @_; my $cwd = getcwd; chdir $leaf; printf "Traversing %s ...\n", getcwd; unlink(glob("*")); my @dirs = glob("*"); foreach $dir (@dirs) { saw($dir); } chdir $cwd; } saw($tree); rmtree($tree);