Following symbolic links (symlink/readlink) seems to me to be a hard problem. As in, if you don't watch out for all the minutae, you can get hammered.
So, I'm hoping someone already has solved that problem in a way accessible in perl.
I'm not looking to follow a symlink all the way to its end - the filesystem does a superb job of that already. I'm actually looking, in my case, for a particular actual symlink. I want to evaluate each symlink in the chain to determine whether I want to archive the target file, or the symlink itself. The criteria is simple, and thus less interesting (if a symlink matches a particular regular expression, I want to go to the next one in the chain, which could be the target file, otherwise I want to keep the symlink as is). However, trying to determine the symlink chain is difficult.
For example, using a simple chain of "S" (for "Symlink"), we could have:
foo -> S/foo S/foo -> S/foo # that's not a circular loop - there's an S in S S/S/foo -> ../lib/foo # keep the symlink because it doesn't start with + "S/"
Note that the filesystem I'm looking at is NFS-mounted, and read-only. And the directory structure I'm looking at is multiple-GB in size, so copying the whole thing becomes somewhat prohibitive in time (not so much in space). Especially following the symlinks during such a copy - we start jumping around from NFS server to NFS server.
Has anyone had to deal with this type of thing before? Are there modules out there that I missed which would help me go through this? Or is there a simplification that I'm just not seeing?
Thanks,
In reply to Following symlinks manually by Tanktalus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |