in reply to Going it alone without File::Find

Beware - this code will erroneously chase symlinks, possibly causing infinite looping.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: RE: Going it alone without File::Find
by ZZamboni (Curate) on Sep 18, 2000 at 23:51 UTC
    The way to fix that would be to change the test to
    if (-d $file && ! -l $file)
    Also possibly change the syntax check to:
    die "Syntax: $0 <dir>" unless @ARGV == 1 && (-d $ARGV[0] && ! -l $ARGV[0]);

    --ZZamboni

RE: RE: Going it alone without File::Find
by bastard (Hermit) on Sep 19, 2000 at 17:34 UTC
    If you're going to say the code is bad, at least suggest a fix. Fortunately ZZamboni already has.
      My "fix" is the normal fix. Use File::Find, or suggest patches to it if it doesn't work the way you want. That way I don't have to review every line of your code in code-review to find out if you've broken it on some platforms, or introduced a security hole.

      The cost of revinventing the wheel is not just in development, but in every phase afterward: testing, documenting, production, and maintenance.

      -- Randal L. Schwartz, Perl hacker

        Thanks. Althought "the normal fix" may be apparent to you, it may not be as apparent to the many other people who read the site.