Subject: Re: [PATCH (amend)] gitweb: Use File::Find::find in git_get_projects_list

From: [email-masked] (Randal L. Schwartz)
Date: 14 Sep 2006 14:50:24 -0700

>>>>> "Jakub" == Jakub Narebski <[email-masked]> 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
<[email-masked]> <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!