Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: "Installed" Perl 5.34 , sort of

by kcott (Archbishop)
on May 06, 2022 at 01:07 UTC ( [id://11143611]=note: print w/replies, xml ) Need Help??


in reply to "Installed" Perl 5.34 , sort of

G'day misterperl,

You may find it's easier to use Perlbrew.

This won't mess with the system Perl. (See ++choroba's comments re that.)

$ /usr/bin/perl -v This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-cy +gwin-threads-multi (with 6 registered patches, see perl -V for more detail) ...

You can have multiple versions of Perl installed.

$ perlbrew list * perl-5.34.0 perl-5.33.5 perl-5.32.0 perl-5.30.0

You can very easily switch between the different Perl versions you have installed.

$ which perl /home/ken/perl5/perlbrew/perls/perl-5.34.0/bin/perl $ perlbrew switch perl-5.32.0 $ which perl /home/ken/perl5/perlbrew/perls/perl-5.32.0/bin/perl $ perlbrew switch perl-5.34.0 $ which perl /home/ken/perl5/perlbrew/perls/perl-5.34.0/bin/perl

If you start your scripts with the shebang

#!/usr/bin/env perl

they will run using the current (`which perl`) version. This can be very useful when troubleshooting why a script worked successfully under one Perl version but not another: just run the script; switch version; run the script again.

Installation of Perlbrew is straightforward; as is the installation of Perl versions. There's no need to go through the laborious effort of installing Perl by hand; there's no need to fiddle with $PATH; there's no need to change shebang lines.

I've used Perlbrew on many different platforms for many years (1 to 2 decades) and can highly recommend it. Many other monks also use Perlbrew so, if you run into difficulties, there's plenty of help available.

— Ken

Replies are listed 'Best First'.
Re^2: "Installed" Perl 5.34 , sort of
by ikegami (Patriarch) on May 18, 2022 at 18:02 UTC

    just run the script; switch version; run the script again.

    First of all, you should be using use (changes that shell only), not switch (changes all subsequently-created shells).

    But you don't even need to use use.

    "$PERLBREW_ROOT"/perls/5.34t/bin/perl ... "$PERLBREW_ROOT"/perls/5.32t/bin/perl ... "$PERLBREW_ROOT"/perls/5.30t/bin/perl ...

    Update: Clarified which shells switch affects.

      "... you should be using use (changes that shell only), ..."

      use is an option; not a requirement. Fix with: s/should be using/can also use/ (or similar).

      "... not switch (changes all shells)."

      That's incorrect. Fix with: s/changes all shells/changes subsequent shells/ (or similar). Below, I show starting two shells both using 5.34 — I change to 5.32 in the second shell; the first shell remains at 5.34; after that I start a third shell which uses 5.32.

      $ # Shell A $ perlbrew list * perl-5.34.0 perl-5.33.5 perl-5.32.0 perl-5.30.0 $ # perlbrew switch in Shell B $ perlbrew list * perl-5.34.0 perl-5.33.5 perl-5.32.0 perl-5.30.0
      $ # Shell B $ perlbrew list * perl-5.34.0 perl-5.33.5 perl-5.32.0 perl-5.30.0 $ perlbrew switch perl-5.32.0 $ perlbrew list perl-5.34.0 perl-5.33.5 * perl-5.32.0 perl-5.30.0
      $ # Shell C $ perlbrew list perl-5.34.0 perl-5.33.5 * perl-5.32.0 perl-5.30.0

      — Ken

        use is an option; not a requirement.

        Well yeah. And I was saying it's the one that should have been used here.

        Fix with: s/changes all shells/changes subsequent shells/ (or similar)

        Yeah, since .bashrc is only executed on startup. I'll clarify.

Re^2: "Installed" Perl 5.34 , sort of
by misterperl (Pilgrim) on May 18, 2022 at 17:15 UTC
    TYVM, I looked at this also. First I unset PERL* env VARS, and I CD'ed to /opt/local. I removed ALL perl copies with yum.

    My @INC looks a lot better (no more /root...), BUT, I have some strange double-/ such as: /opt/local/perl5//lib/site_perl/5/34/1

    Seems like its very difficult to get a clean @INC !

    TY

      I don't have // in any of my @INC paths:

      $ perl -E 'say for @INC' /home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0/cygwin +-thread-multi /home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0 /home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0/cygwin-thread-mu +lti /home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0

      I suspect you may have done something in your installation which caused this; however, without knowing the steps you took, I don't know what that might have been. Do note the differences between your /opt/local/perl5//lib/site_perl/5/34/1 and my /home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0:

      • At the start: you have /opt/local; I have /home/ken.
      • In the middle: you have //; I have /perlbrew/perls/perl-5.34.0/.
      • At the end: you have /5/34/1; I have /5.34.0.

      There are potentially a number of things you may need to change.

      Having // in a path is not a problem in itself: x/y and x//y are effectively the same.

      $ ls -al x/y ls: cannot access 'x/y': No such file or directory $ mkdir -p x/y $ cd x//y $ pwd /home/ken/tmp/x/y $ cd ../.. $ pwd /home/ken/tmp $ cd x/y $ pwd /home/ken/tmp/x/y $ cd ../.. $ pwd /home/ken/tmp

      — Ken

        Let me ask another way... My @INC seems screwy. I do configure and make and make test and make install- how early in that process can I see @INC, and how can I view it?

        TYVM and happy Friday to all Monks!

        TYVM sir your comparison is helpful. I'm investigating whats in /etc/profile.d I suspect there are some paths in there messing things up.

        As far as the //, likely there is an ENV path somewhere ending in /, and the make somewhere , blindly added /more_dirs, I suspect.

        I rebuilt everything today as root (for make install) with no errors, I got the OK at each step. Then I use CPAN to add some modules, but oddly, now I'm having to go in and chmod a bunch of the pm's because the privs are wrong- like dozens, maybe hundreds:
        [root@newnode Socket]# ls -l total 20 -r--r--r-- 1 root root 12778 Nov 2 2021 INET.pm -r--r--r-- 1 root root 3971 Nov 2 2021 UNIX.pm [root@newnode Socket]# chmod 755 *pm
        I've been building perl since like 1995 and NEVER had these issues. I just performed the cpan instructions of configure, make, make test and make install, nothing special, on a Rocky Linux box. I guess maybe the Rocky part is somehow messing things up?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143611]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-25 01:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found