Very nice -- thank you, especially for handling relative links. I would just add a couple things, at first glance:
1. When deleting a stale symlink, the report about the deletion should include the stale target path.
2. It would be prudent to have a "-n" mode (no deletions, just report the paths and targets of stale links).
Sometimes, when you detect a stale link, it could be that you would rather just change the target (e.g. because the target was moved to a new disk volume), or it could be that the target is only "temporarily" inaccessible (e.g. because an nfs or samba server is down).
At the very least, provide enough logging so that it's easy to re-install a deleted link, in case deletion was the wrong thing to do. Better yet, simply report stale links and their targets, and give the user a chance to decide what the appropriate action should be (delete it, replace it, or make sure a given network disk volume comes back online).
Here's a script I wrote a while back to list all links (good and bad, including link chains: link.1 -> link.2 -> ... -> data.file). This was done before I knew about IO::All, so it uses unix "find" instead.
|