in reply to Sorry, Lets try the long version.
in thread Return values, Closure Vars from File::Find &wanted subs?

You don't need to separate your variable declarations from your sub declarations. You can declare @dirlist just before the first subroutine that uses it. The declaration line will never be executed (because you exit before it gets to the declaration, so don't try to initialize it — you'd need to do that in a BEGIN block) but will be visible to the subs below it because the declaration is handled at compile time.

For tighter scoping, you can enclose it in a block with the subs that use it (main and wanted in your example code).

ikegami's solution shows you how to do multiple finds that don't all write to the same array. That is one of the main things closures are useful for.


Caution: Contents may have been coded under pressure.