Use File::Util; my $f = File::Util->new(); my @dirs = $f->list_dir('C:\Input', qw( --dirs-only --recurse --with-paths ));