Re: [PATCH (amend)] gitweb: Use File::Find::find in git_get_projects_list
- From
Randal L. Schwartz <merlyn@stonehenge.com>
- Date
- Sep 14, 2006, 21:50 UTC
- Message-ID
- <86bqpi15jz.fsf@blue.stonehenge.com>
- In-Reply-To
- <200609141939.39406.jnareb@gmail.com>
>>>>> "Jakub" == Jakub Narebski <jnareb@gmail.com> 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 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!