I had no issue adding new CPAN packages to the OSX El Capitan shipped perl. By default, they are built in your home directory and installed in /Library/Perl/5.18/
which is writable with root privileges.
The /sw/
prefix you mention seems to come from a Fink installation. If you previously installed another perl from Fink, you probably need to update your Fink installation and update the perl package coming from it.
If you're sure you're not using Fink and you want to run another perl version alongside the one provided with OS X, you can use the one from homebrew. It will install in /usr/local
and will be available for you to call it, but all OSX perl programs will keep on using the perl version shipped with OSX. Beware that Fink and Homebrew don't play well with each other, it is better to stick to a single one.
Finally, if you want to run multiple perl versions and be able to switch back and forth between those, I'd suggest you have a look at perlbrew.
Some other useful commands to debug your perl installation further:
which perl
will tell you where your current perl exec is installedperl -V
will give you more information about the perl version, its compiled date and options and the include paths that are searched for modulesperldoc perllocal
will list you the perl modules that you installed locally with CPAN
About CPAN, as you noticed, a regular CPAN upgrade fails. There is however a solution by telling CPAN to install in /usr/local/bin/
. I have documented that CPAN upgrade in this answer.