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

A clean install of Ubuntu 8.04. I've installed a new perl under /opt/perl. The
john@ubuntu:~/perl-5.10.1$./Configure -des -Dprefix=/opt/perl john@ubuntu:~/perl-5.10.1$make john@ubuntu:~/perl-5.10.1$make test john@ubuntu:~/perl-5.10.1$make install
appeared to run fine except for install which complained about permissions. Not sure what to do I
john@ubuntu:~$cd /opt john@ubuntu:~$sudo mkdir perl john@ubuntu:~$sudo chmod 777 perl
and then the make install ran fine. I created a link
john@ubuntu:~$cd /usr/local/bin john@ubuntu:~$sudo ln -isv /opt/perl/bin/perl perl
john@ubuntu:~$ls -l /usr/local/bin/perl lrwxrwxrwx 1 root root 18 2010-02-28 10:50 /usr/local/bin/perl -> /opt +/perl/bin/perl
This gave me:
john@ubuntu:~$/usr/local/bin/perl -e 'print "$]\n";' 5.010001 john@ubuntu:~$/usr/bin/perl -e 'print "$]\n";' 5.008008
So far so good, but
john@ubuntu:~$perl -e 'print "$]\n";' 5.008008
which wasn't what I was expecting. And worse
john@ubuntu:~$sudo perl -e 'print "$]\n";' 5.010001
The path is (extract)
john@ubuntu:~$echo $PATH /usr/local/bin: ... /usr/bin: ...
Can anyone see how I managed to screw it up? And is it possible to straighten it out? Do you need any more info?

fwiw, I'm looking to convert some cgi apps to mod_perl. I'm renting a cheap VPS as a "sandbox" but before I let myself loose on that I've set up a spare box with the same OS. At the back of my mind is how to tell Apache/mod_perl to use the perl under /opt/perl. But I fear I have a long way to go before I need worry about that (e.g. learning unix and fighting vim). :-)

As always, thanks in advance.

Updated: corrected the paths in the first code block

Replies are listed 'Best First'.
Re: Permissions for a separately installed perl
by almut (Canon) on Feb 28, 2010 at 12:24 UTC

    What do you get for

    $ ls -l /opt/perl/bin/perl $ which -a perl

    The shell's search behavior (mimicked by which) is to skip programs if their binary isn't executable for the user in question, even if it comes earlier in $PATH.

    P.S.: it's usually not a good idea to make directories like /opt/perl world-writable...

      $ ls -l /opt/perl/bin/perl -rwxr-xr-x 2 john john 1169915 2010-02-28 10:30 /opt/perl/bin/perl $ which -a perl /usr/local/bin/perl /usr/bin/perl

        Ok, in that shell, what does

        perl -e 'print "$]\n";'

        yield?

        The shell hashes paths to commands, and if you add a command to a path previous in $PATH to the already hashed one, your may not see the changes:

        qwurx [shmem] ~> touch blorflydick qwurx [shmem] ~> rm blorflydick qwurx [shmem] ~> mkdir bin qwurx [shmem] ~> PATH=$HOME/bin:$PATH qwurx [shmem] ~> which rm /bin/rm qwurx [shmem] ~> echo '#!/bin/sh' > bin/rm qwurx [shmem] ~> echo 'echo no rm damnit' >> bin/rm qwurx [shmem] ~> chmod a+x bin/rm qwurx [shmem] ~> which rm ~/bin/rm qwurx [shmem] ~> rm blorflydick rm: cannot remove `bloflydick': No such file or directory qwurx [shmem] ~>

        A new shell will see the changes, however:

        qwurx [shmem] ~> echo $SHLVL 4 qwurx [shmem] ~> bash qwurx [shmem] ~> echo $SHLVL 5 qwurx [shmem] ~> rm blorflydick no rm damnit qwurx [shmem] ~>

        Hm... another try:

        $ strace -f -efile /bin/bash -c 'perl -v' 2>&1 | grep perl
        Also try
        sudo which perl
        I think it's a matter of what's in PATH.
Re: Permissions for a separately installed perl
by stefbv (Priest) on Feb 28, 2010 at 12:58 UTC

    Try to change the symlink name (remove the old one from /usr/local/bin/) like:

    % ln -isv /opt/perl/bin/perl /usr/local/bin/myperl

    Then check if /usr/local/bin is in $PATH and try:

    % myperl -V or if not in $PATH % /usr/local/bin/myperl -V

    If all good use 'myperl'

    Update: Don't put /opt/perl/bin in %PATH