[sf-perl] Question about find2perl output

David Alban extasia at extasia.org
Thu Mar 16 16:15:00 PST 2006


I fed find2perl as follows:

  $ find2perl dir1 dir2 \( \( -name baddir1 -o -name baddir2 \
     -o -name baddir3 \) -type d -prune \) -o ! -type l -type f -print

This resulted in the following wanted() subroutine:

sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);

        ) &&
        ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
        -d _ &&
        ($File::Find::prune = 1)
    ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
    ! -l _ &&
    -f _ &&

I believe I understand the reason for the *second* instance of:

  $nlink || ( ... ) = lstat( ... )

If $nlink is true we know we've called lstat() and subsequent file
tests on "_"  will do The Right Thing(TM).  If $nlink is not true then
we haven't called lstat() and need to, to enable those file tests to

But it seems to me that in the *first* instance of that code snippet,
$nlink cannot ever be defined.  Am I missing something?  Not that it
will interfere with the desired functionality, but it seems to be
attempting to handle a case that isn't possible.

$ perl -v
This is perl, v5.8.0 built for sun4-solaris

$ uname -sr
SunOS 5.8

Live in a world of your own, but always welcome visitors.

More information about the SanFrancisco-pm mailing list