4

On a certain system, I am running a perl script and it's failing by saying

Can't locate List/Util.pm in @INC (@INC contains: <Some-Path>/ActiveState/perl/lib <Some-Path>/ActiveState/perl/site/lib .) at <Some-Other-Path>\searchCobolPgms.ps line 7.

Now the strange part is that before deploying the code into the failing system, I ran it on my laptop and it just ran fine. The difference in both the system is, in my laptop I am using Cygwin and perl is bundled with it and the said failing system has ActiveState perl.

<Some-Path>perl -v

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 635 provided by ActiveState Corp. http://www.ActiveState.com
Built 15:34:21 Feb  4 2003


Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

I then searched for Util under the lib of cygwin and it was present under i686-cygwin

c:\cygwin\lib\perl5\5.10>find . -name Util.pm
./CGI/Util.pm
./i686-cygwin/Hash/Util.pm
./i686-cygwin/List/Util.pm
./i686-cygwin/Scalar/Util.pm

So now I am confused. Isn;t List::Util part of the standard perl distribution? The Reason for my confusion

  1. List/Util.pm is present under i686-cygwin
  2. ActiveSync Installation was not having List/Util.pm
Abhijit
  • 62,056
  • 18
  • 131
  • 204

2 Answers2

13

List::Util was only added to core in 5.7 (a development version) and the first stable release of perl containing List::Util was 5.8.0. So, while it is in the perl 5.10 distro you have installed under cygwin, the perl 5.6.1 ActiveState executable you called does not have it. You should update the ActiveState perl to at least 5.8.0, and then it will have the module you need.

Here is a link to find all versions of perl that contain a core module: http://perlpunks.de/corelist/version?module=List%3A%3AUtil

Dan
  • 10,531
  • 2
  • 36
  • 55
  • 1
    Thanks. That makes lot of sense to me now. Unfortunately I can't update ActiveState perl just that easily because that would mean I have to go a whole process of legal and copyright stuffs apart from the whole chain of certification bla bla. So it means I have to end up changing my script to do without List::Util. Thanks again esp for the link :-) – Abhijit Jan 01 '12 at 18:33
  • Well, you can also just install List::Util without updating ActiveState. There's a package called Scalar-List-Utils at version 1.23_03 on the CPAN, it appears to be compatible with perl 5.6 with one caveat listed in the readme: http://cpansearch.perl.org/src/GBARR/Scalar-List-Utils-1.23_03/README - at the least it's a smaller amount of stuff that you need to get through your legal department :) – Dan Jan 01 '12 at 18:56
  • There's also no reason why you can't find a really old version of List::Util that was intended to be installed on perl 5.6. List::Util 1.06_00 was the version added to core, so anything before that was intended to be installed on perl 5.6. You can get all versions of the package from the BackPAN at http://backpan.perl.org/authors/id/G/GB/GBARR/ – Dan Jan 01 '12 at 19:00
10

When I check corelist I get:

corelist List::Util
List::Util was first released with perl v5.7.3

Your perl version seems to be 5.6.1, in which case List::Util would not be part of the core installation.

Judging by the path c:\cygwin\lib\perl5\5.10, it seems your cygwin version is at least 5.10, but as you will note, the cygwin path is not in the @INC of your other perl version. They are most likely separate installations, and therefore they do not share libraries.

Update your ActiveState perl, and all should be well.

TLP
  • 66,756
  • 10
  • 92
  • 149
  • Thanks TLP. Sure now it makes sense to me. I just got the link from DAN which will help me with my compatibility coding :-) – Abhijit Jan 01 '12 at 18:35