-3

If I have both /usr/bin/perl and /usr/local/bin/perl available on a system, which one should I use?

CJ7
  • 22,579
  • 65
  • 193
  • 321
  • Are they the same version? If not, use whichever version you want to use. If they are the same version, why do you have two? – jwodder Feb 15 '16 at 00:47
  • @jwodder This is not my system. This is on a server where I have limited rights. If I run `perl` from my home directory, which `perl` will be executed? – CJ7 Feb 15 '16 at 00:51
  • "which perl will be executed?" ... If only someone had figure out a way to tell that: ***`$ which perl`*** Also, if your basic Unix knowledge is at this level, you might want to consider learning a bit before diving in further. – Sinan Ünür Feb 15 '16 at 17:54
  • @SinanÜnür How do you set which `perl` to use? – CJ7 Feb 16 '16 at 01:28
  • See http://stackoverflow.com/a/2429515/100754 – Sinan Ünür Feb 16 '16 at 20:01
  • @SinanÜnür No, I mean how do I set which `perl` it uses when you type in `perl`. – CJ7 Feb 17 '16 at 05:36

1 Answers1

4

This question is unanswerable cleanly, without more informations and like - so only few remarks.

  • are you sure than you have two perls? The one could be an symbolic link to the another, for example the /usr/bin/perl -> /usr/local/bin/perl.
  • if they're aren't symlinked
    • the /usr/bin/perl is probably the system-wide perl, which comes with your basic system installation
    • and the /usr/local/bin/perl is installed by some package-management
    • just try:
    • /usr/bin/perl -V
    • and /usr/local/bin/perl -V
  • if they're different versions - someone installed to your system one additional perl
  • also, you could try which one is executed when you type perl - e.g. which one is first in your path. type perl could help. Or the simple perl -V.

Which one you should to use? Probably the package installed one, because your package-manager will install the CPAN-modules to the right location. Isn't possible to tell, which one it is. But this depends on your system's package management.

If you doubt, just install your own perl. I recommending to you

  • check the anyenv - here: https://github.com/riywo/anyenv
  • after installing the anyenv you could install the plenv (you could install plenv without anyenv too - but anyenv could help you with other interpreters too in the future)
  • install plenv with anyenv install plenv
  • after you got installed the plenv, you could install any perl version what is available and which one you want, using the:
  • plenv install 5.16.2 #or similar command
  • read about the plenv here: https://github.com/tokuhirom/plenv

You will get your own perl, and could install any CPAN module without the risk overriding your system perl modules. Also, you don't need to be admin. Simple, nice and clean.

clt60
  • 62,119
  • 17
  • 107
  • 194
  • Do you need admin rights to install `anyenv` and `plenv`? I know you already said I don't need to be admin, but can you explain this more? – CJ7 Feb 15 '16 at 01:56
  • @CJ7 `Anyenv` can be installed to any directory writable to you (it defaults to `$HOME/.anyenv`) and the `plenv` (installed by `anyenv` goes inside to this directory. And the perl (installed by `plenv`) goes also to subdirectory. So no, you didn't need admin rights. As shebang you could use `#!/usr/bin/env perl`. – clt60 Feb 15 '16 at 13:31