in reply to how to collect all CPAN modules from an existing system?

Over the years, we have installed a lot of modules from both Ubuntu repository and by CPAN command. Now I want to move to 16.04.

They should have told you that not keeping a coherent change log for any system is going to bite you sooner or later. They didn't? Shame on them.

For modules pertaining to the perl core, there is corelist. Packages installed via the Debian package managers can be found via dpkg -l *-perl (not all of them, some bundles don't have a trailing "-perl" in the package name). For CPAN installed modules, there's perllocal.pod. Finally, you could run locate .pm | grep '.pm$' | xargs dpkg -S | sort | uniq or such to get all debian packages which sport some perl module. Modules which aren't shown by these methods must have been installed by other means.

To get at the statically loaded modules of any scripts, you can add a CHECK block to them, in which you examine %INC, and run them via perl -c.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'