1

I'm using macports supplied perl 5.16.3 installed in /opt/local/bin on my macbook 10.6

jason-danckss-macbook:eg Jason$ which perl
/opt/local/bin/perl

I was testing the demo.pl file that came with AI:Categorizer.pm from metaCPAN. I installed AI:Categorizer via CPAN supplied with macports perl:

tried to run it:

original:

./demo.pl /users/Jason/Desktop/Dropbox/capstone/capstone/notes/HTML/sock
Can't locate AI/Categorizer.pm in @INC (@INC contains: /sw/lib/perl5/5.10.0/darwin-thread-multi-
2level /sw/lib/perl5/5.10.0 /sw/lib/perl5/darwin-thread-multi-2level /sw/lib/perl5 /sw/lib/perl5
/darwin /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0
/Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network
/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library
/Perl/Extras/5.10.0 .) at ./demo.pl line 21.
BEGIN failed--compilation aborted at ./demo.pl line 21.

slightly modified with: use lib "/opt/local/lib/perl5/5.16.3"; because that's where the modules are being written when I use CPAN (I use perl -MCPAN -e shell IDK if that matters)

jason-danckss-macbook:eg Jason$ ./demo.pl ../HTML/sock
Can't locate AI/Categorizer.pm in @INC (@INC contains: /opt/local/lib/perl5/5.16.3/darwin-thread-
multi-2level /opt/local/lib/perl5/5.16.3 /sw/lib/perl5/5.10.0/darwin-thread-multi-2level /sw/lib
/perl5/5.10.0 /sw/lib/perl5/darwin-thread-multi-2level /sw/lib/perl5 /sw/lib/perl5/darwin
/Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System
/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0
/Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network 
/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library
/Perl/Extras/5.10.0 .) at ./demo.pl line 21.
BEGIN failed--compilation aborted at ./demo.pl line 21.

check its in the right spot:

jason-danckss-macbook:eg Jason$ find /opt/local/lib/perl5 -name 'Categorizer.pm'
/opt/local/lib/perl5/site_perl/5.16.3/AI/Categorizer.pm

I even tried to use diagnostic. Neither I nor perl can find diagnostic.pm. CPAN cant find it. I'm guessing it was removed in more recent perl versions?

OK so I have both fink and macports on my computer, along with a default perl installation. the macports version perl is the first perl found in $PATH. I'm OK with it after all its its pretty recent: 5.16.3

I don't know or think reading modules from multiple locations is a bad idea. but IDK. I'd hate to think what kind of gymnastics I might need to do to fix this.

Has anyone encountered this before?

jason dancks
  • 1,152
  • 3
  • 9
  • 29
  • Not a direct answer to your question but... I would recommend looking at `perlbrew` rather than using MacPorts to install additional versions of Perl, see http://perlbrew.pl – mttrb Jul 11 '14 at 02:51
  • 2
    The result of `which perl` doesn't matter. It'll use the interpreter identified on the shebang (`#!`) line – ikegami Jul 11 '14 at 02:56

1 Answers1

5

I have just had a look at the AI::Categorizer bundle and the included demo.pl file has a hardcoded shebang of #!/usr/bin/perl so I believe it is trying to use the system perl.

Assuming you haven't already tried changing this line (the first line of demo.pl) to point at /opt/local/bin/perl then I suspect doing so will fix your problem.

You might also consider setting the shebang to /usr/bin/env perl which should use the version of perl from your path. Also have a look at perlbrew which is probably a better way to install non-system versions of Perl.

mttrb
  • 8,297
  • 3
  • 35
  • 57
  • 1
    I highly recommend Perlbrew. You not only can install a different Perl, but you can install multiple versions of Perl -- each with its own set of modules. The only issue is that you ***MUST*** use Bash as your shell. For 90% of the Mac users, that's no issue. For me, it was a problem because I use Kornshell. – David W. Jul 11 '14 at 18:42
  • I did try changing the shebang. I would have no choice because I was using the CPAN that goes with the macports perl. – jason dancks Jul 11 '14 at 21:30