Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File::Find documentation #4867

Closed
p5pRT opened this issue Jan 17, 2002 · 6 comments
Closed

File::Find documentation #4867

p5pRT opened this issue Jan 17, 2002 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 17, 2002

Migrated from rt.perl.org#8274 (status was 'resolved')

Searchable as RT8274$

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2002

From Ulrich.Windl@rz.uni-regensburg.de

Created by Ulrich.Windl@rz.uni-regensburg.de

The documentation for File​::Find is not enough to be useful​:
The documentation does not describe arguments other than the first one,
and it's not obvious from the examples what the exact semantic is.
Similar is true for the callback routines​: What arguments are passed, what
value is to be returned?

Regards,
Ulrich

Perl Info

Flags:
    category=docs
    severity=medium

Site configuration information for perl v5.6.1:

Configured by root at Thu Sep 20 02:27:59 GMT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.9, archname=i586-linux
    uname='linux reiser 2.4.9 #1 smp wed sep 19 12:11:44 gmt 2001 i686 unknown '
    config_args='-ds -e -Dprefix=/usr -Di_db -Di_dbm -Di_ndbm -Di_gdbm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -pipe',
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.3 20010315 (SuSE)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.1:
    /usr/lib/perl5/5.6.1/i586-linux
    /usr/lib/perl5/5.6.1
    /usr/lib/perl5/site_perl/5.6.1/i586-linux
    /usr/lib/perl5/site_perl/5.6.1
    /usr/lib/perl5/site_perl
    .


Environment for perl v5.6.1:
    HOME=/home/wiu09524
    LANG=de_DE@euro
    LANGUAGE (unset)
    LC_COLLATE=POSIX
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/lib/java/bin:/usr/games/bin:/usr/games:/opt/gnome/bin:/opt/kde2/bin:.:/opt/gnome/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2002

From @schwern

On Thu, Jan 17, 2002 at 12​:32​:51PM +0100, Ulrich Windl wrote​:

The documentation for File​::Find is not enough to be useful​:
The documentation does not describe arguments other than the first one,
and it's not obvious from the examples what the exact semantic is.
Similar is true for the callback routines​: What arguments are passed, what
value is to be returned?

Funny, the callback takes no arguments. Never realized that. Sort of
surprised nobody's taken advantage of this.

However because of the way its called the caller's @​_ does leak
through. The patch below fixes that. The callback's @​_ will now be
empty.

This patch also​:

  Fixes the NAME to describe the module, not the functions therein.

  Makes the synopsis a little more descriptive.

  Adds a short overall description of the module.

  Adds short descriptions of each function, their arguments and
  attempts to explain what breadth/depth-first means in layman's
  terms.

  Makes it a little clearer that the Big List Of Hash Arguments is
  in fact describing the first arg to find/finddept.

  Adds an explicit section about the wanted function.

  Reorganizes the $File​::Find​::dir/name and $_ explaination to
  make it a little clearer as well as including a simple example.

  Explicitly document that wanted takes no args.

Ulrich, I've attached a copy of the new man page. Read it and see if
you like it better.

Inline Patch
--- lib/File/Find.pm	Thu Jan  3 11:08:23 2002
+++ lib/File/Find.pm	Thu Jan 17 16:31:37 2002
@@ -9,18 +9,16 @@
 
 =head1 NAME
 
-find - traverse a file tree
-
-finddepth - traverse a directory structure depth-first
+File::Find - Traverse a directory tree.
 
 =head1 SYNOPSIS
 
     use File::Find;
-    find(\&wanted, '/foo', '/bar');
+    find(\&wanted, @directories_to_seach);
     sub wanted { ... }
 
     use File::Find;
-    finddepth(\&wanted, '/foo', '/bar');
+    finddepth(\&wanted, @directories_to_search);
     sub wanted { ... }
 
     use File::Find;
@@ -28,8 +26,40 @@
 
 =head1 DESCRIPTION
 
+These are functions for searching through directory trees doing work
+on each file found similar to the Unix I<find> command.  File::Find
+exports two functions, C<find> and C<finddepth>.  They work similarly
+but have subtle differences.
+
+=over 4
+
+=item B<find>
+
+  find(\&wanted,  @directories);
+  find(\%options, @directories);
+
+find() does a breadth-first search over the given @directories in the
+order they are given.  In essense, it works from the top down.
+
+For each file or directory found the &wanted subroutine is called (see
+below for details).  Additionally, for each directory found it will go
+into that directory and continue the search.
+
+=item B<finddepth>
+
+  finddepth(\&wanted,  @directories);
+  finddepth(\%options, @directories);
+
+finddepth() works just like find() except it does a depth-first search.
+It works from the bottom of the directory tree up.
+
+=back
+
+=head2 %options
+
 The first argument to find() is either a hash reference describing the
-operations to be performed for each file, or a code reference.
+operations to be performed for each file, or a code reference.  The
+code reference is described in L<The wanted function> below.
 
 Here are the possible keys for the hash:
 
@@ -37,8 +67,8 @@
 
 =item C<wanted>
 
-The value should be a code reference.  This code reference is called
-I<the wanted() function> below.
+The value should be a code reference.  This code reference is
+described in L<The wanted function> below.
 
 =item C<bydepth>
 
@@ -145,21 +175,40 @@
 
 =back
 
-The wanted() function does whatever verifications you want.
-C<$File::Find::dir> contains the current directory name, and C<$_> the
-current filename within that directory.  C<$File::Find::name> contains
-the complete pathname to the file. You are chdir()'d to
-C<$File::Find::dir> when the function is called, unless C<no_chdir>
-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>, C<'/'> and  C<$_> is not literally
-equal to C<$File::Find::name>. The table below summarizes all variants:
+=head2 The wanted function
+
+The wanted() function does whatever verifications you want on each
+file and directory.  It takes no arguments but rather does its work
+through a collection of variables.
+
+=over 4
+
+=item C<$File::Find::dir> is the current directory name, 
+
+=item C<$_> is the current filename within that directory
+
+=item C<$File::Find::name> is the complete pathname to the file. 
+
+=back
+
+For example, when examining the file /some/path/foo.ext you will have:
+
+    $File::Find::dir  = /some/path/
+    $_                = foo.ext
+    $File::Find::name = /some/path/foo.ext
+
+You are chdir()'d toC<$File::Find::dir> when the function is called,
+unless C<no_chdir> 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>,
+C<'/'> and C<$_> is not literally equal to C<$File::Find::name>. The
+table below summarizes all variants:
 
               $File::Find::name  $File::Find::dir  $_
  default      /                  /                 .
  no_chdir=>0  /etc               /                 etc
               /etc/x             /etc              x
-     
+
  no_chdir=>1  /                  /                 /
               /etc               /                 /etc
               /etc/x             /etc              /etc/x
@@ -650,7 +699,7 @@
 
 	    $name = $abs_dir . $_; # $File::Find::name
 
-	    { &$wanted_callback }; # protect against wild "next"
+	    { $wanted_callback->() }; # protect against wild "next"
 
 	}
 
@@ -731,7 +780,7 @@
 	    $_= ($no_chdir ? $dir_name : $dir_rel ); # $_
 	    # prune may happen here
 	    $prune= 0;
-	    { &$wanted_callback };	# protect against wild "next"
+	    { $wanted_callback->() };	# protect against wild "next"
 	    next if $prune;
 	}
 
@@ -779,7 +828,7 @@
 	}
 	@filenames = readdir DIR;
 	closedir(DIR);
-	@filenames = &$pre_process(@filenames) if $pre_process;
+	@filenames = $pre_process->(@filenames) if $pre_process;
 	push @Stack,[$CdLvl,$dir_name,"",-2]   if $post_process;
 
 	# default: use whatever was specifid
@@ -795,7 +844,7 @@
 		
 		$name = $dir_pref . $FN; # $File::Find::name
 		$_ = ($no_chdir ? $name : $FN); # $_
-		{ &$wanted_callback }; # protect against wild "next"
+		{ $wanted_callback->() }; # protect against wild "next"
 	    }
 
 	}
@@ -819,13 +868,13 @@
 		    else {
 			$name = $dir_pref . $FN; # $File::Find::name
 			$_= ($no_chdir ? $name : $FN); # $_
-			{ &$wanted_callback }; # protect against wild "next"
+			{ $wanted_callback->() }; # protect against wild "next"
 		    }
 		}
 		else {
 		    $name = $dir_pref . $FN; # $File::Find::name
 		    $_= ($no_chdir ? $name : $FN); # $_
-		    { &$wanted_callback }; # protect against wild "next"
+		    { $wanted_callback->() }; # protect against wild "next"
 		}
 	    }
 	}
@@ -860,7 +909,7 @@
 	    if ( $nlink == -2 ) {
 		$name = $dir = $p_dir; # $File::Find::name / dir
                 $_ = $File::Find::current_dir;
-		&$post_process;		# End-of-directory processing
+		$post_process->();		# End-of-directory processing
 	    }
 	    elsif ( $nlink < 0 ) {  # must be finddepth, report dirname now
 		$name = $dir_name;
@@ -882,7 +931,7 @@
 			substr($_, length($_) == 2 ? -1 : -2) = '';
 		    }
 		}
-		{ &$wanted_callback }; # protect against wild "next"
+		{ $wanted_callback->() }; # protect against wild "next"
 	     }
 	     else {
 		push @Stack,[$CdLvl,$p_dir,$dir_rel,-1]  if  $bydepth;
@@ -971,7 +1020,7 @@
 	    # prune may happen here
 	    $prune= 0;
 	    lstat($_); # make sure  file tests with '_' work
-	    { &$wanted_callback }; # protect against wild "next"
+	    { $wanted_callback->() }; # protect against wild "next"
 	    next if $prune;
 	}
 
@@ -1026,7 +1075,7 @@
 		$fullname = $new_loc; # $File::Find::fullname 
 		$name = $dir_pref . $FN; # $File::Find::name
 		$_ = ($no_chdir ? $name : $FN); # $_
-		{ &$wanted_callback }; # protect against wild "next"
+		{ $wanted_callback->() }; # protect against wild "next"
 	    }
 	}
 
@@ -1075,7 +1124,7 @@
 		}
 
 		lstat($_); # make sure file tests with '_' work
-		{ &$wanted_callback }; # protect against wild "next"
+		{ $wanted_callback->() }; # protect against wild "next"
 	    }
 	    else {
 		push @Stack,[$dir_loc, $updir_loc, $p_dir, $dir_rel,-1]  if  $bydepth;


-- 

Michael G. Schwern <schwern@​pobox.com> http​://www.pobox.com/~schwern/
Perl Quality Assurance <perl-qa@​perl.org> Kwalitee Is Job One
WOOHOO! I'm going to Disneyland!
  http​://www.goats.com/archive/980805.html

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2002

From @schwern

NAME
  File​::Find - Traverse a directory tree.

SYNOPSIS
  use File​::Find;
  find(\&wanted, @​directories_to_seach);
  sub wanted { ... }

  use File​::Find;
  finddepth(\&wanted, @​directories_to_search);
  sub wanted { ... }

  use File​::Find;
  find({ wanted => \&process, follow => 1 }, '.');

DESCRIPTION
  These are functions for searching through directory trees doing work on
  each file found similar to the Unix *find* command. File​::Find exports
  two functions, "find" and "finddepth". They work similarly but have
  subtle differences.

  find
  find(\&wanted, @​directories);
  find(\%options, @​directories);

  find() does a breadth-first search over the given @​directories in
  the order they are given. In essense, it works from the top down.

  For each file or directory found the &wanted subroutine is called
  (see below for details). Additionally, for each directory found it
  will go into that directory and continue the search.

  finddepth
  finddepth(\&wanted, @​directories);
  finddepth(\%options, @​directories);

  finddepth() works just like find() except it does a depth-first
  search. It works from the bottom of the directory tree up.

  %options
  The first argument to find() is either a hash reference describing the
  operations to be performed for each file, or a code reference. The code
  reference is described in "The wanted function" below.

  Here are the possible keys for the hash​:

  "wanted"
  The value should be a code reference. This code reference is
  described in "The wanted function" below.

  "bydepth"
  Reports the name of a directory only AFTER all its entries have been
  reported. Entry point finddepth() is a shortcut for specifying "{
  bydepth => 1 }" in the first argument of find().

  "preprocess"
  The value should be a code reference. This code reference is used to
  preprocess the current directory. The name of currently processed
  directory is in $File​::Find​::dir. Your preprocessing function is
  called after readdir() but before the loop that calls the wanted()
  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 *follow* or *follow_fast* are in effect, "preprocess" is
  a no-op.

  "postprocess"
  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
  $File​::Find​::dir. This hook is handy for summarizing a directory,
  such as calculating its disk usage. When *follow* or *follow_fast*
  are in effect, "postprocess" is a no-op.

  "follow"
  Causes symbolic links to be followed. Since directory trees with
  symbolic 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 *follow_fast* and *follow_skip* below. If either
  *follow* or *follow_fast* is in effect​:

  * It is guaranteed that an *lstat* has been called before the
  user's *wanted()* function is called. This enables fast file
  checks involving _.

  * There is a variable $File​::Find​::fullname which holds the
  absolute pathname of the file with all symbolic links resolved

  "follow_fast"
  This is similar to *follow* 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 *wanted()* function)
  is worse than just taking time, the option *follow* should be used.

  "follow_skip"
  "follow_skip==1", 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.
  "follow_skip==0" causes File​::Find to die if any file is about to be
  processed a second time. "follow_skip==2" causes File​::Find to ignore
  any duplicate files and directories but to proceed normally
  otherwise.

  "dangling_symlinks"
  If true and a code reference, will be called with the symbolic link
  name and the directory it lives in as arguments. Otherwise, if true
  and warnings are on, warning "symbolic_link_name is a dangling
  symbolic link\n" will be issued. If false, the dangling symbolic link
  will be silently ignored.

  "no_chdir"
  Does not "chdir()" to each directory as it recurses. The wanted()
  function will need to be aware of this, of course. In this case, $_
  will be the same as $File​::Find​::name.

  "untaint"
  If find is used in taint-mode (-T command line switch or if EUID !=
  UID or if EGID != GID) then internally directory names have to be
  untainted before they can be chdir'ed to. Therefore they are checked
  against a regular expression *untaint_pattern*. Note that all names
  passed to the user's *wanted()* function are still tainted. If this
  option is used while not in taint-mode, "untaint" is a no-op.

  "untaint_pattern"
  See above. This should be set using the "qr" quoting operator. The
  default is set to "qr|^([-+@​\w./]+)$|". Note that the parentheses are
  vital.

  "untaint_skip"
  If set, a directory which fails the *untaint_pattern* is skipped,
  including all its sub-directories. The default is to 'die' in such a
  case.

  The wanted function
  The wanted() function does whatever verifications you want on each file
  and directory. It takes no arguments but rather does its work through a
  collection of variables.

  $File​::Find​::dir is the current directory name,
  $_ is the current filename within that directory
  $File​::Find​::name is the complete pathname to the file.

  For example, when examining the file /some/path/foo.ext you will have​:

  $File​::Find​::dir = /some/path/
  $_ = foo.ext
  $File​::Find​::name = /some/path/foo.ext

  You are chdir()'d to$File​::Find​::dir when the function is called, unless
  "no_chdir" was specified. Note that when changing to directories is in
  effect the root directory (/) is a somewhat special case inasmuch as the
  concatenation of $File​::Find​::dir, '/' and $_ is not literally equal to
  $File​::Find​::name. The table below summarizes all variants​:

  $File​::Find​::name $File​::Find​::dir $_
  default / / .
  no_chdir=>0 /etc / etc
  /etc/x /etc x

  no_chdir=>1 / / /
  /etc / /etc
  /etc/x /etc /etc/x

  When <follow> or <follow_fast> are in effect, there is also a
  $File​::Find​::fullname. The function may set $File​::Find​::prune to prune
  the tree unless "bydepth" was specified. Unless "follow" or
  "follow_fast" is specified, for compatibility reasons (find.pl,
  find2perl) there are in addition the following globals available​:
  $File​::Find​::topdir, $File​::Find​::topdev, $File​::Find​::topino,
  $File​::Find​::topmode and $File​::Find​::topnlink.

  This library is useful for the "find2perl" tool, which when fed,

  find2perl / -name .nfs\* -mtime +7 \
  -exec rm -f {} \; -o -fstype nfs -prune

  produces something like​:

  sub wanted {
  /^\.nfs.*\z/s &&
  (($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_)) &&
  int(-M _) > 7 &&
  unlink($_)
  ||
  ($nlink || (($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_))) &&
  $dev < 0 &&
  ($File​::Find​::prune = 1);
  }

  Notice the "_" in the above "int(-M _)"​: the "_" is a magical filehandle
  that caches the information from the preceding stat(), lstat(), or
  filetest.

  Here's another interesting wanted function. It will find all symbolic
  links that don't resolve​:

  sub wanted {
  -l && !-e && print "bogus link​: $File​::Find​::name\n";
  }

  See also the script "pfind" on CPAN for a nice application of this
  module.

WARNINGS
  If you run your program with the "-w" switch, or if you use the
  "warnings" pragma, File​::Find will report warnings for several weird
  situations. You can disable these warnings by putting the statement

  no warnings 'File​::Find';

  in the appropriate scope. See perllexwarn for more info about lexical
  warnings.

CAVEAT
  $dont_use_nlink
  You can set the variable $File​::Find​::dont_use_nlink to 1, if you want
  to force File​::Find to always stat directories. This was used for file
  systems that do not have an "nlink" count matching the number of
  sub-directories. Examples are ISO-9660 (CD-ROM), AFS, HPFS (OS/2 file
  system), FAT (DOS file system) and a couple of others.

  You shouldn't need to set this variable, since File​::Find should now
  detect such file systems on-the-fly and switch itself to using stat.
  This works even for parts of your file system, like a mounted CD-ROM.

  If you do set $File​::Find​::dont_use_nlink to 1, you will notice
  slow-downs.

  symlinks
  Be aware that the option to follow symbolic links can be dangerous.
  Depending on the structure of the directory tree (including symbolic
  links to directories) you might traverse a given (physical) directory
  more than once (only if "follow_fast" is in effect). Furthermore,
  deleting or changing files in a symbolically linked directory might
  cause very unpleasant surprises, since you delete or change files in
  an unknown directory.

NOTES
  * Mac OS (Classic) users should note a few differences​:

  * The path separator is '​:', not '/', and the current directory is
  denoted as '​:', not '.'. You should be careful about specifying
  relative pathnames. While a full path always begins with a
  volume name, a relative pathname should always begin with a '​:'.
  If specifying a volume name only, a trailing '​:' is required.

  * $File​::Find​::dir is guaranteed to end with a '​:'. If $_ contains
  the name of a directory, that name may or may not end with a
  '​:'. Likewise, $File​::Find​::name, which contains the complete
  pathname to that directory, and $File​::Find​::fullname, which
  holds the absolute pathname of that directory with all symbolic
  links resolved, may or may not end with a '​:'.

  * The default "untaint_pattern" (see above) on Mac OS is set to
  "qr|^(.+)$|". Note that the parentheses are vital.

  * The invisible system file "Icon\015" is ignored. While this file
  may appear in every directory, there are some more invisible
  system files on every volume, which are all located at the
  volume root level (i.e. "MacintoshHD​:"). These system files are
  not excluded automatically. Your filter may use the following
  code to recognize invisible files or directories (requires
  Mac​::Files)​:

  use Mac​::Files;

  # invisible() -- returns 1 if file/directory is invisible,
  # 0 if it's visible or undef if an error occurred

  sub invisible($) {
  my $file = shift;
  my ($fileCat, $fileInfo);
  my $invisible_flag = 1 << 14;

  if ( $fileCat = FSpGetCatInfo($file) ) {
  if ($fileInfo = $fileCat->ioFlFndrInfo() ) {
  return (($fileInfo->fdFlags & $invisible_flag) && 1);
  }
  }
  return undef;
  }

  Generally, invisible files are system files, unless an odd
  application decides to use invisible files for its own purposes.
  To distinguish such files from system files, you have to look at
  the type and creator file attributes. The MacPerl built-in
  functions "GetFileInfo(FILE)" and "SetFileInfo(CREATOR, TYPE,
  FILES)" offer access to these attributes (see MacPerl.pm for
  details).

  Files that appear on the desktop actually reside in an (hidden)
  directory named "Desktop Folder" on the particular disk volume.
  Note that, although all desktop files appear to be on the same
  "virtual" desktop, each disk volume actually maintains its own
  "Desktop Folder" directory.

HISTORY
  File​::Find 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.

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2002

From @jhi

On Thu, Jan 17, 2002 at 04​:35​:47PM -0500, Michael G Schwern wrote​:

On Thu, Jan 17, 2002 at 12​:32​:51PM +0100, Ulrich Windl wrote​:

The documentation for File​::Find is not enough to be useful​:
The documentation does not describe arguments other than the first one,
and it's not obvious from the examples what the exact semantic is.
Similar is true for the callback routines​: What arguments are passed, what
value is to be returned?

Funny, the callback takes no arguments. Never realized that. Sort of
surprised nobody's taken advantage of this.

However because of the way its called the caller's @​_ does leak
through. The patch below fixes that. The callback's @​_ will now be
empty.

Thanks, applied.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2002

From @schwern

On Fri, Jan 18, 2002 at 08​:47​:32AM +0100, Ulrich Windl wrote​:

Michael,

I like the new manual page much better! However what's missing is​:
Is the wanted routine allowed to modify any of the "global" variables
that describe the current state of the tree traversal? If not, say so;
if yes, say which may be modified.

Ok, here it is.

Hmm, what could we make changing the variables do... we could tie them
and if you change the variable the associated file/dir will be
renamed! If you set it to undef it'll delete the file.

Or not. ;)

--- lib/File/Find.pm 2002/01/18 08​:06​:39 1.1
+++ lib/File/Find.pm 2002/01/18 08​:07​:07
@​@​ -183,13 +183,15 @​@​

=over 4

-=item C<$File​::Find​::dir> is the current directory name,
+=item C<$File​::Find​::dir> is the current directory name,

=item C<$_> is the current filename within that directory

-=item C<$File​::Find​::name> is the complete pathname to the file.
+=item C<$File​::Find​::name> is the complete pathname to the file.

=back
+
+Don't modify these variables.

For example, when examining the file /some/path/foo.ext you will have​:

--

Michael G. Schwern <schwern@​pobox.com> http​://www.pobox.com/~schwern/
Perl Quality Assurance <perl-qa@​perl.org> Kwalitee Is Job One
Obscenity is the last resort of the illiterate, Mother Fucker
  -- KAL

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2002

From [Unknown Contact. See original ticket]

On Thu, Jan 17, 2002 at 04​:35​:47PM -0500, Michael G Schwern wrote​:

Ulrich, I've attached a copy of the new man page. Read it and see if
you like it better.

I think this man page would be much more useful with a few more
examples. And possibly an 'easy' example earliers. The first example
given is quite intimidating.

If no-one comes up with anything, I'll have a look when I get back from
the Perl Whirl.

tony
--


Tony Bowden | tony@​tmtm.com | http​://www.tmtm.com/
  si me asesinan, resucitare en el alma del pueblo


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant