Hi,

I have a requirement where I have directory structure like : -

test --> test/user1/files/, test/user2/files/, test/user3/files/ etc.
under sub-directories with usernames I have file with name usersettings.

So the final structure as : -

test / user1 / usersettings
                  /files/
         user2 / usersettings
                   /files/
         user3 / usersettings
                  /files/
         user4 / usersettings

etc

I need to get all the subdirectories of test and then read the file
usersettings under that later on to do some processing. I wrote code below
:-
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename qw(basename dirname);
use File::Find qw(find);
use File::Find::Rule;
my $indir = shift;
my $Users = {};
my @userdirs=File::Find::Rule->maxdepth(1)->directory->in($indir);

# this will give me user directories which I want only to depth 1.

    foreach my $dir(@userdirs){
        next if($dir eq "$indir");

# I need to skip parent directory

        my $user = basename($dir);
        print "$user"."\n";
        find( sub {
            print $File::Find::name;
            if ($File::Find::name =~ /Contacts/ && -s $File::Find::name > 0
) {
                                print "$File::Find::name";

                  # do some processing
              }
     }, $dir);

    }

However I get :-

Use of uninitialized value in print at new.pl line 21.
Use of uninitialized value in pattern match (m//) at new.pl line 22.

I think the issue is it is still using depth as 1. How do I reset it ?

Regards.

Reply via email to