Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
From File::Find:
* dangling_symlinks Specifies what to do with symbolic links whose target doesn't exist. If true and a code reference, will be called with the symbolic link name and the directory it lives in as arguments. Otherwise, if true and warnings are on, a warning of the form "symbolic_link_name is a dangling symbolic link\n" will be issued. If false, the dangling symbolic link will be silently ignored. And stat/lstat (WP): The stat() and lstat() functions take a filename argument. If the file is a symbolic link, stat() returns attributes of the eventual target of the link, while lstat() returns attributes of the link itself. The fstat() function takes a file descriptor argument instead, and returns attributes of the file that it identifies.Note: Perl docs - stat, lstat It seems that the question that needs to be answered is, is dangling_symlinks invoked for conditions equivalent to -l && !-e on the file is true? From what I dug up while getting the above clarifications, it seems that there are great pains in both documents (and elsewhere) that differentiate the link itself and the file that is the target of the link. So make sure you're being consistent in what you're testing and that you are recreating the identical conditions for which dangling_symlinks is invoked. Another thought occurred to me that there could be some interactions in
Since you're testing $_ (I assume) when you might want (or not) to do something like sub{if (-l && !-e _){, which is going to avoid calling stat or lstat again. Not super solid on this nuance, but just saying to verify it's doing what you expect. Update (from From -X): If any of the file tests (or either the stat or lstat operator) is given the special filehandle consisting of a solitary underline, then the stat structure of the previous file test (or stat operator) is used, saving a system call. (This doesn't work with -t , and you need to remember that lstat and -l leave values in the stat structure for the symbolic link, not the real file.) (Also, if the stat buffer was filled by an lstat call, -T and -B will reset it with the results of stat _ ). So there you go...hopefully clear as mud now. :) In reply to Re^2: File::Find and remove invalid symlinks question
by perlfan
|
|