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

Ok, I have written a perl script, and it works fine on my machine and on the machines of several others who have tested it. So I know the script itself works flawlessly.

However, now it is going through another stage of testing, and whenever the testers try to run it, they get errors like "Cannot find strict.pm..." (yes, really!)

The same error happens with every other module. Every time I use use, the script crashes.

Now, with strict, this isn't really a problem, since it can be harmlessly yanked out once the code is no longer being developed. But I still think it's just bad form -- I've got a lot of coworkers who don't like strict, and I'm trying to set an example :). Also, there are other modules that are fairly important to the script which I'd really like to have (I don't want to roll my own File::Path, thank you very much!).

I need a little insight into some of Perl's inner mojo. I know it uses @INC as a search path for importing modules, but how does @INC get built? How can Perl possibly not know where to find modules that are part of the standard distribution? Is there anyway to tell Perl where to look for those files?

Thanks in advance.

If you have any trouble sounding condescending, find a Unix user to show you how it's done.
- Scott Adams

Replies are listed 'Best First'.
(Ovid - not really an answer) Re: Can't find any modules
by Ovid (Cardinal) on May 04, 2001 at 01:47 UTC
    DeusVult wrote:
    Now, with strict, this isn't really a problem, since it can be harmlessly yanked out once the code is no longer being developed.
    I disagree for two reasons:
    1. No code is ever "finished".
    2. Can you prove to me that you've thoroughly unit tested your code to the point where "use strict" won't cause any issues?
    I don't think the second point is that serious as most code should go through significant unit testing, which will catch most strict issues. The first point, though, is serious. Someone comes along to add a new feature, adds thirty lines of code only to fail to notice that "next_field" was spelled "next_feild". A two-second bug catch takes half an hour. Worse, if they don't catch it, they might code around it. Other programmers might come by and not appreciate the virtues of strict. Or maybe they assume the code is not strict compliant and don't bother trying. Why take it out? It's just begging for trouble.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Can't find any modules
by buckaduck (Chaplain) on May 04, 2001 at 02:25 UTC
    Perl's @INC gets defined during the install. Your situation sounds like one I dealt with some time ago. A sysadmin had installed Perl on one computer, and then tried to copy it to another computer. It's never a good idea, in my experience. In your case, it sounds like the libraries were either not copied, or they were put in the wrong place.

    Try running perl -V to see what @INC it's using. If it's looking in the wrong place, you may be able to put create a link to the right place. It's not the perfect solution, but sometimes when you're on another guy's computer, he calls the shots...

    buckaduck

Re: Can't find any modules
by merlyn (Sage) on May 04, 2001 at 01:42 UTC
Re: Can't find any modules
by WebHick (Scribe) on May 04, 2001 at 04:56 UTC

    I may be misunderstanding the situation, but...What about other scripts? Do they have the same problem, or is it just this one?

    Logically speaking, if no other scripts exibit this behavior, it's probably something funky with this script that's causing the problem. Its happened to me before and I ended up having to go through my code with a fine-tooth comb.

    Sarah
    All non-Perl nodes will be eliminated. Fear is your only defense.

Re (tilly) 1: Can't find any modules
by tilly (Archbishop) on May 04, 2001 at 16:14 UTC
    Another solution that I have used as a hack on Windows is to insert this:
    BEGIN { push @INC, 'h:\\\\path\\to\\misplaced\\library\\here'; }
    (It is far better to fix the install.)

    BTW a note on your .sig. In my experience for true condescending you cannot beat an OS/2 fan explaining that you should not try OS/2 because it will forever spoil you for the operating systems that you are forced to use for the rest of your life...

      I can only assume you're kidding. I worked at a place where they used a mix of windows and 0S/2. That has got to be the saddest OS I've ever used. I had to use one for a few minutes, and that was enough to make me start pining for Win95...

      We live in a society exquisitely dependent on science and technology, in which hardly anyone knows anything about science and technology.
      - Carl Sagan