Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

System vs. User module version of List::Util

by Lady_Aleena (Curate)
on Jun 18, 2017 at 01:12 UTC ( #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 (Chancellor) 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 (Bishop) 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 (Pope) 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.

Re: System vs. User module version of List::Util
by sundialsvc4 (Abbot) on Jun 19, 2017 at 13:49 UTC

    A few idle comments here:

    The Unix locate command will only function if the updatedb command is being periodically run to update its database, a-n-d if the file is in a place that is being indexed by it.   (For instance, NFS shares usually are not.)   Windows systems do not have an equivalent.

    Libraries will always be searched in the order specified by @INC, which can be managed in any one of several ways (such as use lib).   But some installation scripts, which are run when you install a package for the first time, also perform these tests and may be confused by things being found in un-conventional locations.   If the test is only a warning, you can proceed.   But occasionally, you must “force” installation of the module to override the tests.   This is your judgment call.   (The OP did not provide details as to exactly when the conflict-message occurred.)

        "Windows systems do not have an equivalent." Apart from:
        • dir filename /s from the command prompt.

        Well, as much as I hate it, but that's nonsense:

        locate uses a database (created by the companion program updatedb, see locatedb). That database contains a sorted and compressed list of filenames on the system optimized for searching for filenames.

        dir /s filename (on DOS/Windows) is a stupid tree scanner that has to read at least all directories starting at the current directory. It is roughly equivalent to find . -name filename.

        • powershells get-childitem

        That's also a stupid tree scanner, according to Microsoft

        • gnu find utils

        find is yet another stupid tree scanner. See GNU documentation. Apart from that, findutils contain locate, see above.

        • One of the many ports of locate available...

        Yeah, right. You could use locate on Windows. Like you could use it on Unix. With a database optimized for searching for filenames. Updated every now and then, and not always installed. Especially not installed on any "fresh" Windows installation. It is not even part of the installation media.

        Windows has an indexing service, optional for NT 4, standard since W2k, replaced with Windows Search indexer in Vista. But both index file names AND file contents, so they are not really comparable to locate. Yes, I'm aware that the newer one has a search API, but it looks quite scary. Maybe it's quite easy to implement something that has a command line interface similar to locate, but it is not available out-of-the-box. Plus, neiter the Indexing Service nor Windows Search index all local files. Directories outside Microsoft's plan for where you should store your data are not scanned by default.

        locate's updatedb can be configured by updatedb.conf, that file usually excludes virtual files, temp directories, and files on network shares and removable media. Directories outside the FHS are usually indexed. A sane updatedb.conf is usually bundled with locate when you use a binary or source distribution of Linux, and I'd expect the same for the BSDs.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        dir filename /s from the command prompt.

        Or dir /s /b for more program friendly formatting. (Or attrib /s. It requires a little prefix trimming, but seems to run faster on uncached drives or trees.)


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
        In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
        Heh. As usual, sundial-servicer's "knowledge" is 30 years old.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1193030]
Approved by marinersk
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2017-09-20 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (236 votes). Check out past polls.

    Notices?