in reply to unlink and -U

use File::Path qw( rmtree );

Please note the caveat about errors at the end its perldoc.

Update: File::Path exports mktree and rmtree by default, so use File::Path; will suffice.

After Compline,
Zaxo