Tony:
An alternative approach (and one of my favorites in Perl) is to loop
through the files in a directory using:
while($filename = glob("$directory_one/*.extension $directory_two/*.txt")) {
# Do something with each $filename
}
Note that this matches on "traditional" shell wildcards, not regex, but is
very compact for most uses.
:Tariq
-----Original Message-----
From: Tony Bass [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 3:47 PM
To: [EMAIL PROTECTED]
Subject: File::List issue
Hi Everyone,
I am trying to use the File-List 0.3.1 module to get a directory listing of
a group of subdirectory's that contain a certain file. My problem is that I
don't know in advance the case of the file name. According to the doc's
File::List is supposed to take a regex argument for the find function. If I
run this piece of code it works for all the files in lower case and misses
any file in upper or mixed case (as expected).
#!c:\perl\bin\perl.exe
use File::List;
use File::Stat;
$dir = "c:/branches";
my $search = new File::List($dir);
my @files = @{ $search->find("file.ext") };
while ($p = <@files>) {
print "$p\n";
}
If I run this piece of code with the regex inserted to disregard the case
of the file name then I get no results or garbage results.
#!c:\perl\bin\perl.exe
use File::List;
use File::Stat;
$dir = "c:/branches";
my $search = new File::List($dir);
my @files = @{ $search->find(/file\.ext/i) };
while ($p = <@files>) {
print "$p\n";
}
I'm at a loss why this doesn't work. Anyone's input would be fine on why
this doesn't work or a better way of handling this problem. I wrote this
using File::Find and it works but takes way too long to run so I'm trying
to speed things up and File::List looks like a good way to go if I can get
it to work.
Thanks for the help,
Tony Bass
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs