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:

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?

Thanks.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to