foreach $n(@array) { if (-d $n) { ## do stuff } }