explanation of @INC
- From: talklists@xxxxxxxxxx (Scott Haneda)
- Date: Thu, 22 Jan 2009 22:01:59 -0800
Hello, total newbie here, maybe 50 lines of perl in my life. I really appreciate any pointers. I have hit a research wall on this one.
I am working on trying to create a portfile for MacPorts for ASSP. MacPorts is just a package manager for OS X. There are a few things that are probably important to know.
MacPorts installs a new perl, in /opt/local/bin/perl
MacPorts puts everything in /opt/local/
ASSP required about 15 perl modules, I installed them, or wrote new portfiles for them to get them installed. I have all requirements for ASSP installed. I edit the ASSP source files to change the first line from:
When I run ASSP, it tells me three ports are not installed. One is Email::Valid, which should serve well enough as a way for me to learn how to solve this.
I think this has to do with the @INC path. I can not add to PERL5LIB environment variable, since that is outside of /opt/local/ and would require user permission to change the file.
What I am not understanding, is why these three perl mods are not finding the correct location. ASSP is running perl from /opt/local/ since it found the other 12 modules, but it misses 3 of them. Since I did not have to modify @INC to get it to find the 12, what is causing the 3 others to not be found?
I have searched the ASSP source to find a hard coded path, the module check looks like a looped array check with no special treatment to any.
Is it something in the source of Email::Valid that is making an assumption on path location?
I made a small test file to prove that Email::Valid was working..
print (Email::Valid->address('maurice@xxxxxxxxxxx') ? 'yes' : 'no');
run as `perl testfile.pl` it will fail, with error that it can not find email valid
run as `/opt/local/bin/perl testfile.pl` it works.
So this proves to my limited understanding, that changing the path to perl should be all I need to do.
I can use
use lib "/path/to/directory"
in the ASSP code, but I would like to avoid live manipulation of the ASSP source, unless it really is needed.
I believe it is in the correct location:
The output of @INC below shows that is a path that is being searched.
For reference, using `perl` plain, this is the result
perl -e "print join(\"\n\", @INC);"
Using the /opt/local/ path, this is the result
/opt/local/bin/perl -e "print join(\"\n\", @INC);"
Thanks for any help and education you may offer.