diff --git a/ext/File-Find/lib/File/Find.pm b/ext/File-Find/lib/File/Find.pm index a41a6f5a5668..af84fbf116f3 100644 --- a/ext/File-Find/lib/File/Find.pm +++ b/ext/File-Find/lib/File/Find.pm @@ -1,21 +1,21 @@ package File::Find; + use 5.006; use strict; use warnings; use warnings::register; -our $VERSION = '1.43'; + use Exporter 'import'; require Cwd; +require File::Basename; +require File::Spec; +our $VERSION = '1.44'; our @EXPORT = qw(find finddepth); - -use strict; my $Is_VMS = $^O eq 'VMS'; my $Is_Win32 = $^O eq 'MSWin32'; -require File::Basename; -require File::Spec; # Should ideally be my() not our() but local() currently # refuses to operate on lexicals @@ -812,7 +812,7 @@ File::Find - Traverse a directory tree. =head1 DESCRIPTION These are functions for searching through directory trees doing work -on each file found similar to the Unix I command. File::Find +on each file found similar to the Unix L command. C exports two functions, C and C. They work similarly but have subtle differences. @@ -846,14 +846,14 @@ where C works from the top of the tree down. Despite the name of the C function, both C and C perform a depth-first search of the directory hierarchy. -=head2 %options +=head2 C<%options> The first argument to C is either a code reference to your C<&wanted> function, or a hash reference describing the operations to be performed for each file. The code reference is described in L below. -Here are the possible keys for the hash: +Here are the possible B for the hash: =over 4 @@ -879,7 +879,7 @@ function. It is called with a list of strings (actually file/directory names) and is expected to return a list of strings. The code can be used to sort the file/directory names alphabetically, numerically, or to filter out directory entries based on their name alone. When -I or I are in effect, C is a no-op. +C or C are in effect, C is a no-op. =item C @@ -887,7 +887,7 @@ The value should be a code reference. It is invoked just before leaving the currently processed directory. It is called in void context with no arguments. The name of the current directory is in C<$File::Find::dir>. This hook is handy for summarizing a directory, such as calculating its disk -usage. When I or I are in effect, C is a +usage. When C or C are in effect, C is a no-op. =item C @@ -897,15 +897,15 @@ links (followed) may contain files more than once and may even have cycles, a hash has to be built up with an entry for each file. This might be expensive both in space and time for a large directory tree. See L and L below. -If either I or I is in effect: +If either C or C is in effect: =over 4 =item * -It is guaranteed that an I has been called before the user's +It is guaranteed that an C has been called before the user's C function is called. This enables fast file checks involving C<_>. -Note that this guarantee no longer holds if I or I +Note that this guarantee no longer holds if C or C are not set. =item * @@ -918,23 +918,23 @@ a dangling symbolic link, then fullname will be set to C. =item C -This is similar to I except that it may report some files more +This is similar to C except that it may report some files more than once. It does detect cycles, however. Since only symbolic links have to be hashed, this is much cheaper both in space and time. If processing a file more than once (by the user's C function) -is worse than just taking time, the option I should be used. +is worse than just taking time, the option C should be used. =item C C, which is the default, causes all files which are neither directories nor symbolic links to be ignored if they are about to be processed a second time. If a directory or a symbolic link -are about to be processed a second time, File::Find dies. +are about to be processed a second time, C dies. -C causes File::Find to die if any file is about to be +C causes C to die if any file is about to be processed a second time. -C causes File::Find to ignore any duplicate files and +C causes C to ignore any duplicate files and directories but to proceed normally otherwise. =item C @@ -954,12 +954,13 @@ C<$_> will be the same as C<$File::Find::name>. =item C -If find is used in L (-T command line switch or -if EUID != UID or if EGID != GID), then internally directory names have to be -untainted before they can be C'd to. Therefore they are checked against -a regular expression I. Note that all names passed to the -user's C function are still tainted. If this option is used while not -in taint-mode, C is a no-op. +If find is used in L (C<-T> command line +switch or C or C), then internally +directory names have to be untainted before they can be C'd to. +Therefore they are checked against a regular expression C. +Note that all names passed to the user's C function are still +tainted. If this option is used while not in taint-mode, C +is a no-op. =item C @@ -969,7 +970,7 @@ Note that the parentheses are vital. =item C -If set, a directory which fails the I is skipped, +If set, a directory which fails the C is skipped, including all its sub-directories. The default is to C in such a case. =back @@ -979,10 +980,10 @@ including all its sub-directories. The default is to C in such a case. The C function does whatever verifications you want on each file and directory. Note that despite its name, the C function is a generic callback function, and does B tell -File::Find if a file is "wanted" or not. In fact, its return value +C if a file is "wanted" or not. In fact, its return value is ignored. -The wanted function takes no arguments but rather does its work +The C function takes no arguments but rather does its work through a collection of variables. =over 4 @@ -1004,7 +1005,7 @@ For example, when examining the file F you will have: $_ = foo.ext $File::Find::name = /some/path/foo.ext -You are chdir()'d to C<$File::Find::dir> when the function is called, +You are C'd to C<$File::Find::dir> when the function is called, unless C was specified. Note that when changing to directories is in effect, the root directory (F) is a somewhat special case inasmuch as the concatenation of C<$File::Find::dir>, @@ -1025,13 +1026,13 @@ When C or C are in effect, there is also a C<$File::Find::fullname>. The function may set C<$File::Find::prune> to prune the tree unless C was specified. Unless C or C is specified, for -compatibility reasons (find.pl, find2perl) there are in addition the -following globals available: C<$File::Find::topdir>, +compatibility reasons (C, L) there are +in addition the following globals available: C<$File::Find::topdir>, C<$File::Find::topdev>, C<$File::Find::topino>, C<$File::Find::topmode> and C<$File::Find::topnlink>. -This library is useful for the C tool (distributed as part of the -App-find2perl CPAN distribution), which when fed, +This library is useful for the C tool (distributed with the +L CPAN module), which when fed: find2perl / -name .nfs\* -mtime +7 \ -exec rm -f {} \; -o -fstype nfs -prune @@ -1086,9 +1087,9 @@ warnings. =over 4 -=item $dont_use_nlink +=item C<$dont_use_nlink> -You can set the variable C<$File::Find::dont_use_nlink> to 0 if you +You can set the variable C<$File::Find::dont_use_nlink> to C<0> if you are sure the filesystem you are scanning reflects the number of subdirectories in the parent directory's C count. @@ -1098,7 +1099,7 @@ if a filesystem doesn't populate C as expected. C<$File::Find::dont_use_nlink> now defaults to 1 on all platforms. -=item symlinks +=item Symlinks Be aware that the option to follow symbolic links can be dangerous. Depending on the structure of the directory tree (including symbolic @@ -1112,12 +1113,12 @@ in an unknown directory. =head1 HISTORY -File::Find used to produce incorrect results if called recursively. +C used to produce incorrect results if called recursively. During the development of perl 5.8 this bug was fixed. -The first fixed version of File::Find was 1.01. +The first fixed version of C was 1.01. =head1 SEE ALSO -L, find2perl. +L, L =cut diff --git a/ext/File-Find/t/find.t b/ext/File-Find/t/find.t index b6359d86ae89..64392a7eb80d 100644 --- a/ext/File-Find/t/find.t +++ b/ext/File-Find/t/find.t @@ -1,6 +1,6 @@ #!./perl -use strict; -use Cwd; + +use strict; # Affects the BEGIN block below it my $warn_msg; @@ -19,14 +19,13 @@ BEGIN { require File::Spec::Unix; @File::Spec::ISA = 'File::Spec::Unix'; } - require File::Find; - import File::Find; } -my $symlink_exists = eval { symlink("",""); 1 }; +my $symlink_exists = eval { symlink("", ""); 1 }; -use Test::More; use lib qw( ./t/lib ); + +use Test::More; use Testing qw( create_file_ok mkdir_ok @@ -35,8 +34,10 @@ use Testing qw( file_path _cleanup_start ); +use Cwd; use Errno (); use File::Temp qw(tempdir); +use File::Find; my %Expect_File = (); # what we expect for $_ my %Expect_Name = (); # what we expect for $File::Find::name/fullname diff --git a/ext/File-Find/t/taint.t b/ext/File-Find/t/taint.t index 2500b53819b4..17ec4fbf95b1 100644 --- a/ext/File-Find/t/taint.t +++ b/ext/File-Find/t/taint.t @@ -1,4 +1,5 @@ #!./perl -T + use strict; use lib qw( ./t/lib ); @@ -15,9 +16,8 @@ BEGIN { require File::Spec::Unix; @File::Spec::ISA = 'File::Spec::Unix'; } - require File::Find; - import File::Find; } + use Test::More; use File::Find; use File::Spec; diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat index f9da84633b80..2e6d8521e739 100644 --- a/t/porting/known_pod_issues.dat +++ b/t/porting/known_pod_issues.dat @@ -26,6 +26,7 @@ arybase atan2(3) atof(3) atoi(3) +App::find2perl Attribute::Constant autobox B::Debug @@ -136,6 +137,7 @@ File::MMagic File::ShareDir Filter::Encoding find(1) +find2perl flock(2) flock(3) fopen(3)