2

I had perl version 5.8.8 installed in my system. I have installed 5.10.0 at /usr/local/bin/perl. but when i restarted my linux box now the default perl path has been changed.

which perl
/usr/local/bin/perl

I want to use perl version 5.10.0 but also want to keep default path to /usr/bin/perl (version 5.8.8).

I have tried to make an alias in my bash profile but after doing this I am not able to use perl 5.10. Can you please suggest me the way to fix this issue.

4 Answers 4

6

Check your $PATH and make sure that /usr/local/bin comes after /usr/bin

echo $PATH
2

You need to learn about the PATH environment variable. Do in a terminal:

   echo $PATH

You'll see the different directories where binaries are looked for. Usually, you'll have /usr/local/bin before /usr/bin. You can modify the PATH variable in your ~/.profile or ~/.bash_profile.

Yours, david

2

In general, using a different perl on your linux box than the system perl can be really messy, especially if you want to use multiple modules. This is because all the modules that have C code require compilation and will be dependent on your perl version. For instance if you use DBD::mysql the 5.8 version does not work for 5.10.

The 'modern' answer to this nowadays is to use perlbrew and install a different perl in your home directory, you can even have multiple.

Then you can use cpanminus to install the modules you need. You'd have installed the devel modules for mysql in order to be able to compile the module, but it will work neatly and will not break the rest of your system. https://metacpan.org/module/App::cpanminus#Installing-to-local-perl-perlbrew-

1

simply declare:
use 5.10.0;

have a look in "Location of Perl" chapter in perlrun

1
  • This only enables new features such as 'say "bla";' in perl. It does not do anything with regards to what perl you use.
    – MichielB
    Aug 31, 2011 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .