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?
-
RHEL = Red Hat Enterprise Linux. http://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux – Peter Mortensen Oct 06 '09 at 18:40
-
Whoever modified the question title isn't right because it is not complete. – aartist Oct 06 '09 at 21:14
-
@aartist the new title refers to the general class of questions of which your question is a particular instance ;-) – Sinan Ünür Oct 06 '09 at 21:40
-
What operating system are you using? – Michael Carman Oct 06 '09 at 23:36
-
@Michal Carman: RHEL = Red Hat Enterprise Linux – Sinan Ünür Oct 07 '09 at 00:17
-
@Sinan: Ah, brian deleted that from the title before I saw the question and without it it Peter Mortensen's comment didn't seem trustworthy. I agree with the poster that the question is no longer complete. The basic answer -- install to a different directory -- is simple enough but how to do that depends on the OS and distribution. e.g. you'd do something different to install a second copy of ActivePerl than you would to build from the source. – Michael Carman Oct 07 '09 at 13:08
-
@aartist: You have two options. Either download the 32 bit binary package for your OS (I do not have any experience with RHEL to say anything about its package management system) or download the latest source distribution and build it with the appropriate options. This might involve some studying of readmes and docs and maybe installing/creating an appropriate build environment. – Sinan Ünür Oct 10 '09 at 00:24
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

- 116,958
- 15
- 196
- 339
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.

- 11,218
- 8
- 50
- 99
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:
- You can compile a 32 bit perl that uses 64 bit ints and floats (-Duselongdouble -Duse64bitint);
- 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.

- 1,304
- 12
- 22