views:

290

answers:

3

I want to set up Perl 5.10 in my home directory in addition to the ancient Perl currently on the machine in the /usr/local. I am not a super-user on this machine.

I found the require 5.10 HPUX perl binary package and it seems to work, but for some reason it seems to assume it's running in /usr/local (as evidenced by @INC error messages). Is there some other variable in addition to PERLLIB, like PERLHOME or something I need to set so that Perl won't look for anything in the /usr/local dirs?

P.S. I seen advice online to compile and set the dir in the ./Configure step, but I been having hard time compiling things on this old box so I'd prefer to use the pre-compiled Perl since it seems mostly to work.


UPDATE -- Leon answered this, so basically it's not possible to run perl binary correctly from your home dir unless it was compiled with that in mind

+2  A: 

It depends on whether or not your perl binary is relocatable. It's a compile time option. What is the output of this command? Is it defined or not?

perl -V:userelocatableinc
Leon Timmermans
perl -V:userelocatableinc userelocatableinc='undef';
Ville M
Then you're out of luck. You'll have to compile it yourself.
Leon Timmermans
Does that mean it won't work? So your answers is basically that there is no way to put this binary in my home dir since that variable wasn't set when somebody compiled it. Let's say they had, how would it work then?
Ville M
A relocatable perl uses relative paths, so it would basically do what you expect it to do.
Leon Timmermans
A: 

You can point to any interpreter path you want in the first line:

!#/my/local/perl

And if you're not looking for portability across machines, you can set @INC manually in your script. I think there's a way to get it from the env as well, which might be more portable.

chris
There are some hard coded default paths in the binary if it wasn't compiled with the options Leon specifies above.
Ville M
+2  A: 

You're not going to like this answer.

Perl stores @INC as strings in its binary. Before there was userelocatableinc the technique to relocate Perl was to do a search and replace on the binary, as well as changing them in Config.pm. This is how ActiveState shipped a relocatable Perl.

The strings have to remain the same size as they were before, padding out any extra space with null bytes. ActiveState would get around this by configuring Perl with a prefix like "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTMPPATHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or something. It also made it really unambiguous to find in the binary. You don't have such luck, so it will only work if the current paths are shorter than the paths you want to replace them with.

But that's way too complicated. Just compile Perl for yourself either using HP/UX's source or just grab the regular source from perl.org. Perl has a dedicated HP/UX developer so it should all go smoothly.

Schwern
Thanks for that additional info about activestate etc, so I did compile perl from scratch and it does work, however still having trouble with PAR's @INC, so new question to follow soon. Thanks
Ville M