So you're trying to print out all the directories without the path attached onto them? If so, this might work:
use warnings;
use diagnostics;
use strict;
my %config = ( home => '/home/cjf/' );
my %user = ( site_id => 'code' );
finddir("$config{home}$user{site_id}");
sub finddir {
my $root = shift;
chomp $root;
$root = $root . '/' unless ( $root =~ m|/$| );
opendir ( DIR, $root ) or die "Can't open Directory: $!";
my @userfiles = sort grep !/^\.\.?\z/, readdir DIR;
foreach my $file (@userfiles) {
next unless ( -d "$root$file" );
print $file, "\n";
finddir("$root$file");
}
}
You might want to consider File::Find as well.