in reply to File Find question

What you're trying to write there would correctly look like
#!/usr/local/bin/perl -w use strict; use File::Find; my $dirs = '/web/directory'; find(\&search, $dirs); sub search { print "$File::Find::name\n" if -d and /\A(?:AA|BB|CC)\z/; }
But why not just say the following?
#!/usr/local/bin/perl -w use strict; use File::Find; my $dirs = '/web/directory'; find(\&search, map "$dirs/$_", qw(AA BB CC)); sub search { # ... }
If you don't want any other dirs, why descend anywhere else?

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: File Find question
by Anonymous Monk on Nov 06, 2002 at 20:14 UTC
    thanks but I want the 3 directories and all the subdirectories and all the files under the 3 directories. Sorry I wasnt clear on that earlier. Can you advise how I would do that? Basically what I have currently but just doing the deep searches on files and directories with the 3 I listed.
      As far as I can tell the second snippet I posted will do what you want. If it doesn't, you haven't been clear enough.

      Makeshifts last the longest.

        Thanks I got it to work this way (and your map function answer works great also) but was hoping I could get it more condensed without using the map function. Just so I can understand it better since I am a beginner. Anyway to combine what I have here to work??
        #!/usr/local/bin/perl use strict; use File::Find; my $dirs = '/web/directory/AA'; my $dirs2 = '/web/directory/BB'; my $dirs3 = '/web/directory/CC' find(\&search, $dirs); find(\&search, $dirs2); find(\&search, $dirs3); sub search { print "$File::Find::name\n"; }