Hi madparu,
There is a little-known feature of File::Find from find2perl, the variable $File::Find::topdev, which holds the device number of the path currently being searched under, which you can compare with the device number of the current file (stat). Stick the following at the top of your wanted function, and your search will be limited to the filesystems of the paths which you tell File::Find::find to search under.
if ( $File::Find::topdev != (stat)[0] ) { $File::Find::prune = 1; return }
Update: Fixed stat vs. stat(_), apologies. My test code was doing a stat beforehand, so stat(_) worked fine. But if the piece of code above is the very first thing in your wanted function, you should stat $_ first, and only then use the special filehandle _. (The exception is when the follow option is set, then File::Find guarantees that an lstat has been called.)
And by the way, Use strict and warnings!
Hope this helps,
-- Hauke D
In reply to Re: Restrict file search within current filessystem using wanted subroutine
by haukex
in thread Restrict file search within current filessystem using wanted subroutine
by madparu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |