Well, here's an idea:
my $dir = '/home/user1';
my @files = glob("$dir/*"); # Get list of files
my @directories = grep { -d } @files; # Use -d to get dirs
Then you could do:
foreach my $directory (@directories) {
my @list = glob("$directory/*");
}
...and of course repeat the process until a directory contains no more directories. Probably an easier way of traversing a directory structure is using the
File::Find module though it does have some very irritating behaviours... It's a "standard" Perl module, and it should be on your system already.