my $dir = '/home/user1'; my @files = glob("$dir/*"); # Get list of files my @directories = grep { -d } @files; # Use -d to get dirs