in reply to Processing directories (again) with File::Find

I think you'll have to loop
use File::Find; my $limit= 4; # Whatever you prefer for ($name = 1; $name <= $limit; ++$name) { find(\&Wanted, $dir); }
This will go through all subdirectories and search 1.* first, then 2.*, then 3.* and at last 4.* or whatever you defined as a $limit.
sub Wanted { # /$name\.*/; # NO! You want $name at the beginning!
Update... Made a mistake         /^$name\./;
if (/^$name\./) { # if undef {
If what is undef?
What you pretend to do is, increment $name if $name is not in the directory. What you really would do if it worked is: increment $name if the FIRST NAME in the directory doesn't match. It won't match since the first name would (in *NIX) almost always be "."
# $name++; # return; # } else { open(FILE, $_); my @lines = <FILE>; # some processing missing here? } }

Replies are listed 'Best First'.
Re: Re: Processing directories (again) with File::Find
by billie_t (Sexton) on Jun 16, 2003 at 07:22 UTC
    Thanks for the suggestions, Skeeve. Unfortunately, everything is still seeming to be processed multiple times in no particular order.

    One VERY IMPORTANT thing I forgot to mention - and which is probably causing problems as well as my bad syntax etc -is the fact that the directories have names that also consist of numbers. I thought that specifying /^$name\.*/ would limit it to filenames like 1.xx? (assuming a file structure of something like /03/4/1.32). I'm doing this on Windows, by the way

    And yes, there is some processing after the file is read into an array (squirting it into a spreadsheet), but this part is the problematic bit...
      My mistake. It should have been:
      if (/^$name\./) { open....
        That's great Skeeve - it opens the files nicely, and I can even see how it works. (I should have spotted that if myself - I'm still getting the hang of these implied variables)