Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install a separate perl without disturbing the existing one?

Tags:

perl

32-bit

How I should install 32-bit Perl on 64-bit machine without affecting the existing applications that uses 64-bit Perl? Is it possible to have a single application (Read: Single file) use different version of Perl for different tasks?

like image 874
aartist Avatar asked Oct 06 '09 18:10

aartist


3 Answers

Install the custom perl in a different directory, say /opt/perl-5.10.1-32bit and specify that path in the scripts which you want to use this custom version:

#!/opt/perl-5.10.1-32bit/perl

as the first line of your script.

For example, just a few minutes ago, I did:

$ ./configure -Dprefix=/opt/perl-5.11.0
like image 121
Sinan Ünür Avatar answered Sep 25 '22 05:09

Sinan Ünür


You might also be interested in perlbrew by Kang-min Liu. It allows you to easily install multiple versions of perl.

After downloading it and installing it, run

perlbrew -h

to see the options. Looking at the documentation, it seems to be able to use the -D options as Sinan and Mark mentioned.

like image 24
Christopher Bottoms Avatar answered Sep 23 '22 05:09

Christopher Bottoms


You can't use two versions of perl for a running program for what should be fairly obvious reasons. Without knowing why you want to do that, here are a few ideas:

  1. You can compile a 32 bit perl that uses 64 bit ints and floats (-Duselongdouble -Duse64bitint);
  2. You could have two processes, one using your 64 bit perl the other using 32 bit and pass data between them using pipes or shared memory.

If you need 64 bit precision but also need to link with 32 bit libraries #1 might help. #2 is obviously a more general solution but potentially harder and/or slower since the communication point could be a bottleneck.

like image 28
Mark Aufflick Avatar answered Sep 27 '22 05:09

Mark Aufflick