in reply to recurse directory script

++tamills and ++LordAvatar for their helpful tips. In particular, tamills's advice should produce a massive performance boost, because in your code, @files = (@files,$_); is essentially replacing the entire contents of @files with its prior contents plus a new element, EVERY TIME you add to it.

The time it takes to add a new element this way increases exponentially with the number of elements in the array, versus push which runs in approximately constant time.

Mustn't forget the, ahem, obligatory standard advice:

As a rule, put -w on your shebang line, and use strict;, and take the time to remove any errors or warnings reported.

#!/usr/bin/perl -w use strict; use File::Recurse; # ...

BTW, subroutine calls no longer require the & prefix character. Using them makes your code unnecessarily more difficult to read.

Update: fiddled with text.

dmm

You can give a man a fish and feed him for a day ...
Or, you can
teach him to fish and feed him for a lifetime

Replies are listed 'Best First'.
Re(2): recurse directory script
by FoxtrotUniform (Prior) on Jan 10, 2002 at 04:24 UTC

    BTW, subroutine calls no longer require the & prefix character. Using them makes your code unnecessarily more difficult to read.

    To the contrary, I find that prepending an & to subroutine calls makes my code easier to read. For one thing, it helps some syntax-hilighting editors hilight the subs, which is helpful. For another, it keeps with the theme of "everything with a sigil is a thingy that you can take a reference to", which I find helpful as well. The obvious caveat is that the & makes the current @_ visible to the subroutine; this hasn't bitten me in the ass yet, though.

    --
    :wq
      I prefer leaving off the & because I have to program in multiple languages, and like to preserve some visual uniformity.

      But if you include it, as long as you also use parens you will not re-use @_. So you can put your mind at ease on that detail...