Question

I've installed a number of modules into my Strawberry Perl running on Windows XP, such as:

  • Regexp::Common
  • URI::Find::Schemeless

These libraries work fine in my perl code the first time directly after installing each module.

The problem is that every subsequent day I run my scripts they fail with the error:

Can't locate Regexp/Common.pm in @INC (@INC contains: C:/strawberry/perl/lib C:/ strawberry/perl/site/lib C:\strawberry\perl\vendor\lib .)

I have put all the appropriate paths into environment variables into Windows: PERL5LIB and others such as lib that were suggested on various other answers on stackoverflow and other wesites dealing with module installations. The scripts continue to fail unless I perform the following workaround that I figured out:

  1. Open the "edit the environment variables" window in Windows. ("My Computer" -> "Properties" -> "Advanced" tab -> "Environment Variables")
  2. Without adding or changing anything, click OK.
  3. Re-open any perl consoles that were already open or open a new perl window.
  4. Now the libraries are all found without issues.

Does anyone have an idea why this might be happening? I suspect it may be something specifically related to Windows/cmd or even my company's windows environment setup?

Any suggestions would be appreciated because it is an extremely annoying problem!

Was it helpful?

Solution

Windows does not clear the environment variables daily by default, therefore it's likely something in your corporate settings resetting the environment variables.

If this is the case, you have a few options:

  1. Get the network admins to modify the script so that it doesn't reset them (or includes the PERL5LIB directories you want to specify).
  2. Write another daily task, running after their daily task, which re-adds the variables on your local machine.
  3. Wrap your perl scripts with a Windows batch file, or run them with perl -I to specify the library at run time.
  4. Run your perl scripts from Cygwin bash or mingw bash, which won't use your computer's global environment variables.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top