Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using wildcards to open files in multiple directories

Status
Not open for further replies.

dbrazeau

Programmer
Sep 5, 2007
2
US
This is problay easy to do but I'm really new to perl and am having trouble opening files in several directories to make a list of them using wildcards. Here is what I have:

my @files = <../*/*.asm>;

So basicly I'm trying to search for all files endding with .asm that are in any subdirectory of the parent directory that I am currently in.
 
my @filenames = glob ("$directory/*.asm");

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
You need to drill down through sub directories. A glob will not do that automatically. File::Find might be better if you have to find all the .asm files in all the sub directories or code your own recursive subroutine to do it.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Oh.. I missed the several directory part. File::Find works really good for finding files in a tree. I used to roll my own but found that File::Find worked just as good.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top