in reply to Exporter problem

First, lexical variables cannot be exported. Use our $test="hello" instead.

Secondly, the name Config is somewhat unfortunate, because there's a core module of the same name, which you will likely load instead of your own...

Update: to elaborate on the latter point: the use lib "$FindBin::Bin"; doesn't achieve the desired effect here, because use lib itself already loads Config.pm, so your own subsequent use Config just does nothing, because the (core) module is already loaded.  In theory, you could work around that problem (in this particular case) by saying

BEGIN { unshift @INC, $FindBin::Bin }

but it's probably a better idea to choose a different name, in order to avoid such pitfalls right from the start... (What if some other module you load later should need the core module's functionality after you've successfully manoeuvred your own module into the Config namespace?)

Replies are listed 'Best First'.
Re^2: Exporter problem
by saintex (Scribe) on Jun 03, 2010 at 17:15 UTC
    thank you for your answer, my package now is "toConfig.pm".
      Hello Monks,
      now I would like to put my toConfig.pm
      in a directory called LIB;
      so I have update my scripts:
      use FindBin; use lib qw($FindBin::Bin LIB);
      In Linux it works fine, but in Windows I have:
      Can't locate toConfig.pm in @INC (@INC contains: $FindBin::Bin LIB C:/ +Perl/site/ lib C:/Perl/lib .) at C:\Documents and Settings\myFile. pl line 9.
      Why?
      Thank you...

        qw($FindBin::Bin LIB) doesn't interpolate.  It's equivalent to ('$FindBin::Bin', 'LIB'), which means you specified the literal string '$FindBin::Bin' instead of the value of the variable.

        You probably meant

        use lib "$FindBin::Bin/LIB";

        presuming the LIB directory is a subdirectory of $FindBin::Bin (i.e. the directory from where script was invoked).

        See also Quote and Quote-like Operators.

        Hello, I understand your suggestion,
        but what I like to do is to add two or more path in @INC:
        - the first is the directory of the script;
        - the second one is another directory inside the script.
        So, something like this:
        use lib ($FindBin::Bin,"$FindBin::Bin/LIB");
        Is it right?
        Thank you
        Hello Monks,
        now I have another little problem...

        Now my script is locate in directory LIB
        and I have to use my toConfig package locate in parent directory.
        So I have:

        - toConfig.pm
        ------------- LIB
        ----------------- myFile.pl

        myFile.pl use toConfig, that is in the parent directory.
        I can I do that?

        I tried with:
        use FindBin; use lib "$FindBin::Bin/../";

        But it doesn't works.