 |
 |
Perl oddness under OSX
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
I have a Perl script that uses the LDAP module and in my script, I add the directory where the LDAP.pm (and friends live) to @INC via an "unshift". For corporate reasons, the .pm's need to be in an odd place. Then I "use Net::LDAP" and all is fine.
This works fine under Solaris.
Under OSX, the same method (adding to @INC via push/unshift) doesn't work at all. Perl pukes indicating that it can't find Net::LDAP and that the @INC doesn't have the special directory.
However, if I comment out the "use Net::LDAP" line and simply ask Perl to print out @INC (via join(" ", @INC)), it shows the special directory in the array.
I can successfully add the special directory using the -I command line option on the #! line though.
Anyone seen anything like this.
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Oct 2000
Status:
Offline
|
|
No, I haven't, but I have installed all my packages in /Library/Perl, and thus I' m probably not tickling the problem.
This may be a versioning magic thing. Many corporate environments are still using Perl 5.004/5.005. OS X has 5.6.
You might want to try changing the default Perl include path to add the special directory if the directory doesn't change or anything pathological like that.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
Thanks for the feedback.
Right, if you put the .pm's in /Library/Perl (or one of the other 'std'
@INC locations for OSX's perl), then you do NOT tickle the bug.
I just didn't want to put things in /Library..... I'd have preferred
/usr/local/perl/site_perl/......
I don't think it's a versioning thing though.
I can live w/ -I on the #! line for now.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: New Hampshire
Status:
Offline
|
|
Have you tried using
use lib '/path/to/the/file.pm';
? Double-check the syntax, that's from memory from last year.
Has anyone had 5.6.1 from CPAN compile successfully on OSX? Mine craps out whether I do the manual or defaults compile.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
I dont think the use/require thing w/ full path is a viable solution
as LDAP has lots of other modules it needs to load.
HOWEVER, I just fixed the problem
BEGIN {
unshift(@INC, '/path/...')
}
fixed it. I dont know why OSX requires that to be in a BEGIN block
but it does.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2000
Status:
Offline
|
|
Originally posted by howardm4:
I dont think the use/require thing w/ full path is a viable solution
as LDAP has lots of other modules it needs to load.
HOWEVER, I just fixed the problem 
BEGIN {
unshift(@INC, '/path/...')
}
fixed it. I dont know why OSX requires that to be in a BEGIN block
but it does.
Sorry, this is the way all versions of Perl work. The BEGIN says to do this at compile time.
use lib '/path/...';
does exactly the BEGIN block work, and is easier to read.
No bugs found so far.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
I'm simply saying OSX is *different* in this regard.
What works on Solaris doesn't work on OSX.
If the BEGIN{} works on OSX and works on Solaris, fine, I've learned
something about how to do my code.
My point is that it wasn't portable. Solaris seems to be able to
do it at runtime and OSX requires it at compile time.
Also, the case insensitivity of HFS+ manifests itself during
the Perl build because it uses 'makefile' and 'Makefile' and
the Makefile.SH script does a rm makefile which of course, really removes
Makefile.
If you carefully mess w/ the $firstmakefile variable, you can
get past the problem in Makefile.SH and makedepend.SH
[localhost:/tmp] howardm% touch FOO
[localhost:/tmp] howardm% touch foo
[localhost:/tmp] howardm% ls
1/ 807/ FOO emacs/
[localhost:/tmp] howardm% touch hjm
[localhost:/tmp] howardm% mv hjm foo
mv: rename hjm to foo: File exists
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2000
Status:
Offline
|
|
Originally posted by howardm4:
I'm simply saying OSX is *different* in this regard.
What works on Solaris doesn't work on OSX.
If the BEGIN{} works on OSX and works on Solaris, fine, I've learned
something about how to do my code.
My point is that it wasn't portable. Solaris seems to be able to
do it at runtime and OSX requires it at compile time.
Again, sorry. They are not different. Perl is compiled from the same source for both platforms. The site you are using Solaris on already has the Net::LDAP software installed in a standard place and that is the one you are picking up. If you think it is picking up the one you installed, you should check the version number. Alternatively, you may have PERL5LIB environment variable defined, and it is picking it up from that - that won't work for a CGI because that environment variable is not defined for a CGI.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
OK, this discussion is going down a rathole.
1. The LDAP module on Solaris is NOT installed in a 'standard place'. It
isn't part of the normal Perl install. It (the LDAP stuff) only exists
where I put it.
2. How I wrote my script (using unshift onto @INC OUTSIDE of a BEGIN block)
works fine and Perl on Solaris finds it fine.
3. I do the EXACT same thing on OSX and it doesn't work. OSX seems to force
me to put the unshift statement inside a BEGIN block.
4. I dont have PERL5LIB set.
5. There is nothing CGI related about this whole script/situation.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
I'll admit when I'm wrong.
There were multiple installed versions of Perl (and libraries) on Solaris and the one invoked on #! DID have the LDAP stuff in a standard place.
I thought it was not the case because I was looking at a different installed version (w/o LDAP).
Thanks all for your help.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|