How to reinstall Mac OS X built in Perl on Mountain Lion?

I updated to Mountain Lion 4 days ago and then realised that my perl scripts did not work any longer. So I installed ActivePerl 5.14 (newest version) because I thought that perl has been deleted. After installing ActivePerl though my programmes still did not work:

Warning message:
running command 'perl calc.pl' had status 2 
Can't locate Excel/Writer/XLSX.pm in @INC (@INC contains:    
/Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 
/Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 
/Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level 
/System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-
2level /System/Library/Perl/Extras/5.12 .) at test.pl line 3.
BEGIN failed--compilation aborted at calc.pl line 3.

In the terminal when I type perl -v it shows that it uses the newly installed ActivePerl. I used sudo clan -> install Excel::Writer::XLSX to install the missing module. However, it does not install it for 5.12 but for ActivePerl 5.14.

The own Mac OS X Perl seams to be installed here:

bash-3.2$ ls /Library/Perl/
5.10    5.12    Updates
bash-3.2$ ls /System/Library/Perl/
5.10    5.12    Extras  lib
bash-3.2$

There is also a version here:

bash-3.2$ ls /opt/local/lib/perl5/
5.12.4      site_perl   vendor_perl

I thought best is to delete the ActivePerl by running its uninstaller. I did that and also removed the 5.12.4 as well as the site_perl directory in /opt/local/lib/perl5.

Then I wanted to reinstall the XLSX::Writer module using cpan. I thought that it is then installed into the old perl directory. However running cpan now results in the following error:

bash-3.2$ sudo cpan
Can't locate strict.pm in @INC (@INC contains:    
/opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level 
/opt/local/lib/perl5/site_perl/5.12.4 
/opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level 
/opt/local/lib/perl5/vendor_perl/5.12.4 /opt/local/lib/perl5/5.12.4/darwin-multi-
2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl5/site_perl 
/opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level 
/opt/local/lib/perl5/vendor_perl/5.12.3 /opt/local/lib/perl5/vendor_perl .) at 
/opt/local/bin/cpan line 5.
BEGIN failed--compilation aborted at /opt/local/bin/cpan line 5.

I don't know what to do now. I think the best I can do is probably reinstalling Mac OS X's own Perl, how to do that?


Solution 1:

I found on another website the following command

$ sudo perl -MCPAN -e 'CPAN::Shell->notest(install => CPAN::Shell->r)'

This updated all my perl modules and all is back to normal. Not sure why or what, but don't care that it is working now.