[LA.pm] Command line loops?

Jeremy Leader jleader at alumni.caltech.edu
Tue May 20 23:43:25 CDT 2003


There's more than one way to do it...

On Unix-like systems, try the "find" command, which
recursively searches a directory tree for files
matching specifications you give it (which can
include size, type, timestamp, name, etc.) and
executes commands you specify on them (including
listing their names).  That's what I usually use.

You could also write Perl code using the opendir and
readdir to read directories yourself.  Or you could
use the DirHandle package, which is an OO wrapper for
opendir/readdir/etc.

Or you could use the File::Find package, which is a
Perl version of the find command.  You pass it a
list of starting directories, specify how it should
search (breadth first or depth first), and lots of
options about what to search for, including a
subroutine to call for each file it finds.

Hope one of those is what you're looking for.

Jeremy Leader

At 08:39 PM 5/20/03 , Ron Smith wrote:
>Is there a Perl way to do a command line loop that reaches down 
>recursively into directories and 'greps' out certain files of the same type?
>
>TIA
>Ron
>  
>
>
>Do you Yahoo!?
><http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com>The New Yahoo! Search - Faster. Easier. Bingo. 





More information about the Losangeles-pm mailing list