in reply to search for folder

You don't tell us where your code goes wrong and what it does, and what you expect instead.

I'm guessing without running your code.

You are not using lexical variables where you should use them. In godeep(), $dir and $fld get overwritten once the routine calls itself because $dir and $fld are global variables instead of lexical variables.

Once you declare $fld and $dir as lexical variables, they won't get overwritten when godeep() calls itself:

my( $fld ) = shift; opendir( my $dir, $fld ) or die "Couldn't opendir '$fld': $!";

If you want Perl to help you declare your variables, add this line to the top of your script:

use strict;

That makes Perl force you to decide for every variable whether it should be global or lexical.