How do I undo an accidental installation of all Perl modules?

Looking at this a bit closer, I don't think that you need to or should delete any directories or files on your system.

Running the command perl -MCPAN -e 'upgrade' from the command line will not install additional modules onto your system.

It will only attempt to upgrade installed modules, through the CPAN package management system, and not through Synaptic.

This is similar to running the 'r' command and then running the upgrade command at the cpan[1]> prompt. See here.

CPAN and Synaptic are two separate and distinct package management systems.

This will not install all possible Perl modules from CPAN. Nor will it modify the existing system package dB. So, you can definitely roll this back safely.

However, this is still potentially risky if an application or your system depends upon a particular version of a Perl module.

If you have interrupted the upgrade process, chances are good that you have avoided harming your system.

Recovery options:

From a command line, start cpan, and run the command r to see the list of installed modules and available upgrades. For example, here is the abbreviated output from my cpan:

cpan[7]> r

Package namespace         installed    latest  in CPAN file
App::Cpan                    1.5701      1.61  BDFOY/App-Cpan-1.61.tar.gz
DBD::mysql                    4.020     4.022  CAPTTOFU/DBD-mysql-4.022.tar.gz
DBI                           1.616     1.623  TIMB/DBI-1.623.tar.gz
DB_File                       1.821     1.827  PMQS/DB_File-1.827.tar.gz
Error                       0.17010   0.17019  SHLOMIF/Error-0.17019.tar.gz
Eval::Closure                  0.06      0.08  DOY/Eval-Closure-0.08.tar.gz
....

Take the Eval::Closure module, for this example. Let's say that you let the perl -MCPAN -e 'upgrade' command complete and you now have version 0.08 installed.

Looking at Synaptic, in this case, it will show that the latest version in the repository will still be 0.06(0.06-1, specifically, in my instance).

You can roll back to your system version, by running the following command:

sudo apt-get install --reinstall libeval-closure-perl

If you have installed any Perl modules manually and want to roll them back to a previous version, you will need download them again (either from source.cpan.org or elsewhere), and manually re-install them.

To summarize: Upgrading Perl modules within CPAN should not affect your system repository.

Best of luck. Don't panic.