my @dirs = qw#/usr /tmp Kitten.gif /sys /var/run /nonexistent /root#; @dirs = map { warn "`$_' is not a directory\n" if not -d; -d _ ? $_ : () } @dirs; print "\nThe following are valid: @dirs\n";