open(my $FOLDERS, '+>', "dirs.log") or die $!; find(sub { push @folders, "$_" if -d $File::Find::name && !$seen{$_}++; print $FOLDERS "$_\n" if -d $File::Find::name && !$seen{$_}++; }, $cwd);