-3

When I run my perl program, i get the error, i have tried googling it, but i could not find a definitive easy to solve answer

C:\Users\mte>C:\Users\mte\Desktop\org11.pl Can't locate org2.pm in @INC (you may need to install the org2 module) (@INC con tains: C:/Perl64/site/lib C:/Perl64/lib .) at C:\Users\mte\Desktop\org11.pl line 2. BEGIN failed--compilation aborted at C:\Users\mte\Desktop\org11.pl line 2.

the beginning of my code looks like this

use warnings;
use org22;
toolic
  • 57,801
  • 17
  • 75
  • 117
matters1776
  • 11
  • 1
  • 6
  • In the path for your setup perl can't find the module file for org22. First check where you installed it. If it is a local module you need to make certain you set the appropriate `use lib yourLocalDir/path/to/module/here` to bring it into your path. – scrappedcola Sep 21 '15 at 17:13
  • 2
    You said your code contains an instruction to load `org22`, but the error says `org2` can't be found... – ikegami Sep 21 '15 at 17:30
  • @scrappedcola , where do i put that? in my program or the command prompt? – matters1776 Sep 21 '15 at 18:12
  • above your other `use` statements in your code. just make certain you have the correct directory path. It basically says look in this directory for additional modules. – scrappedcola Sep 21 '15 at 18:24
  • @scrappedcola, i used the use function, but how does it know to point to the direct .pm file if i am only putting the path? – matters1776 Sep 21 '15 at 18:35
  • "org2" or "org22"? Accuracy is important in programming. – Dave Cross Sep 22 '15 at 09:20

1 Answers1

0

Either your perl path is incorrect/lacking, or the org22 module is not installed. Take a look at this post for more information on constructing an @INC. Make sure that the org22 module is installed (and if it isn't, that's likely the cause of this error.)

Edit:

If your module is not in @INC (the standard perl include path), and assuming that your module (for example) is located at C:\Some\Path\MyModule.pm, then:

use lib 'C:\Some\Path';
use MyModule;

# Rest of your code

You also may consider using a shebang line as the 1st line in your script:

#!/bin/perl

or

#!/usr/bin/env perl

This will help ensure a consistent experience based on which perl interpreter you are using, given updates, installations of other programs, etc.

Community
  • 1
  • 1
Tim S.
  • 2,187
  • 1
  • 25
  • 40
  • I tried almost all the example, and keep running into various problems. i tried changing my code to, use warnings; use lib "C:\Users\mte\Desktop\org22.pm"; use org22.pm; – matters1776 Sep 21 '15 at 18:07
  • i used the use function, but how does it know to point to the direct .pm file if i am only putting the path? don't i need to add something else, like "use org22.pm" – matters1776 Sep 21 '15 at 18:39
  • use lib adds a path to your @INC and nothing more. You still have to 'use' the module(s) contained in that path in your code. (and the 'use lib' has to come before the 'use' of modules in that directory.) – Tim S. Sep 21 '15 at 18:41
  • Updated my answer with more details about use lib. – Tim S. Sep 21 '15 at 18:50
  • for the use module, should i include the .pm or no? – matters1776 Sep 21 '15 at 19:44
  • No. Never use extensions for modules in 'use' statements. The example shows that. – Tim S. Sep 21 '15 at 21:11