Home: Perl Programming Help: Advanced:
File::Find problem



Iconx
Novice

Nov 7, 2016, 12:36 PM


Views: 4843
File::Find problem

Hi everyone,

I'm stumped on this File::Find module, I'm getting an error and not sure why. I'm trying to run a find all files under a directory, this is just the first part of the script.


Code
my (%master, %slave); 
my $confDir = "/opt/drutt/ca/conf";

print "Running local find for master \n";
find( sub { -f && $master{$_} = $File::Find::name }, $confDir);


The error is this:

Code
Can't modify logical and (&&) in scalar assignment at AuditConf.pl line 16, near "$File::Find::name }" 
Execution of AuditConf.pl aborted due to compilation errors.


Help.

Thanks,

Iconx


Laurent_R
Veteran / Moderator

Nov 7, 2016, 2:08 PM


Views: 4831
Re: [Iconx] File::Find problem

Probably a precedence problem. Try:

Code
find( sub { -f and $master{$_} = $File::Find::name }, $confDir);

or

Code
find( sub {$master{$_} = $File::Find::name if -f }, $confDir);