mopodafordeya
mopodafordeya

Reputation: 635

How to downgrade Perl on Mac OS X Mavericks

The newly release Mavericks has removed the deprecated module "Switch.pm" from its repository. However, I have recently try to build AOSP source tree and it somehow uses this module to generate "make-hash-tools.pl"

The Mavericks has perl version of 5.16.2, and its predecessor Mountain Lion has a 5.12.4. Is there a way to downgrade my Perl?

Compilation error looks like this:

  Can't locate Switch.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-\ 
  multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level\
  /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2\
  /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16\
  /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level \
  /System/Library/Perl/Extras/5.16 .) at external/webkit/Source/WebCore\
  /make-hash-tools.pl line 23.

Thanks~!

Upvotes: 3

Views: 5232

Answers (6)

qhdwangnan
qhdwangnan

Reputation: 175

I find these command works.

sudo perl -MCPAN -e shell

cpan > force install Switch 

Upvotes: 0

MBan
MBan

Reputation: 58

looks like running sudo cpanm Switch --force worked for me

Upvotes: 3

Central Thinking Unit
Central Thinking Unit

Reputation: 67

I found another command :

sudo cpan -f Switch

I had to execute the command 2 times but for me it works on Yosemite. Thank s this blog.

Upvotes: 0

Jason Jenkins
Jason Jenkins

Reputation: 11

Worked for me on 10.9.2, with no "force".


cpan[2]> install Switch
Running install for module 'Switch'
Running make for C/CH/CHORNY/Switch-2.17.tar.gz
Fetching with LWP:

... bunch of fetch stuff ...

CPAN.pm: Building C/CH/CHORNY/Switch-2.17.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Switch
Writing MYMETA.yml and MYMETA.json

... a bunch of xcode license stuff ...

cp Switch.pm blib/lib/Switch.pm
Manifying blib/man3/Switch.3pm
  CHORNY/Switch-2.17.tar.gz
  /usr/bin/make -- OK
'YAML' not installed, will not store persistent state
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/given.t ... ok       
t/nested.t .. ok   
t/switch.t .. ok       
All tests successful.
Files=3, Tests=590,  0 wallclock secs ( 0.04 usr  0.01 sys +  0.22 cusr  0.01 csys =  0.28 CPU)
Result: PASS
  CHORNY/Switch-2.17.tar.gz
  /usr/bin/make test -- OK
Running make install
Installing /Library/Perl/5.16/Switch.pm
Installing /usr/local/share/man/man3/Switch.3pm
Appending installation info to /Library/Perl/Updates/5.16.2/darwin-thread-multi-2level/perllocal.pod
  CHORNY/Switch-2.17.tar.gz
  /usr/bin/make install  -- OK

I then ran my code that previously pitched the "Can't locate Switch.pm in @INC" error, and the code ran fine.

Upvotes: 1

Elise
Elise

Reputation: 21

you can also use this:

$ sudo defaults write '/Library/Preferences/com.apple.versioner.perl' Version 5.12

It makes perl run version 12 for most stuff. Unfortunately, not for apache ...

Upvotes: 2

Quentin
Quentin

Reputation: 944217

You can use perlbrew to install a parallel version of Perl in its own directory with its own modules. Currently it lets you install Perl as far back as 5.003_07, although not all of them are supported by Perl Porters for security fixes.

It would probably be simpler to install Switch from CPAN though.

Upvotes: 5

Related Questions