in reply to Push, Matching, and File::Find

Not only does if (//g) doesn't make sense conceptually (search again just to be sure?), it's buggy to do so*. You also seem to be forgetting that "." means something special in a regex pattern. Fix:

push(@file_list, $File::Find::name) if /\.(?:txt|jpg|gif)\z/i && lc($_) ne 'category.txt';

* — while (//g) and if (//gc) are useful, but that's another story.

Replies are listed 'Best First'.
Re^2: Push, Matching, and File::Find
by Marshall (Canon) on Feb 17, 2010 at 20:10 UTC
    Not trying to nitpick, but Op used plural for "category.txt files", so in case of housing_category.txt or job_category.txt, I guess we could have a slight change?:
    push(@file_list, $File::Find::name) if /\.(?:txt|jpg|gif)\z/i && !/category\.txt\z/i;
    Update: well I wasn't exactly sure whether there could be more than one category.txt type file out there. Anyway OP has some solid code (And I really do like the ikegami code). I guess since I'm commenting more, I would point out to the op that "return" looks like what was intended rather than "next" at top of sub.

      He said:

      I don't want to grab any files named "category.txt"

      The plural indicate similarly named files could exist in multiple directories.