Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

System vs. User module version of List::Util

by Lady_Aleena (Priest)
on Jun 18, 2017 at 01:12 UTC ( [id://1193030]=perlquestion: print w/replies, xml ) Need Help??

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

Hello. List::Util is a core module, but the system version has not been updated since 1.27. So I installed it in my user directory, and it is version 1.47. However, I am getting an error that uniq is not exported by List::Util. According to the docs, List::Util has had uniq since version 1.45. So, what do I do to get the system to look at the user installed List::Util instead of the system installed List::Util? Is there precedence in @INC? Do I have to beg the system administrators to update their List::Util?

I went to the command line and read the perldoc for List::Util, and perldoc brought up the docs for 1.47 not 1.27. I am confused by that a bit.

Here is my @INC from the command line, and it has my user directories first, so that makes this even more confusing.

/www/fantasy/perl5/lib/perl5/5.24.1/x86_64-linux-64int /www/fantasy/perl5/lib/perl5/5.24.1 /www/fantasy/perl5/lib/perl5/x86_64-linux-64int /www/fantasy/perl5/lib/perl5 /usr/local/cpanel /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/x86_64-linu +x-64int /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1/x86_64-linux-64 +int /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/5.24.1 /opt/cpanel/perl5/524/site_lib/x86_64-linux-64int /opt/cpanel/perl5/524/site_lib

Here is my @INC from the browser, and it has my user directories first, so that makes this so much more confusing.

../files/lib /www/fantasy/perl5/lib/perl5 /www/fantasy/perl5/lib/perl5/x86_64-linux-thread-multi /www/fantasy/perl/usr/local/lib/perl5/5.8.8/x86_64-linux /www/fantasy/perl/usr/local/lib/perl5/5.8.8 /www/fantasy/perl/usr/local/lib/perl5/site_perl/5.8.8/x86_64-linux /www/fantasy/perl/usr/local/lib/perl5/site_perl/5.8.8 /www/fantasy/perl/usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.8/x86_64-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/x86_64-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .

Any and all help is appreciated.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re: System vs. User module version of List::Util
by kcott (Archbishop) on Jun 18, 2017 at 05:50 UTC

    G'day Lady Aleena,

    What you have installed locally ("from the command line") indicates Perl 5.24.1; however, whatever your ISP, or equivalent, has installed ("from the browser") indicates Perl 5.8.8.

    As far as I know, the core List::Util module has never had the uniq function. Here's the online perldoc for the nearest versions I could find: List::Util (Perl 5.8.8 core) and List::Util (Perl 5.24.0 core) — note the absence of the uniq function in both of those.

    When you install List::Util from CPAN, you're actually getting a bundle of modules. At the top of List::Util (CPAN) you'll see the link to the Scalar-List-Utils-1.47 distribution. Follow that to see the modules and other files; one of those is README which contains:

    This distribution is a replacement for the builtin distribution.

    This package contains a selection of subroutines that people have expressed would be nice to have in the perl core, but the usage would not really be high enough to warrant the use of a keyword, and the size so small such that being individual extensions would be wasteful.

    The module which originally had (as best as I remember) the uniq function is List::MoreUtils. Rather than trying to manipulate @INC, you might be better off changing

    use List::Util qw{uniq};

    to

    use List::MoreUtils qw{uniq};

    Of course, that would require your ISP (or equivalent) to have List::MoreUtils installed.

    "So I installed it in my user directory, and it is version 1.47. However, I am getting an error that uniq is not exported by List::Util."

    It's possible I've missed the point there somewhere; in case I haven't, I'll just point out that modules added to the 5.24.1 installation will not make them available to the 5.8.8 installation.

    — Ken

      When I said "from the command line", I sshed into my account, and read the perldoc there. I was not talking about from my system's command line.

      And darn it! My local List::Util has uniq.

      And this is just great, for my stuff for the browser, I am stuck with 5.8.8; but on the command line of my web host, I have 5.24.2. That's so not fair! (And not a PM problem.)

      And yes, my web host has List::MoreUtils installed, and I used it instead. Thanks!

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
        And this is just great, for my stuff for the browser, I am stuck with 5.8.8; but on the command line of my web host, I have 5.24.2. That's so not fair! (And not a PM problem.)
        This is actually something that you can probably fix.

        On the command line, run which perl to get the path to the perl binary that you're using there. Now modify the shebang line at the top of your web script to match (e.g., if which perl says /home/aleena/perlbin/perl, then, in your web script, change #!/usr/bin/perl to #!/home/aleena/perlbin/perl) and your web script should now run in the same version of Perl as you get on the command line, and with the same compile-time settings, including the default value of @INC.

        BTW, you use Debian, right? You should consider to use Perlbrew.

        Regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

        Furthermore I consider that Donald Trump must be impeached as soon as possible

Re: System vs. User module version of List::Util
by LanX (Saint) on Jun 18, 2017 at 02:18 UTC
    Yes there is precedence in @INC, see lib pragma to manipulate it

    Please try print  $List::Util::VERSION; to be sure about the version.

    You don't tell us into which directory you installed the module, but ../files/lib looks weird.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      At the command line, it says 1.45 for $List::Util::VERSION

      I don't don't know which directory List::Util was installed into.

      ../files/lib is where the modules I wrote are.

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
        I don't don't know which directory List::Util was installed into.

        At the shell prompt:

        $ locate List/Util.pm /usr/lib64/perl5/vendor_perl/List/Util.pm $

        You should expect to have at least 2 entries - one being the system version and one being your manually installed version.

        Maybe try perldoc -l List::Util

        Normally the path of the doc is the same.

Re: System vs. User module version of List::Util
by ikegami (Patriarch) on Jun 20, 2017 at 01:47 UTC

    L::U is an arch-specific module (because it has a binary component), so the new version is probably installed in a directory that contains 5.24.1/x86_64-linux-64int in its path. The much older Perl you use via "your browser" won't look in that directory because it only contains modules it can't load.

    You verify this using

    use List::Util; print $INC{"List/Util.pm"}, "\n";

    That said, why are testing using one build of perl, and running using another? That makes no sense. Fix your shebang line, and your problem will be solved.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1193030]
Approved by marinersk
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 01:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found