-M is simpler.
The OP already asked this question here and here
In reply to Re^4: remove directory in perl by ikegami in thread remove directory in perl by Anonymous Monk