CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



Iconx
Novice

Nov 7, 2016, 12:36 PM

Post #1 of 2 (1920 views)
File::Find problem Can't Post

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

Post #2 of 2 (1908 views)
Re: [Iconx] File::Find problem [In reply to] Can't Post

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);


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives