use File::Path 'rmtree'; rmtree([ "$rootpath/$username" ]);