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?
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
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.
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.