Skip to content

How to change Perl @INC variable permanently.

June 6, 2013

Recently I worked on legacy Perl application. The target OS was Solaris 10. I needed a  specific version of Perl to make this application work.

I had very restricted permission on this system. I could not install of make any kind of changes on this system. So I copied the Perl libraries local to machine from some other server. But It did not work as Perl was build on other server. So when I was trying to run my application Perl was looking for some path when it was build.

I did some search on internet and first thing I found was this link

http://www.perlmonks.org/?node_id=486084

But it did not help me at all. I went to next link

http://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations

what i got from this –

@INC is defined when Perl is compiled and it is embedded in the binary code. You cannot change that, unless you recompile Perl. Not something we would do every day.

Finally stack overflow came to rescue – the following link describe how @INC is constructed.

http://stackoverflow.com/questions/2526804/how-is-perls-inc-constructed-aka-what-are-all-the-ways-of-affecting-where-pe

specifically I was able to change @INC which was encoded into binary just using simple

no lib <'path'>

We also need to add new path using export PERL5LIB env variable.

Hope this helps you sometime when you don’t have option to compile and other restriction on system where you are working.

Advertisements

From → Tech

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: