Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm new to Perl and I'm trying to set up run some Perl scripts written by someone else. These scripts use a module and I can't get the module to be 'found' by my IDE. Here is the code

use lib qw( C:\Documents and Settings\Administrator\Desktop\Code\BioPe +rl ); use bin::ExecuteConfigureBioMartBuilder;
Here is the error message in the IDE
Can't locate bin/ExecuteConfigureBioMartBuilder.pm in @INC (@INC conta +ins: C:\Documents and Settings\Administrator\Desktop\Code\BioPerl C:/Perl/site/lib C:/P +erl/lib .)
I added the use lib but to no avail. In the BioPerl directory there is a bin directory which contains a file called ExecuteConfigureBioMartBuilder which has this package definition: package bin::ExecuteConfigureBioMartBuilder; I thought this should work

thanks

Replies are listed 'Best First'.
Re: beginner - can't load a module
by Anonymous Monk on Oct 16, 2010 at 22:35 UTC
    You probably don't want to use qw(), because that gives you three separate directories:

    'C:\Documents' 'and' 'Settings\Administrator\Desktop\Code\BioPerl'
Re: beginner - can't load a module
by lyklev (Pilgrim) on Oct 16, 2010 at 23:24 UTC
    As mentioned before, qw( ) will give you three directories, because it splits on space.

    Perl was created on Unix-like systems, so to make your life easier on windows:

    • avoid spaces in path names, so create a directory 'c:\bioperl' (or whatever you want) and work there;
    • keep in mind that the backslash '\' works as an escape character to get special characters (like tabs, newlines) and to get a real backslash, you have to use a double backslash. This will make your paths look weird ('c:\\bioperl\\project').
    • when referring to files, you can use a forward slash which you don't need to escape; these are automatically converted, so 'c:/bioperl/somefile.txt' works.

    So summarizing: work in 'c:\bioperl' (or similar), put your libraries in, say, 'c:\bioperl\modules', and add the lib-line to your programs:

    use lib 'c:/bioperl/modules';
    Alternatively, add the directory to your PERL5LIB environment-variable.
      keep in mind that the backslash '\' works as an escape character to get special characters (like tabs, newlines) and to get a real backslash, you have to use a double backslash. This will make your paths look weird ('c:\\bioperl\\project').
      You do not seem to understand the difference between single and double quoted. What you said is true for double quoted strings, but even in your example you use a single quoted string. No need to escape the backslash there - it would only need to be escaped if it's at the end of the string, or if followed by a backslash. None of that is happening in the OPs path.
Re: beginner - can't load a module
by Anonymous Monk on Oct 16, 2010 at 21:44 UTC

    I posted the original question. I should have pointed out that the file ExecuteConfigureBioMartBuilder is in the bin directory along with the script I am trying to run. So the fact that the current working directory is in the @inc path means that this file should have been found doesnt it?

      Perl is looking for bin/ExecuteConfigureBioMartBuilder.pm in its error message. But there only is ./ExecuteConfigureBioMartBuilder.pm. You need to put the module into a bin/ directory or put both, the module and the script into a bin/ directory and launch the script from one level higher.

        This is what i thought but I couldn't get it to work. I created a bin directory in my current directory and copied the file there and it still couldn't find it. I made a bin directory in c:\perl\site\lib and copied the file there and it could find it. I don't understand why the second option worked but the first option failed. The disturbing thing though is that the people who I got these files from are adamant in their installation instructions that you should not move/copy files under any circumstances

Re: beginner - can't load a module
by Anonymous Monk on Oct 17, 2010 at 06:21 UTC

      Tragically flawed!

      It's like putting a band-aid on a bullet wound. It may stop the bleeding there, but it does nothing to solve the real problem. Using single quotes (as already mentioned) is a real fix. An illustration of one of the problems with the bit of code you've offered:

      use lib join ' ', qw ( C:\Path with varying spaces between wor +ds );

      ...roboticus

      Why not simply use single quotes (or q())?

      use lib 'C:\Documents and Settings\Administrator\Desktop\Code\BioPerl' +;