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

Dear Perlmonks, I'm new at this, sorry if this is in the wrong place. Ultimately, I want to design some web pages on my local Red Hat Server (7.2) using GD and/or Image::Magick. I've done some basic stuff - posting perl pages from /cgi-bin/, but now I want to upgrade perl and then add more graphics related perl modules. However, I have fallen at the first hurdle.... The system is currently running perl 5.6.0. I've upgraded to 5.8.1 using the rpm distro from ActivePerl, and then again using the latest stable.gz from CPAN. Both appear to install ok, butr when I perl -v, it tells me I still have 5.6.0 I installed from an account other than root. I assume I need to tell the system how to use perl 5.8.0 for all users somehow. Is there some global parameter somewhere that I need to set? Or does something need to be added to a login script in the user account? I'm using BASH Any advice or pointers gratefully received. Thanks, Clunk.
  • Comment on Upgraded perl but cant get to the new version

Replies are listed 'Best First'.
Re: Upgraded perl but cant get to the new version
by liz (Monsignor) on Oct 05, 2003 at 10:47 UTC
    Your system's Perl is probably installed as /usr/bin/perl. Any additional perl (specifically 5.8.1) will by default be installed in /usr/local/bin/perl. Your path possibly doesn't include /usr/local/bin, or has it "after" /usr/bin.

    I usually add:

    export PATH=/usr/local/bin:$PATH
    to my .bash_profile script to fix this.

    Hope this helps.

    Liz

      Dear all,

      Thank you for your marvellous replies. I am so impressed with this forum, mind if I stick around? You all deserve a repsonse....

      Liz,
      I've been banging my head against the table tying to work this out. You responded and fixed the problem in 7 minutes!

      Shemne,
      Where did I put perl?

      I just downloaded the tar to my user account and unpacked it into a directory there. I then installed from that directory.
      Is there a better way to do this?
      Is it better to install from root?

      Where should I install new moules to?
      I used your "find iname" command from root to get a complete list from the system. Very useful command. I got a very long list but I think these are the main points...

      ./usr/local/bin/perl5.8.1
      ./usr/bin/perl5.6.0

      Tachyon,

      The "locate" command - very useful, thank you. The -u listed hundreds of lines. These are updates? Do you mean things I have added - like modules?

      Any modules I have added do not show now. I only see perl5.8.1. No modules. They were there under 5.6.0

      Roger,

      I like the script. Havn't tried it yet, but I learned something about profiles and login scripts from your text - thanks.

      I'm off to try and find my modules now. I'm sure I'll be back soon...
Re: Upgraded perl but cant get to the new version
by shenme (Priest) on Oct 05, 2003 at 10:52 UTC
    When you enter the command "whereis perl" it will show you all the places the system can find 'perl'.   If you enter "which perl" you will see where the system thinks it should execute 'perl' from.   I bet none of these are where you put your copy of perl.

    Where _did_ that copy of Perl get put, anyway?   You might want to use "find . -iname 'perl*'" at some likely starting points.   Once you find it you can try "export PATH=/that/place/you/found/it:$PATH" to put that into your path so the system can execute it from there.   At that point "which perl" should show you that Perl was found where you put it.

Re: Upgraded perl but cant get to the new version
by tachyon (Chancellor) on Oct 05, 2003 at 11:39 UTC

    When you do a command like this:

    $ command

    Then the system looks at the diretories in you path and executes the first matching one. To see your path do:

    $ echo $PATH /bin:/sbin:/usr/bin:/usr/sbin: $

    In this case we have 4 dirs in the PATH. The OS will look for 'command' in /bin, then /sbin....etc until it finds an exe called 'command' If there is one in /bin it will never look any further.

    You are seeing the result of this behaviour. You will have (prabably a symlink) to 'perl' in /usr/bin so that is the first one found, and the one that gets executed when you ask for perl. If you do '/usr/local/bin/perl' (probable install location) you will get 5.8. Either call 5.8 on the shebang line as shown or replace the symlink in /usr/bin.....

    To find all the perls on your system do:

    $ locate -u $ locate bin/perl /usr/bin/perl /usr/local/bin/perl $
    The -u flag to locate updates the DB (may take a minute, background with &, add a daily cron job...) and then we run it to find all the things on the system that match the search string.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Hi tachyon,
      The -u flag to locate updates the DB...
      Not trying to be a SA here but the -u flag for locate isn't applicable to all *nix's (in my case Debian). I have to use the updatedb command instead.

      Not an attack, just an observation and "heads up" if anyone attempting it gets the good ole 'locate: invalid option -- u' error message.

        Sure, but AM specified did specify RH 7.2 where it is certainly valid.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Upgraded perl but cant get to the new version
by Roger (Parson) on Oct 05, 2003 at 13:06 UTC
    How about this heavy-handed approach. An automatic login script that sets up the perl environment for the users. Save it as /etc/perl_config.pl.
    #!/usr/bin/perl -w use strict; # Validate current user die "Unknown user!" if (!$ENV{LOGIN}); # Load user configuration (from external file or from this script) my %config; while (<DATA>) { chomp; my ($user, $pref) = /(\w+)\s+(.*)\/perl/; $config{$user} = $pref; } # Find out the preferred perl version for this user # If user not seen in the config file, set to default # path to the latest version of perl my $path = $config{$ENV{LOGIN}} || "/usr/local/bin"; # Export the modified path for the user print "export PATH=$path:\${PATH}\n"; __DATA__ roger /usr/bin/perl james /usr/local/bin/perl thomas /usr/bin/perl peter /usr/perl/bin/perl
    Note the format of the config file, to make it a bit easier to maintain and understand, I have chosen to put the full path to perl executable against each user (rather than path to bin directory), and the script will strip out the /perl bit before printing the modified path to STDOUT.

    In user's login shell, just add the following:
    eval $(/etc/perl_config.pl)
    To the system /etc/profile or user's ~/.bash_profile.