[perl #73560] [PATCH] Fix typos in Pod::Functions
[p5sagit/p5-mst-13.2.git] / lib / find.pl
CommitLineData
19aca649 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
6e21c824 6# Usage:
7# require "find.pl";
8#
9# &find('/foo','/bar');
10#
11# sub wanted { ... }
12# where wanted does whatever you want. $dir contains the
13# current directory name, and $_ the current filename within
14# that directory. $name contains "$dir/$_". You are cd'ed
15# to $dir when the function is called. The function may
16# set $prune to prune the tree.
17#
19aca649 18# For example,
6e21c824 19#
19aca649 20# find / -name .nfs\* -mtime +7 -exec rm -f {} \; -o -fstype nfs -prune
6e21c824 21#
19aca649 22# corresponds to this
6e21c824 23#
24# sub wanted {
25# /^\.nfs.*$/ &&
26# (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
27# int(-M _) > 7 &&
28# unlink($_)
29# ||
30# ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
31# $dev < 0 &&
32# ($prune = 1);
33# }
8990e307 34#
35# Set the variable $dont_use_nlink if you're using AFS, since AFS cheats.
6e21c824 36
dffa8cde 37use File::Find ();
6e21c824 38
28312d68 39*name = *File::Find::name;
40*prune = *File::Find::prune;
41*dir = *File::Find::dir;
42*topdir = *File::Find::topdir;
43*topdev = *File::Find::topdev;
44*topino = *File::Find::topino;
45*topmode = *File::Find::topmode;
46*topnlink = *File::Find::topnlink;
6e21c824 47
dffa8cde 48sub find {
49 &File::Find::find(\&wanted, @_);
6e21c824 50}
dffa8cde 51
6e21c824 521;