1N/A# Usage:
1N/A# require "find.pl";
1N/A#
1N/A# &find('/foo','/bar');
1N/A#
1N/A# sub wanted { ... }
1N/A# where wanted does whatever you want. $dir contains the
1N/A# current directory name, and $_ the current filename within
1N/A# that directory. $name contains "$dir/$_". You are cd'ed
1N/A# to $dir when the function is called. The function may
1N/A# set $prune to prune the tree.
1N/A#
1N/A# This library is primarily for find2perl, which, when fed
1N/A#
1N/A# find2perl / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune
1N/A#
1N/A# spits out something like this
1N/A#
1N/A# sub wanted {
1N/A# /^\.nfs.*$/ &&
1N/A# (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
1N/A# int(-M _) > 7 &&
1N/A# unlink($_)
1N/A# ||
1N/A# ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
1N/A# $dev < 0 &&
1N/A# ($prune = 1);
1N/A# }
1N/A#
1N/A# Set the variable $dont_use_nlink if you're using AFS, since AFS cheats.
1N/A
1N/Ause File::Find ();
1N/A
1N/A*name = *File::Find::name;
1N/A*prune = *File::Find::prune;
1N/A*dir = *File::Find::dir;
1N/A*topdir = *File::Find::topdir;
1N/A*topdev = *File::Find::topdev;
1N/A*topino = *File::Find::topino;
1N/A*topmode = *File::Find::topmode;
1N/A*topnlink = *File::Find::topnlink;
1N/A
1N/Asub find {
1N/A &File::Find::find(\&wanted, @_);
1N/A}
1N/A
1N/A1;