use File::Path 'rmtree'; rmtree([ "$rootpath/$username" ]); #### rmtree([ map {"$rootpath/$_"} @user ]); #### rmtree([ map {"$rootpath/$_"} @user ], 1);