in reply to Re: Adding a dispatch table and getting "Variable $x will not stay shared" errors.
in thread Adding a dispatch table and getting "Variable $x will not stay shared" errors.

Replies are listed 'Best First'.
Re^3: Adding a dispatch table and getting "Variable $x will not stay shared" errors.
by runrig (Abbot) on Mar 03, 2009 at 16:30 UTC
    Ok, so you do want to descend into sub-directories. But File::Find doesn't easily let you stop searching when you've found your file, so you could either use something like File::Next, or wrap the call to find() in an eval {} block, and die when you've found the file. Something like:
    eval { find(sub { ($foundfile = $File::Find::name) if $File::Find::name =~ $target; die "FoundFile" if $foundfile; }, $location) }; die $@ if $@ and $@ !~ /FoundFile/;