From: Randal L. Schwartz Date: Thu, 14 Sep 2006 21:50:24 GMT Subject: Re: [PATCH (amend)] gitweb: Use File::Find::find in git_get_projects_list Message-ID: <86bqpi15jz.fsf@blue.stonehenge.com> In-Reply-To: <200609141939.39406.jnareb@gmail.com> >>>>> "Jakub" == Jakub Narebski writes: Jakub> + sub wanted { Jakub> + # only directories can be git repositories Jakub> + return unless (-d $_); Jakub> + Jakub> + my $subdir = substr($File::Find::name, $pfxlen + 1); Jakub> + # we check related file in $projectroot Jakub> + if (-e "$projectroot/$subdir/HEAD") { Jakub> + push @list, { path => $subdir }; Jakub> + $File::Find::prune = 1; Jakub> } Jakub> } Jakub> - closedir($dh); Jakub> + Jakub> + File::Find::find({ Jakub> + follow_fast => 1, # follow symbolic links Jakub> + dangling_symlinks => 0, # ignore dangling symlinks, silently Jakub> + wanted => \&wanted, Jakub> + }, "$dir"); Don't define a sub inside a sub. That's the "won't stay shared" problem. Move that like this: find( { follow_fast => 1, dangling_symlinks => 0, wanted => sub { ... everything in &wanted above ... }, $dir); -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!