Commit | Line | Data |
---|---|---|
19aca649 AMS |
1 | # This library is deprecated and unmaintained. It is included for |
2 | # compatibility with Perl 4 scripts which may use it, but it will be | |
3 | # removed in a future version of Perl. Please use the File::Find module | |
4 | # instead. | |
5 | ||
6 | warn( "Please use the File::Find module instead of the deprecated" | |
7 | ." 'find.pl' library, which will be removed in the next major" | |
8 | ." release of perl" ); | |
9 | ||
6e21c824 LW |
10 | # Usage: |
11 | # require "find.pl"; | |
12 | # | |
13 | # &find('/foo','/bar'); | |
14 | # | |
15 | # sub wanted { ... } | |
16 | # where wanted does whatever you want. $dir contains the | |
17 | # current directory name, and $_ the current filename within | |
18 | # that directory. $name contains "$dir/$_". You are cd'ed | |
19 | # to $dir when the function is called. The function may | |
20 | # set $prune to prune the tree. | |
21 | # | |
19aca649 | 22 | # For example, |
6e21c824 | 23 | # |
19aca649 | 24 | # find / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune |
6e21c824 | 25 | # |
19aca649 | 26 | # corresponds to this |
6e21c824 LW |
27 | # |
28 | # sub wanted { | |
29 | # /^\.nfs.*$/ && | |
30 | # (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && | |
31 | # int(-M _) > 7 && | |
32 | # unlink($_) | |
33 | # || | |
34 | # ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) && | |
35 | # $dev < 0 && | |
36 | # ($prune = 1); | |
37 | # } | |
8990e307 LW |
38 | # |
39 | # Set the variable $dont_use_nlink if you're using AFS, since AFS cheats. | |
6e21c824 | 40 | |
dffa8cde | 41 | use File::Find (); |
6e21c824 | 42 | |
28312d68 RS |
43 | *name = *File::Find::name; |
44 | *prune = *File::Find::prune; | |
45 | *dir = *File::Find::dir; | |
46 | *topdir = *File::Find::topdir; | |
47 | *topdev = *File::Find::topdev; | |
48 | *topino = *File::Find::topino; | |
49 | *topmode = *File::Find::topmode; | |
50 | *topnlink = *File::Find::topnlink; | |
6e21c824 | 51 | |
dffa8cde | 52 | sub find { |
53 | &File::Find::find(\&wanted, @_); | |
6e21c824 | 54 | } |
dffa8cde | 55 | |
6e21c824 | 56 | 1; |