http://www.perlmonks.org?node_id=101307


in reply to Re: Re: File::Find bummers on an NFS volume.
in thread File::Find bummers on an NFS volume.

Don't just patch the POD. Patch the module! See RE: RE: File::Find. I'm not aware of a single modern system where having that on by default makes sense. Any system that supports CD-ROM drives should not have it turned on by default, for example. And it is all Win32 file systems, not just remote samba file systems that are incompatable with it. Most Unix systems support quite a few file system types that don't follow the "nlink" rule.

Of course, I and others have tried to patch this multiple times and none of the patches have ever been accepted. I think File::Find just has too much bad history behind it and what we really need is a replacement that

File::Recurse might be such a replacement but I'm worried that it isn't being maintained. So I'd rather people put work into something like that (and getting it bundled with the base Perl distribution) than banging their head against the brick wall that is the "nlink" trick in File::Find.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: File::Find bummers on an NFS volume.
by bikeNomad (Priest) on Aug 01, 2001 at 01:56 UTC
    How would it transfer to the user's code if it didn't callback? File::Recurse only populates a hash with filenames keyed by directory; it doesn't call anything.

    I think a callback is natural; however, there might also be an interface that populates hashes or arrays.

      Perhaps I was thinking of some module other than File::Recurse. Darn.

      How would it transfer to the user's code if it didn't callback?
      Iterators, of course.

      For any readers who aren't familiar with the concept: I find bikeNomad's question similar to "But how can we let the user run a section of code once for each line of an input file without requiring them to write callbacks?"

      Perl is full of iterators. File globbing, line reading, regex matching, and iterating over an array or other list are all common examples of things that are often done in Perl using interators. And this is because callbacks suck. (:

              - tye (but my friends call me "Tye")
        I don't see much of a difference between these idioms in Perl:
        # iterator sort { $a cmp $b } @array; # callback sub myFunc { $a cmp $b } sort myFunc @array;
        It's interesting you mention this. My Algorithm-Diff module uses callbacks, in part because the original module by Dominus did, and in part because that seemed like a good thing to do. There are, in fact, about 6 callbacks that could be specified. A couple are there to handle comparison and hashing of user-defined data types (since everything in Perl isn't an object). The rest of them are there so that user code can be run while traversing the input sequences. This turns out to be pretty useful.

        I'm re-doing this module in Ruby, and am re-considering the interface in the process.

        I ended up with the various diff functions in a class; if someone wants to override comparison behavior, they just re-define a method or two (Ruby lets you do this on a per-object basis; for the equivalent in Perl you can use my Class::Prototyped module). I wonder if that would be a better interface in Perl. You'd just override the methods you cared about:

        package MyDiff; @MyDiff::ISA = 'Algorithm::Diff'; sub keyGen { ... } sub compare { ... } sub match { ... } sub skip_a { ... } package main; my $diff = MyDiff->new(); $diff->traverse_sequences(\@a1, \@a2);

        Do you think that this is a better idiom than explicit callbacks?

Re: (tye)Re: File::Find bummers on an NFS volume.
by petdance (Parson) on Aug 01, 2001 at 01:22 UTC
    Don't just patch the POD. Patch the module!

    I probably agree that the default should be changed, but what I'm hearing is that it's been suggested and rejected. Given that nobody's going to change it, then I think that we should at least patch the POD so that future users of the module don't go through the same thing I did.

    The two options are not mutually exclusive. We can do BOTH.

    So my question still stands: What do I need to do to get the POD patched?

    xoxo,
    Andy
    --
    <megaphone> Throw down the gun and tiara and come out of the float! </megaphone>

      You submit patches with "perlbug". To be extra nice to the "porters", grab "bleedperl", make your update to that, then use "diff -C3" or "diff -U3" to create a patch and use the "perlbug" command to send it in.

      I'd love to see the POD update: "$dont_use_nlink should be set to default to 1 for all modern systems if you actually want File::Find to _work_ on all of your file systems (such as CD-ROM file systems). We'd just fix this bug but politics prevent it." (:

              - tye (but my friends call me "Tye")