If you're removing files from a distribution I recommend making Makefile.PL or Build.PL refuse to install, add this
my $mod = 'CGI';
if( eval "require $mod; 1" ){
die "
YOU HAVE TO UNINSTALL $mod before you can upgrade, use one of
cpanp -u $mod --force
pm-uninstall -vf $mod
";
}
Or better yet, add a pre-amble which does the actual uninstalling (maybe with ExtUtils::Install::uninstall($packlist) )
Usually you'll know which version of your module requires complete uninstalling, so you might want to add a version check ...
FWIW, this would make a good Module::Build/Module::Install/ExtUtils::MakeMaker addition/extension/plugin that accepts something like
requires_uninstall_if_installed => '<3000' ,
requires_uninstall_if_installed => { CGI => '<3000', 'CGI::Util' => '<3000' },
requires_uninstall_if_installed => [ qw' CGI CGI::Util '],
requires_uninstall_if_installed( '<3000' );
requires_uninstall_if_installed( { CGI => '<3000', 'CGI::Util' => '<3000' } );
requires_uninstall_if_installed( [ qw' CGI CGI::Util '] );