in reply to Re^3: How to get sub-folder names using perl?
in thread How to get sub-folder names using perl?

This way, the script will only work on subdirectories.

it will only work on files that are not "plain files", but will still include unwanted entities like symlinks, named pipes, sockets, block and character files.

Instead of next if -f $_; which is not that accurate, it is much better to use the already suggested next unless -d $_; which does the trick of doing no more and no worse of skipping everything that's not a directory.

Cheers, Sören

Créateur des bugs mobiles - let loose once, run everywhere.
(hooked on the Perl Programming language)

Replies are listed 'Best First'.
Re^5: How to get sub-folder names using perl?
by Laurent_R (Canon) on Mar 08, 2015 at 11:05 UTC
    Yes, I absolutely agree with you, Happy-the-monk, I would also use next unless -d $_; if I wanted to get only directories. And probably add a regular expression or something else to filter out the . and .. directories. Here, I only wanted to briefly answer the question in simple terms, and I had not seen that other answers to the original question also took up this point.

    Je suis Charlie.