sub readindirs { my ($dirname) = @_; opendir(NEWDIR, $dirname) or die $!"; @newfiles = grep { $_ ne '.' and $_ ne '..' } readdir NEWDIR; closedir NEWDIR; $length = scalar(@newfiles); for ($i = 0; $i < $length; $i++) { if (opendir(DIR1, $newfiles[$i])) { #this is where i want to re-call the sub &readindirs($newfiles[$i]); } else { &parse_sub_routine } } }