in reply to Global symbol $dir requires a explicit package name ?
You declared $dir using 'foreach my $dir (@dir) {', which limits the declaration to inside that foreach loop, then you attempted to pass it to find(), which is outside the loop.