tags:

views:

154

answers:

7
sh-3.2# perl -v

This is perl, v5.8.9 built for darwin-2level
...


sh-3.2# perl 2348.pl 
Can't locate HTTP/Cookies.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level /opt/local/lib/perl5/site_perl/5.8.9 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.9 /opt/local/lib/perl5/vendor_perl /opt/local/lib/perl5/5.8.9/darwin-2level /opt/local/lib/perl5/5.8.9 .) at 2348.pl line 24.
BEGIN failed--compilation aborted at 2348.pl line 24.


sh-3.2# find / | grep -i "Cookies\.pm"
/System/Library/Perl/Extras/5.10.0/HTTP/Cookies.pm
/System/Library/Perl/Extras/5.8.9/HTTP/Cookies.pm
/usr/local/ActivePerl-5.10/lib/HTTP/Cookies.pm

how to fix this? I understand I have to edit @INC but where is it? :)

+3  A: 

I guess you should try

perl -I /System/Library/Perl/Extras/5.8.9 -e'use HTTP::Cookies;'
catwalk
same thing :(sh-3.2# perl -I /System/Library/Perl/Extras/5.8.9 -e'use HTTP::Cookies;'sh-3.2# perl 2348.pl Can't locate HTTP/Cookies.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level /opt/local/lib/perl5/site_perl/5.8.9 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.9 /opt/local/lib/perl5/vendor_perl /opt/local/lib/perl5/5.8.9/darwin-2level /opt/local/lib/perl5/5.8.9 .) at 2348.pl line 24.BEGIN failed--compilation aborted at 2348.pl line 24.sh-3.2#
yoble
@yoble: He means that you should use the `I ...` argument when calling your script. The verbatim command he gave you will simply attempt to use the module and then exit (so if it errors, you can tell that the include path did not work). So do `perl -I/System/Library/Perl/Extras/5.8.9 2348.pl`.
Ether
A: 

@INC is simply the array that references your includes, much like "path" does.

Try

do '/usr/local/ActivePerl-5.10/lib/HTTP/Cookies.pm'

and use HTTP::Cookies should work fine.

Edit: you can also find out what is in @INC

$myincludes = join(", ",@INC);
print $myincludes;
Jeremy Morgan
Yeah I kinda rushed this one.
Jeremy Morgan
sh-3.2# do '/usr/local/ActivePerl-5.10/lib/HTTP/Cookies.pm'sh: syntax error near unexpected token `do'
yoble
`do` is a perl function, not a shell command.
BipedalShark
A: 

It looks like you're using a custom-compiled Perl based in the '/opt/local' directory. Two things to investigate: where are you running Perl from? Is there another in /usr/bin? I'm guessing there's a system-installed one along side the libraries you found and the custom one you're using (in which case you may want to use the cpan utility to install the module you want into the custom location).

PP
/opt/local is where macports installs its stuff (see http://macports.org); if `/opt/local/bin` isn't before `/usr/bin` in `$PATH`, call `/opt/lang/bin/cpan HTTP::Cookies`.
Ether
Oh, what a mess. Would have been helpful if the author pointed out he was using Apple software.
PP
It doesn't matter that this is on Mac OS X. It's the same issue on any platform.
brian d foy
+5  A: 

You installed HTTP::Cookies in a non-standard location. You can reinstall it with cpan HTTP::Cookies or /opt/lang/bin/cpan HTTP::Cookies.

Also see http://stackoverflow.com/questions/65865/cant-locate-foo-pm-in-inc-whats-the-easiest-way-to-install-a-missing-perl

Ether
Ether also recommends calling cpan with the full path because the shebang line should have the perl that installed cpan. Watch the output to see which directories you put it in: the CPAN.pm config might have specified something other than the default @INC.
brian d foy
A: 

You can't "edit" @INC. It's locked into the binary. (Yes, there are some windows installers that pad the value of @INC with 500 NULs so they can hot-patch the value, but let's not go there.)

So the only way to have a new value for @INC is to recompile the Perl distro.

Randal Schwartz
This is simply false. I've written dozens of scripts with @INC altered.
BipedalShark
No you haven't. You haven't altered the @INC as it is bound in the binary.
Randal Schwartz
To clarify: Randal is saying there's no way to "configure" the @INC path initially used by the `perl` executable. It's built into the binary. However, you can tell the executable that you want to look elsewhere at run-time, using command-line switches or Perl code particular to that execution. But you'll have to do this each time you run your code, as those techniques last only for that invocation.
Adam Bellaire
+2  A: 

You can edit @INC in your script:

BEGIN {
    unshift(@INC, '/System/Library/Perl/Extras/5.8.9/');
    use HTTP::Cookies;
}

(Updated with suggestions from brian d foy)

BipedalShark
You probably want that path at the front, and notice that he's running Perl 5.8.9. Although this will work since HTTP::Cookies is pure Perl, you might cause a binary incompatible module to load by looking in another version's library path.
brian d foy
+2  A: 

Searching Stackoverflow for @INC has many answers to this, and you can see many answers in the perlfaq that deal with your situation. :)

brian d foy