in reply to How to find matching file names and build a @AOA using File::Find

Usually when I see "opendir" (as in holli's response), I think "glob". Combined with a bit of map-magic, I get this:

my @AoA = map { (my $C = $_) =~ s/^Afj/Cfj/; [ $_, $C ] } glob 'Afj*';
This is based on the idea that both the Afj and Cfj files exist at the same time. You can tweak this a bit if that's not always true, but I'm guessing it is.

  • Comment on Re: How to find matching file names and build and @AOA using File::Find
  • Download Code

Replies are listed 'Best First'.
Re^2: How to find matching file names and build and @AOA using File::Find
by holli (Abbot) on Jul 06, 2005 at 13:07 UTC
    The problem with glob is that it returns the path for every file when you do something like glob ("path/to/somewhere"). You will have to strip that path if you want just the filename. That's why I used opendir here.


    holli, /regexed monk/