I am Perl beginner. I wanted to use Log::Log4perl module as I am familiar how it works in Java. I used cpanm script to download module, but I ran it without "sudo". Then it installed this module to my dir /home/amer/perl5. Afterwards, I installed it as sudoer, but I want to remove installation in my home dir to avoid any conflicts in future. How can I do that? Here is my cmdline execution stack.

Thanks and Regards!


That's quite experimental for the moment being, but now cpanm supports an uninstall option. From MetaCpan :

-U, --uninstall

EXPERIMENTAL: Uninstalls the modules. Will remove the distribution files from your library path using the .packlist file. When used with -l or -L, only the files under the local::lib directory will be removed. NOTE: If you have the "dual-life" module in multiple locations (i.e. site_perl and perl library path, with perl 5.12 or later), only the files in site_perl will be deleted. If the distribution has bin scripts and man, they will be kept in case the core installation still references that, although there's no guarantee that the script will continue working as expected with the older version of .pm files.


Try App::pmuninstall


App::pmuninstall is a fast module uninstaller. delete files from .packlist.

App::cpanminus and, App::cpanoutdated with a high affinity.


From your user account go to shell/command prompt, enter PPM. When PPM opens type "remove [package name]" this will uninstall that particular package for you. type "help remove" in PPM for more details.

  • What if I don't have ppm? What's the package name on redhat based distros? – azec-pdx Apr 26 '12 at 13:31
  • I am little confused with your question. You mean "RPM" the redhat package manager or are you asking how to remove the package on redhat ? – Chakri Apr 26 '12 at 14:06
  • What do you mean by PPM? I am not working with rpm packages here at all. – azec-pdx Apr 27 '12 at 5:49

I have tried App::pmuninstall and it is worked for me fine.

Install module using command:

$ perl -MCPAN -e shell

Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]>install App::pmuninstall




On my local machine it has installed to /home/taras/perl5/bin/pm-uninstall

pm-uninstall [options] Module ...


    -v,--verbose                  Turns on chatty output
    -f,--force                    Uninstalls without prompts
    -c,--checkdeps                Check dependencies (defaults to on)
    -n,--no-checkdeps             Don't check dependencies
    -q,--quiet                    Suppress some messages
    -h,--help                     This help message
    -V,--version                  Show version
    -l,--local-lib                Additional module path
    -L,--local-lib-contained      Additional module path (don't include non-core modules)

Module website is: https://metacpan.org/release/App-pmuninstall


I used David Farrell's script:

# uninstall_perl_module.pl from PerlTricks.com

use 5.14.2;
use ExtUtils::Installed;
use ExtUtils::Packlist;

# Exit unless a module name was passed
die ("Error: no Module::Name passed as an argument. E.G.\n\t perl $0 Module::Name\n") unless $#ARGV == 0;

my $module = shift @ARGV;

my $installed_modules = ExtUtils::Installed->new;

# iterate through and try to delete every file associated with the module
foreach my $file ($installed_modules->files($module)) {
    print "removing $file\n";
    unlink $file or warn "could not remove $file: $!\n";

# delete the module packfile
my $packfile = $installed_modules->packlist($module)->packlist_file;
print "removing $packfile\n";
unlink $packfile or warn "could not remove $packfile: $!\n";

# delete the module directories if they are empty
foreach my $dir (sort($installed_modules->directory_tree($module))) {
    print("removing $dir\n");
    rmdir $dir or warn "could not remove $dir: $!\n";

It did the job although it produced some scary looking output :-):

removing /
could not remove /: Device or resource busy
removing /home
could not remove /home: Permission denied

You might also want to have a look at this post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.