#!/usr/bin/perl use strict ; use warnings ; open(CMDOPT, "find /path -type d | ") or die("$! : cant execute find") ; while() { print "Directory found : $_" ; ##do something with the directory here..... }