qadwjoh has asked for the wisdom of the Perl Monks concerning the following question:

Is there a quick way in Perl to expand a list of directories (in @ARGV) into a list of all the files in the directories?

thanks,
A

Replies are listed 'Best First'.
Re: Directory contents
by broquaint (Abbot) on Jan 28, 2004 at 14:43 UTC
    Apply grep to the results of a map that uses a glob
    my @files = grep -f, map glob("$_/*"), @ARGV;
    HTH

    _________
    broquaint

      This is the idea I had, but I need to get it to also fill in any subdirectories it finds.

      A
        Then File::Find::Rule should do the trick e.g
        use File::Find::Rule; my @files = find(file => in => \@ARGV);
        HTH

        _________
        broquaint

Re: Directory contents
by ColtsFoot (Chaplain) on Jan 28, 2004 at 14:43 UTC
    File::Find will be what you are looking for
    use File::Find; find(\&wanted, @directories_to_search); sub wanted { ... }
    within the user defined sub wanted the following variables
    have special meaning
    $File::Find::dir is the current directory name $_ is the current filename within that directory