in reply to Help with node discovering and processing

A global counter may or may not be the way to go here, depending on the context in which you want to do this. If this is for a small script that you need for system administration or so, I'd say yes, use a global counter. If it's part of a larger project, use a cleaner solution with hooks/callback functions.

Take a look at Dominus's book Higher-Order Perl, too, walking a directory tree is one of the examples he uses in the first chapter (pp. 16-25). You could probably adapt what he's doing there. (And all the code snippets from his book are online, e.g. dir-walk-cb-def and so on.)

Other than that, to actually print the right numbers -- for a file it's straightforward; for a directory, "processed" equals "discovered" plus twice the number of files in that directory, plus one, so just print that (without increasing the counter, of course).

  • Comment on Re: Help with node discovering and processing