in reply to Finding total number of subdirectories and list them

What is STDIN connected to? If nothing in particular, it will read as lines whatever is typed at the console.

Why not do this with File::Find?
use File::Find; my $basedir = '/some/path'; my $dircount = 0; find( sub { -d && $dircount++; print $FILE::Find::name, "\n"; }, $basedir }; printf "%s subdirectories found.\n", $dircount;

After Compline,
Zaxo