From: Jakub Narebski Date: Mon, 29 Nov 2010 23:54:45 GMT Subject: Re: [PATCHv7.1 3/4] gitweb: File based caching layer (from git.kernel.org) Message-ID: <201011300054.47312.jnareb@gmail.com> In-Reply-To: On Tue, 30 Nov 2010, demerphq wrote: > On 30 November 2010 00:07, demerphq wrote: > > 2010/11/13 Jakub Narebski : > > Also in this code: > > 2010/11/28 Jakub Narebski : > > +# > > +# Includes > > +# > > +if (!exists $INC{'cache.pl'}) { > > + my $return = do 'cache.pl'; > > + die $@ if $@; > > + die "Couldn't read 'cache.pl': $!" if (!defined $return); > > +} > > Why is that preferred to: > > require 'cache.pl'; > > And why is this thing even a .pl file? Why isnt it called > lib/GitWeb/Cache.pm or something like that? Because it is not a Perl module; in particular 'cache.pl' uses global variables from gitweb.perl (like $my_url, or $cachedir, or %action) and subroutines from gitweb.perl (like change_output() and reset_output()). That is why it needs to be injected via do, rather than included in its owne namespace with package/require. P.S. This is not my code, this is patch by J.H. (John Hawley); I did only *minimal* fixups. P.P.S. My rewrite can be found in 'gitweb/cache-kernel-pu' branch in my repository (links are to web interface) http://repo.or.cz/w/git/jnareb-git.git https://github.com/jnareb/git Sent in http://thread.gmane.org/gmane.comp.version-control.git/158313 -- Jakub Narebski Poland