in reply to Adding a dispatch table and getting "Variable $x will not stay shared" errors.
The problem is your 'nested' sub wanted. The lexical variable $target used by the named sub 'wanted' is not what you think it is. Named subs are compiled before the script is run and at that time $target is a different animal than when findfile is called during the execution of the script.
Your best solution is to unnest wanted and pass $target in as an argument.
For much more discussion of this issue see Perl scoping not logical...?.
|
|---|