Re: installed modules - faq question 3.4 What am I doing wrong?
- From: "John W. Krahn" <someone@xxxxxxxxxxx>
- Date: Mon, 16 May 2005 21:48:23 GMT
randp@xxxxxxx wrote:
use File::Find; my @files;
find sub { push @files, $File::Find::name if -f _ && /\.pm$/ }, @INC;
print join "\n", @files; -------------------------------------------------------
I think the above code will go through each directory listed in @INC and all its subdirectories and list all the files ending with ".pm". Why is it not doing this?
It is missing a whole bunch of files with ".pm". Am I doing something wrong?
Yes. The file test operators require a *valid* filehandle or a file name. This should work (untested):
find sub { push @files, $File::Find::name if -f && /\.pm$/ }, @INC;Or if you want to use more then one file test you could stat() or lstat() the file first:
find sub { stat; push @files, $File::Find::name if -f _ && -s _ && /\.pm$/ }, @INC;
John -- use Perl; program fulfillment .
- References:
- Prev by Date: Re: one liners or not
- Next by Date: No line editing within perl -d on RedHat
- Previous by thread: Re: installed modules - faq question 3.4 What am I doing wrong?
- Next by thread: How to get list of only directories
- Index(es):
Relevant Pages
|
|