develooper Front page | perl.perl5.porters | Postings from March 2012

[perl #59750] File::Find behavior with files among @DIRS

Thread Previous
From:
James E Keenan via RT
Date:
March 25, 2012 12:21
Subject:
[perl #59750] File::Find behavior with files among @DIRS
Message ID:
rt-3.6.HEAD-4610-1332703254-676.59750-15-0@perl.org
On Thu Jan 12 17:24:08 2012, jkeenan wrote:
> On Thu Oct 09 08:39:46 2008, jflack@math.purdue.edu wrote:
> > 
> > The File::Find documentation never mentions any possibility of
> > including non-directories among @DIRS, but it seems to be
> > possible and the resulting behavior seems to be about what one
> > would hope for: preprocess and postprocess don't get called,
> > but wanted gets called with $File::Find::dir containing the
> > directory name and $_ containing the bare file name. This is
> > useful behavior (in the sense that if you wanted to write a
> > script that could accept a mix of file and directory arguments,
> > and File::Find /didn't/ do this, you'd have to write a fairly
> > fiddly wrapper around File::Find to accomplish the same thing).
> > 
> > So, unless there is a really strong objection to documenting the
> > current behavior (or on some platforms it actually won't work),
> > it would be nice to document it so people know it's available.
> > 
> > There is one small point where the behavior for a non-directory
> > in @DIRS differs from the normal behavior: $File::Find::dir
> > winds up with a terminal / where normally it does not. Nothing
> > the user can't work around with a File::Spec->canonpath, but
> > it might be nice to make it consistent.
> > 
> > 
> > 
> 
> If I am reading the File::Find source code correctly, there is some
> provision inside File::Find::_find_opt() for handling items passed to
> the caller-level subroutines which are not, in fact, directories:
> 
> #####
>     462 sub _find_opt {
>     463     my $wanted = shift;
> ...
>     577     unless ($Is_Dir) {
>     578         unless (($_,$dir) = File::Basename::fileparse($abs_dir)) {
>     579         ($dir,$_) = ('./', $top_item);
>     580         }
> ...
>     620 }
> #####
> 
> (I haven't studied the code between lines 577 and 620 well enough to say
> what's happening.)
> 
> But the OP is correct with regard to the silence of the documentation on
> the handling of non-directories.  Do we need changes in the documentation?
> 

Still need some feedback on this.

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=59750

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About