in reply to Why -M doesn't work?

But it did not work.
see How do I post a question effectively?

It could not get value for $result
$result will always have a value.

Just check the results of unlink() and opendir().