Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Getting a list of directories matching a pattern

by Marshall (Canon)
on Jul 21, 2016 at 22:54 UTC ( [id://1168287] : note . print w/replies, xml ) Need Help??


in reply to Getting a list of directories matching a pattern

You can use glob to get all files (a directory is just special kind of file), then use grep to filter out the plain files. To get directories underneath the currently running program...
#!/usr/bin/perl use warnings; use strict; my @dirs = grep{-d $_}glob "*"; print join "\n",@dirs;
Make sure you take into account the path if not in the current directory.