in reply to Can't get Tk.pm to work [SOLVED]

"I feel, that somehow, I need to tell cpan, that I have a v5.22.1 perl version and not 5.20.2, so it installs module in the correct folder. How can I do it? Or how can I fix this?"

If you have multiple version of perl installed, each perl will have a version of cpan.

marto@laptop:~$ which cpan /usr/bin/cpan

Simply calling cpan Module::Name will invoke the first cpan in your PATH environment variable. Either provide the full path to cpan for the version of perl you want to install modules to (/app/perl26/bin/cpan Module::Name) or alter your PATH, giving precedence to the directory containing your target Perl installation. Also, consider using cpanm over cpan, it's faster.

Replies are listed 'Best First'.
Re^2: Can't get Tk.pm to work
by igoryonya (Pilgrim) on Jan 26, 2018 at 15:31 UTC
    No, I don't have mutiple versions of perl. It's just updates automatically from ubuntu's repository.
    which cpan just shows:
    /usr/bin/cpan

      If as you say perl -v reports v5.22.1 but cpan is installing to /usr/local/lib/x86_64-linux-gnu/perl/5.20.2/ it looks as though a Ubuntu has done something weird, which wouldn't be unheard of, for example. Do you have a #!/usr/local/bin/perl if so which version? Did you try using cpanm?

      My preference, for an easy life, is to install my own version of perl elsewhere, and leave the system one alone. A custom install has resulted in fewer headaches. See also perlbrew.

        For over a year, I've started using:
        #!/usr/bin/env perl
        instead of using direct perl path.
        I've read, that env finds an executable from locations in PATH variable, which command also does, but it might resolve to not first encountered path with the named binary, but the best for context, so I've looked @ man which to see what other parameters it has, since env (I didn't find a way for it to just to show the paths, that it resolves), which has -a, that allows to show all possible paths, so I did:
        which -a perl
        It gave me only one path:
        /usr/bin/perl

      Forgive my skepticism. You can confirm or refute this easily enough with locate -r /bin/perl$.

      You could also say which version of ubuntu you have installed so we can determine which perl is the interloper.

        This resolves to:
        /snap/core/3604/usr/bin/perl /snap/core/3748/usr/bin/perl /snap/core/3887/usr/bin/perl /usr/bin/perl
        Then I did the following:
        for var_p in `locate -r /bin/perl$`; do echo $var_p; $var_p -v| grep ' +(v'; perl -le 'print "-" x 150;'; done
        It gave me the following results:
        This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux-gnu-thread-multi ---------------------------------------------------------------------- +-------------------- /snap/core/3748/usr/bin/perl This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux-gnu-thread-multi ---------------------------------------------------------------------- +-------------------- /snap/core/3887/usr/bin/perl This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux-gnu-thread-multi ---------------------------------------------------------------------- +-------------------- /usr/bin/perl This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-li +nux-gnu-thread-multi ---------------------------------------------------------------------- +--------------------
        According to results, all of them have version 5.22.1
        then I did: perl -le 'print for @INC;', it gave me:
        /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .
        None of the paths show 5.20.2, so, I don't get it, where cpan gets it from.