Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use Perl libraries from fink in BBEdit UNIX
In order to run Perl Scripts that use Perl libraries installed with Fink (like the PDL) within BBEdit, the environment variable PERL5LIB needs to be set at the user level.

When I used the 'Run terminal' command in BBEdit, everything was fine, because the environment variable for the tcsh had been properly set. The list of paths in @INC does include /sw/lib/perl5/ and /sw/lib/perl5/darwin, so the PDL library was loaded.

However, when using the 'Run' command within BBEdit, the compilation would abort, saying that the PDL.pm library was not found in @INC. The list of paths did not include /sw/lib/perl5/ or /sw/lib/perl5/darwin.

This hint from David Wheeler and Rick Frankel, found on a newsgroup, gave me the solution. I also found some information on Apple's web site. The idea is to set the environment variable for each user at login by creating a ~/.MacOSX/environment.plist file in XML format as explained by Apple. This is how the file should look like in this particular case (the DOCTYPE entry should be one row with a space instead of a line break):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PERL5LIB</key>
    <string>/sw/lib/perl5/darwin:/sw/lib/perl5</string>
</dict>
</plist>
For some reason, the /sw/lib/perl5/darwin is then included twice, which is OK, I guess. One way of not getting it twice is by using the following environment.plist file (the DOCTYPE entry should be one row with a space instead of a line break):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PERL5LIB</key>
    <string>/sw/lib/perl5/darwin</string>
    <key>PERL5LIB</key>
    <string>/sw/lib/perl5</string>
</dict>
</plist>
I should add that it is impossible to create such a file using PropertyListEditor application, because you can't have two keys with the same name. You have to make it in a text editor. It seems to work well, though, and I don't know if this is better or not.

The problem (and solution) might be the same for other environment variables within BBEdit.
    •    
  • Currently 3.25 / 5
  You rated: 4 / 5 (4 votes cast)
 
[5,736 views]  

Use Perl libraries from fink in BBEdit | 5 comments | Create New Account
Click here to return to the 'Use Perl libraries from fink in BBEdit' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Perl libraries from fink in BBEdit
Authored by: Beernd on May 12, '03 10:30:22AM

I'd like to use those perl-libraries for cgi-scripts, but they can't be found. I've tried putting this .MacOSX/environment.plist in /Library/Webserver, which is www's home dir, according to /etc/passwd. Unfortunately, this doesn't seem to work. Anybody?

---
\"Perhaps nothing is true, and not even that!\"
Multatuli, Ideen 1



[ Reply to This | # ]
Use Perl libraries from fink in BBEdit
Authored by: CaptainQueeg on May 12, '03 01:35:21PM

This works for me:

#!/usr/bin/perl

BEGIN {
push @INC, '/sw/lib/perl5/darwin';
}



[ Reply to This | # ]
Use Perl libraries from fink in BBEdit
Authored by: Beernd on May 13, '03 07:54:37AM
Yes, this works, but this means I have to add this to every single script. Perl can do that task easily, of course, but I think it's inelegant. I found that adding a line
SetEnv PERL5LIB /sw/lib/perl5
to my /etc/httpd/httpd.conf does the trick, probably as well as adding this to an .htaccess-file.

---
"Perhaps nothing is true, and not even that!"
Multatuli, Ideen 1

[ Reply to This | # ]

Use Perl libraries from fink in BBEdit
Authored by: Mrs. Grundy on Nov 23, '03 05:53:29PM

You may notice that if you follow this hint one of the values will be ignored. This is because the plist in this case is defining a dictionary and key values in dictionaries must be unique.



[ Reply to This | # ]
Use Perl libraries from fink in BBEdit
Authored by: cparnot on Dec 16, '03 03:36:22PM
you are totally right. I was young and ignorant at that time and I didn't know what I was really doing. My guess is that '/sw/lib/perl5/darwin' is anyway added at some other step in the list of paths. So the plist should probably read:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PERL5LIB</key>
    <string>/sw/lib/perl5</string>
</dict>
</plist>

---
charles

[ Reply to This | # ]