Tony writes..
>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") };
You need to use the qr// operator:
my @files = @{ $search->find( qr/file.ext/i ) };
You should also escape the '.' assuming that's meant to be a literal
period:
my @files = @{ $search->find( qr/file\.ext/i ) };
It'll be quicker if you can anchor that pattern too, it would appear
that you can at least anchor at the end:
my @files = @{ $search->find( qr/file\.ext$/i ) };
But anchor at the beginning too if possible:
my @files = @{ $search->find( qr/^file\.ext$/i ) };
Your last section of code is not going to do what you want:
>while ($p = <@files>) {
> print "$p\n";
>}
The '<>'s are filehandle IO operators for reading from a file. You
probably just want to do this:
print join( "\n" => @files), "\n";
Or more verbosely:
for( @files ) {
print "$_\n";
}
--
Jason King
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs