Re: [PATCHv5 08/17] gitweb: Add optional output caching
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Oct 6, 2010, 23:06 UTC
- Message-ID
- <201010070106.30864.jnareb@gmail.com>
- In-Reply-To
- <AANLkTi=RFu5PzBfbF0qVjFnSHnf5GGedkgqKAA4v4nVG@mail.gmail.com>
On Thu, 7 Oct 2010, Ævar Arnfjörð Bjarmason wrote:
Show 10 quoted lines
> On Wed, Oct 6, 2010 at 22:01, Jakub Narebski <jnareb@gmail.com> wrote:
>
> > + $cache ||= 'GitwebCache::SimpleFileCache';
> > + eval "require $cache";
>
> Just:
>
> eval { require $cache };
>
> Instead?Wouldn't work correctly. We want to use 'require BAREWORD' version, where BAREWORD is name of module, e.g. GitwebCache::SimpleFileCache, and which makes Perl to search for GitwebCache/SimpleFileCache.pm in @INC.
The 'require STRING' version loads file given by a *path*, and it doesn't do library lookup.
From `perldoc -f require`:
But if you try this:
$class = 'Foo::Bar';
require $class; # $class is not a bareword
#or
require "Foo::Bar"; # not a bareword because of the ""The require function will look for the "Foo::Bar" file in the @INC array and will complain about not finding "Foo::Bar" there. In this case you can do:
eval "require $class";
Well, we could insert hooks into @INC, but I don't think we want to use such hack.
-- Jakub Narebski Poland