Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You can't do if (-d $file && -l _). That will always return false. True. You must reverse that: if (-l $file && -d _). Actually, that also always returns a false value. The cached lstat results did not follow the symbolic link and so doesn't know anything about what (if anything) it links to. If you want to check for "X is a (symbolic) link to a directory", then you can't avoid doing [l]stat twice (well, lstat once and stat once). There certainly are cases where you can "cheat" (or "be efficient"). Perhaps you were thinking of a very common case, for example:
That does work and does require that you do the -l part first. - tye In reply to Re^2: Detecting if a folder is a symbolic link (tricky)
by tye
|
|