freelanceprogrammers.org Forum Index » Perl

list of files


View user's profile Post To page top
pkkjb Posted: Sat Mar 05, 2005 4:39 am


Joined: 05 Mar 2005

Posts: 3
list of files
Hi,

Please help me in making a list of files in different
dirs

eg if dir structure is like this and I want to
list files "file*.txt"

dir1/subdir1/subdir2/file1.txt
dir2/subdir1/subdir2/file2.txt
dir3/subdir1/subdir2/foo.txt

so my list should look like:

@files = qw(dir1/subdir1/subdir2/file1.txt
dir2/subdir1/subdir2/file2.txt)

Thanks
Pardeep
Reply with quote
Send private message
View user's profile Post To page top
merlynstoneh... Posted: Mon Mar 07, 2005 12:31 am


Joined: 21 May 2004

Posts: 44
list of files
>>>>> "pkkjb" == pkkjb <pkkjb@...> writes:

pkkjb> Please help me in making a list of files in different
pkkjb> dirs

pkkjb> eg if dir structure is like this and I want to
pkkjb> list files "file*.txt"

pkkjb> dir1/subdir1/subdir2/file1.txt
pkkjb> dir2/subdir1/subdir2/file2.txt
pkkjb> dir3/subdir1/subdir2/foo.txt

pkkjb> so my list should look like:

pkkjb> @files = qw(dir1/subdir1/subdir2/file1.txt
pkkjb> dir2/subdir1/subdir2/file2.txt)

use File::Finder;

my @files = File::Finder->name(`file*.txt`)->in(glob "dir*");

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Reply with quote
Send private message
View user's profile Post To page top
whinnim Posted: Mon Mar 07, 2005 3:16 am


Joined: 07 Mar 2005

Posts: 4
list of files
@files = <dir1/subdir1/subdir2/file*.txt>;

--- In perl_official@yahoogroups.com, pkkjb <pkkjb@y...> wrote:
>
> Hi,
>
> Please help me in making a list of files in different
> dirs
>
> eg if dir structure is like this and I want to
> list files "file*.txt"
>
> dir1/subdir1/subdir2/file1.txt
> dir2/subdir1/subdir2/file2.txt
> dir3/subdir1/subdir2/foo.txt
>
> so my list should look like:
>
> @files = qw(dir1/subdir1/subdir2/file1.txt
> dir2/subdir1/subdir2/file2.txt)
>
> Thanks
> Pardeep
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help