in reply to To retrieve all files according to given path list

Asked quite often! Usual -good- answer: use File::Find or its relatives, File::Finder and File::Find::Rule.

perl -MFile::Find -le "find { no_chdir =>1, wanted => sub {print} }, @ +ARGV" C:\temp\

(should work under Windows with double quotes)

Incidentally @ARGV[0] is not strictly wrong, but in Perl 5 it is more customary to write $ARGV[0] instead.

Replies are listed 'Best First'.
Re^2: To retrieve all files according to given path list
by ikegami (Patriarch) on Dec 22, 2005 at 16:46 UTC

    Not quite. While it's a step in the right direction, your program dies on inputs (2) and (4), and returns the incorrect result for inputs (1) and (3). The OP's tool has a very odd usage syntax.

    devlele, have you considered using a switch (say -r) to decide whether to recurse or not. * normally means something else.

      Not quite. While it's a step in the right direction, your program dies on inputs (2) and (4), and returns the incorrect result for inputs (1) and (3). The OP's tool has a very odd usage syntax.
      Oh, that was just for illustrational purposes. Of course it would be up to him to decide to which depth level to recurse based upon actual input. Indeed the requirements are quite strange...


        Hi, I am a newbee to PERL, so can you please explain me what this tool is doing with what are the parameters ? I have actually tried this with c:\directoryname but it gives everything in that directory as well as in subdirectories. Is there any way to mention depth ? What I mean is, if I give c:\temp, it should only show me the directories and files in that directory and not under the its subdirectories.

        Please help.
        Thanks.