Krishna P Krishna P - 4 months ago 12
Perl Question

How to resolve conflict with File::Find::Rule and File::Find

To elaborate,

I am using

File::Find::Rule
to get the path of a specific file which exists in multiple sub directories and sometimes in sub directories directory.

File::Find::Rule->file()
->name('abc')
->in('.');


Apart from this, i am using

use File::Find;
find(\&wanted, @directories_to_search);
sub wanted { ... }


Here basically the wanted function is just to change permissions....

The problem is...when I add
File::Find::Rule
, the
find()
function mentioned above says file itself doesn't exist. If I don't add the rule module use then the find part works great

Can anyone help me sort this one. Any ideas here would be helpful. I tried all possible combinations....but nothing works...

Thank you in advance :)

Answer

It's hard to tell from your description of the problem, but I suspect the problem is related to the fact that both

use File::Find::Rule;

and

use File::Find;

export a function named find. Replace

use File::Find::Rule;

with

use File::Find::Rule qw( );

to avoid importing find from File::Find::Rule.