in reply to Re: Problem using -I argument with Perl
in thread Problem using -I argument with Perl

Many thanks for the two replies.
I favoured the use lib option and tried to use this so that the code became.
use strict "vars"; my $inc_item; use lib "C:\\perl-programs\\modules"; foreach $inc_item (@INC) { print "$inc_item\n"; }
This worked as required and gave the following from the print
C:\perl-programs\modules
C:/perl5/lib
C:/perl5/site/lib
.
I then tried to use a moudule in the new directory with a new line at the end of the code above of
use modules::test-module
However, this did not worked as I then got the following
Can't locate modules/test.pm in @INC (@INC contains: C:\perl-programs\modules C:
/perl5/lib C:/perl5/site/lib .) at C:\perl-programs\test-inc-iarg.pz line 13.
BEGIN failed--compilation aborted at C:\perl-programs\test-inc-iarg.pz line 13.

It seems that the lines are not processed in order so that it 'got' to the
use modules::test-module
before the use lib line even though this nearer the beginning.
How can this be made to work?

Replies are listed 'Best First'.
Re^3: Problem using -I argument with Perl
by rinceWind (Monsignor) on Jan 10, 2007 at 19:19 UTC

    Name your module with an underscore instead of a hyphen

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

      That did it! Many thanks.
      I would never have guessed that was the problem.
      However, I do not understand why the print output in the main part came after the print from the module when the code lines were the other way around.
Re^3: Problem using -I argument with Perl
by MaxKlokan (Monk) on Jan 11, 2007 at 09:16 UTC
    With the line
    use modules::test-module;
    you are trying to use

    C:\perl-programs\modules\modules\test-module.pm

    I suspect you mean to use

    C:\perl-programs\modules\test-module.pm

    For that, the correct syntax is:
    use test-module;
    because you directory C:\perl-programs\modules is already in the INC path.