develooper Front page | perl.perl5.porters | Postings from February 2000

File::Find::finddepth and find2perl -depth isn't depthfirst as find-depth is (fwd)

David Dyck
February 27, 2000 14:48
File::Find::finddepth and find2perl -depth isn't depthfirst as find-depth is (fwd)
Message ID:

After attempting to submit this bug via perlbug
and not getting one of those confirmation reports
I'm sending this to perl5-porters

I've since seen that there was an earlier
report of the bug in File::Find::finddepth, but
that earlier bug didn't report that

find2perl -depth is also broken


---------- Forwarded message ----------
Date: Sat, 26 Feb 2000 17:37:26 -0800
From: David Dyck <>
Subject: File::Find::finddepth and find2perl -depth isn't depthfirst as find
    -depth is

This is a bug report for perl from,
generated with the help of perlbug 1.27 running under perl v5.5.660.

[Please enter your report here]

 # given a directory tree such as

$ mkdir -p f/g/h
$ touch  f/a f/g/b f/g/h/c

I want to get what find -depth reports 
$ find f -depth -type d -print

 #f2p is my wrapper around find2perl  (see below)
$ f2p f -depth -type d -print

# Here's a one liner that also just prints11
$ perl -wl -MFile::Find -e 'File::Find::finddepth( 
			sub { -d $_ && print $File::Find::name; }, "f")'

# I wanted all 3 directories to be printed

# instrumenting the wanted subroutine

perl -wl -MCwd -MFile::Find -e 'sub w{ print cwd,"\t\$_=$_\t$File::Find::name" }
                         File::Find::finddepth( \&w , "f")'

 #reports something like (if made the columns line up)
 # cwd           $_    $File::Find::name
/tmp/f  	$_=a    f/a
/tmp/f  	$_=.    f
/tmp/f/g        $_=b    f/g/b
/tmp/f/g        $_=g    f/g
/tmp/f/g/h      $_=c    f/g/h/c
/tmp/f/g/h      $_=h    f/g/h

Notice wanted does get called with each of the desired directories
but that
  1) they still aren't in the right order, and
  2) when calling wanted for directory f/g and f/g/h
     we are not chdir'ed to the directory that would allow
     testing of -d $_ (we are still in the $_ directory)

####### here is f2p

# f2p
# immediatly interpret the output find2perl

$FIND2PERL = '/usr/local/bin/find2perl';

pipe(READ, WRITE);
if (fork) {
    $script = <<'DIE';
$SIG{__DIE__} = sub { print STDERR $_[0]; exit 1; };

    while ($out = <READ>) {
	$script .= $out;
    print "eval $script;\n" if defined($debug);
    eval $script;
    # test and report if there was a syntax error or runtime error, or a
    # die statement was executed
    if (length($@)) {
	die $@;

} else {
    open(STDOUT, ">&WRITE");
    $| = 1;
    do $FIND2PERL;

[Please do not change anything below this line]

Site configuration information for perl v5.5.660:

Configured by dcd at Thu Feb 24 09:54:36 PST 2000.

Summary of my perl5 (revision 5.0 version 5 subversion 660) configuration:
    osname=linux, osvers=2.2.15pre10, archname=i686-linux
    uname='linux dd 2.2.15pre10 #2 thu feb 24 09:36:58 pst 2000 i686 '
    config_args='-Doptimize=-g -de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
    usesocks=undef useperlio=undef d_sfio=undef
    use64bits=undef uselargefiles=define usemultiplicity=undef
    cc='cc', optimize='-g', gccversion=
    cppflags='-DDEBUGGING -I/usr/local/include'
    ccflags ='-DDEBUGGING -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldbm -ldb -ldl -lm -lc
    libc=/lib/, 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.5.660:

Environment for perl v5.5.660:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About