On Thu, Dec 15, 2011 at 11:02 AM, Ken Peng <short...@gmail.com> wrote:

> 2011/12/15 Brian Fraser <frase...@gmail.com>:
> >
> > The second way is using an @INC hook, which is explained in perldoc -f
> > require. Here's a pretty simple form:
> >
> > BEGIN { unshift @INC, sub { say "@_[0..$#_]"; return } }
> >
> > But the real question here is, why do you need to know this?
> >
>
>
> Thanks Brian, your info is much helpful.
>
> My real question is, for example, for the source of my module
> Net::Evernote:
> http://cpansearch.perl.org/src/YHPENG/Net-Evernote-0.02/lib/Net/Evernote.pm
>
> BEGIN {
>    my $module_dir = $INC{'Net/Evernote.pm'};
>    $module_dir =~ s/Evernote\.pm$//;
>    unshift @INC,$module_dir;
> }
>
> This begin block setup the @INC by adding a path as the module itself,
> it does work.
>
> I was thinking once Perl praser sees the file of this module existing
> in the filesystem, it will update the @INC, am I right?
> Otherwise if Perl only update the @INC after reading all the file, the
> following statement will fail:
>
>
Hm, that's not quite right. It updates %INC as soon as it can open a
filehandle and start reading, but I don't think it ever updates @INC unless
you ask it to (e.g. by  'use lib' or -I on the command line, or mucking
with it manually).


> use EDAMUserStore::UserStore;

use EDAMUserStore::Types;
> use EDAMNoteStore::NoteStore;
> use EDAMNoteStore::Types;
> use EDAMErrors::Types;
> use EDAMLimits::Types;
> use EDAMTypes::Types;
>
> Since these modules exist in  the same library dir as Evernote.pm.
> (in my OS it's /usr/local/share/perl/5.10.0/Net/Evernote.pm)
> But their names are not began with "Net::“ as they should be.
> (in my OS,  they are
> /usr/local/share/perl/5.10.0/Net//EDAMUserStore/Types.pm etc).
>
>
> This seems a Chicken-egg question, but my solution does work...
> Any futher suggestion?
>

Well, why do you have those private packages? If they are useful on their
own, it would make more sense to just install them in their own
directories. For point of reference, I think that this is what
List-Scalar-Utils does.

Reply via email to