Front page | perl.perl5.porters |
Postings from March 2000
Re: What's left to do? [LONG]
From:
scozens
Date:
March 22, 2000 19:17
Subject:
Re: What's left to do? [LONG]
Message ID:
492568AB.00119736.00@pwj-gw-n001.pwj.co.jp
I wrote:
> > # Make File::Find export C<$name> etc manually
> Or less:
> <rubbish snipped>
Hi, I'm Simon and I'm no good at Perl.
Let's try again, eh?
--- lib/File/Find.pm~ Thu Mar 23 11:18:18 2000
+++ lib/File/Find.pm Thu Mar 23 12:12:34 2000
@@ -55,7 +55,7 @@
=item *
-It is guarantueed that an I<lstat> has been called before the user's
+It is guaranteed that an I<lstat> has been called before the user's
I<wanted()> function is called. This enables fast file checks involving S<
_>.
=item *
@@ -119,7 +119,8 @@
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.
When <follow> or <follow_fast> are in effect there is also a
-C<$File::Find::fullname>.
+C<$File::Find::fullname>. These three variables may be imported to the
+caller's namespace.
The function may set C<$File::Find::prune> to prune the tree
unless C<bydepth> was specified.
Unless C<follow> or C<follow_fast> is specified, for compatibility
@@ -173,8 +174,8 @@
=cut
@ISA = qw(Exporter);
-@EXPORT = qw(find finddepth);
-
+@EXPORT = qw(find finddepth);
+@EXPORT_OK = qw($name $dir $fullname);
use strict;
my $Is_VMS;
@@ -271,6 +272,7 @@
}
our($dir, $name, $fullname, $prune);
+our($_dir);
sub _find_dir_symlnk($$$);
sub _find_dir($$$);
@@ -348,11 +350,11 @@
}
unless ($Is_Dir) {
- unless (($_,$dir) = File::Basename::fileparse($abs_dir)) {
- ($dir,$_) = ('.', $top_item);
+ unless (($_,$_dir) = File::Basename::fileparse($abs_dir)) {
+ ($_dir,$_) = ('.', $top_item);
}
- $abs_dir = $dir;
+ $abs_dir = $_dir;
if ($untaint) {
my $abs_dir_save = $abs_dir;
$abs_dir = $1 if $abs_dir =~ m|$untaint_pat|;
@@ -372,7 +374,7 @@
}
$name = $abs_dir;
-
+ $dir = $_dir;
&$wanted_callback;
}
@@ -399,7 +401,7 @@
my $dir_pref= ( $p_dir eq '/' ? '/' : "$p_dir/" );
my $dir_rel= '.'; # directory name relative to current directory
- local ($dir, $name, $prune, *DIR);
+ local ($_dir, $prune, *DIR);
unless ($no_chdir or $p_dir eq '.') {
my $udir = $p_dir;
@@ -424,8 +426,8 @@
while (defined $SE) {
unless ($bydepth) {
- $dir= $p_dir;
- $name= $dir_name;
+ $_dir= $p_dir;
+ $name = $dir_name;
$_= ($no_chdir ? $dir_name : $dir_rel );
# prune may happen here
$prune= 0;
@@ -455,7 +457,7 @@
$CdLvl++;
}
- $dir= $dir_name;
+ $_dir= $dir_name;
# Get the list of files in the current directory.
unless (opendir DIR, ($no_chdir ? $dir_name : '.')) {
@@ -472,6 +474,7 @@
$name = $dir_pref . $FN;
$_ = ($no_chdir ? $name : $FN);
+ $dir = $_dir;
&$wanted_callback;
}
@@ -496,12 +499,14 @@
else {
$name = $dir_pref . $FN;
$_= ($no_chdir ? $name : $FN);
+ $dir = $_dir;
&$wanted_callback;
}
}
else {
$name = $dir_pref . $FN;
$_= ($no_chdir ? $name : $FN);
+ $dir = $_dir;
&$wanted_callback;
}
}
@@ -523,7 +528,7 @@
if ( substr($name,-2) eq '/.' ) {
$name =~ s|/\.$||;
}
- $dir = $p_dir;
+ $_dir = $p_dir;
$_ = ($no_chdir ? $dir_name : $dir_rel );
if ( substr($_,-2) eq '/.' ) {
s|/\.$||;
@@ -558,7 +563,7 @@
my $dir_rel = '.'; # directory name relative to current
directory
my $byd_flag; # flag for pending stack entry if $bydepth
- local ($dir, $name, $fullname, $prune, *DIR);
+ local ($_dir, $prune, *DIR);
unless ($no_chdir or $p_dir eq '.') {
my $udir = $dir_loc;
@@ -584,7 +589,7 @@
while (defined $SE) {
unless ($bydepth) {
- $dir= $p_dir;
+ $dir= $_dir = $p_dir;
$name= $dir_name;
$_= ($no_chdir ? $dir_name : $dir_rel );
$fullname= $dir_loc;
@@ -614,7 +619,7 @@
}
}
- $dir = $dir_name;
+ $_dir = $dir_name;
# Get the list of files in the current directory.
unless (opendir DIR, ($no_chdir ? $dir_loc : '.')) {
@@ -667,7 +672,7 @@
if ( substr($name,-2) eq '/.' ) {
$name =~ s|/\.$||;
}
- $dir = $p_dir;
+ $_dir = $dir = $p_dir;
$_ = ($no_chdir ? $dir_name : $dir_rel);
if ( substr($_,-2) eq '/.' ) {
s|/\.$||;