tags:

views:

286

answers:

3

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?

+13  A: 

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
Sinan Ünür
For your answering the question despite the low accept rate (which you've noted in comments is a bad thing), I award you with 10 reputation.
Chris Lutz
+1, even though you don't need it. Thanks for answering the questions with a low acceptance rate.
choudeshell
Sinan Ünür
Or you could go and ask some questions and post and accept your own answers to boost it.
ysth
Where I can find 32-bit Perl?
aartist
How I can install 32-bit Perl on 64-bit system?
aartist
+2  A: 

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.

Mark Aufflick
A: 

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.

molecules