Messed up Perl
Arno Hautala
arno at alum.wpi.edu
Sun Oct 3 14:53:26 PDT 2010
On Sun, Oct 3, 2010 at 14:55, Hal Vaughan <hal at halblog.com> wrote:
>
> I just found out that on my iMac, the "perl" command is now /opt/local/bin/perl and not /usr/bin/perl.
That's because you installed perl with MacPorts.
> I ran CPAN to install WWW::Mechanize and it's in /opt/local/libs/perl5/site_perl and I can't include them in my script with "use WWW::Mechanize."
I'm not sure what the right way to clean that up is, but the proper
way to install WWW::Mechanize would have been to run /usr/bin/cpan so
that you were installing perl packages into the standard system, or to
install the MacPorts version "p5-www-mechanize".
> So how do I either return Perl to "normal" so my Mac uses the regular Perl all the time, or make Perl use the modules in /opt/local/libs/perl5/site_perl?
Using the system perl should be as simple as changing your shebang
line. (kerbang? Never heard it called that before.)
Short of cleaning up MacPorts (it'd probably be easiest to get a list
of your installed ports, wipe the /opt directory, and reinstall) I'd
switch your shebang line to point to the system perl (/usr/bin/perl)
which shouldn't by default see the modules in /opt. Then install
Mechanize using the system CPAN (/usr/bin/cpan). You could add the
MacPorts directories to your @INC list (see below), but you may run
into incompatibilities by trying to use different versions of perl and
modules.
Adding the below BEGIN block [1] to the beginning of your script will
add the MacPorts perl modules to your INC variable.
This will likely cause problems. I get the following error [2] when
importing WWW::Mechanize and running with /usr/bin/perl
You'd be better off installing the appropriate port or installing from
the system CPAN.
[1]
###
BEGIN {
push @INC,qw[
/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
];
}
###
[2]
LWP::UserAgent version 5.827 required--this is only version 5.813 at
/opt/local/lib/perl5/vendor_perl/5.8.9/WWW/Mechanize.pm line 132.
BEGIN failed--compilation aborted at
/opt/local/lib/perl5/vendor_perl/5.8.9/WWW/Mechanize.pm line 132.
Compilation failed in require at test.pl line 20.
BEGIN failed--compilation aborted at test.pl line 20.
--
arno s hautala /-| arno at alum.wpi.edu
pgp eabb6fe6 d47c500f b2458f5d a7cc7abb f81c4e00
More information about the macports-users
mailing list