I tried to upgrade my Padre (the Perl IDE) on MS-Windows and broke it – so now I want to remove Padre.
There is a Perl module named: “ExtUtils : : Packlist” – used for manage .packlist files.
There is an example – used remove ALL installed modules.
I mada a slight change – to remove only a specified module – for example Padre.
(Don’t worry – I’m going to re-install it later).
Here is the code:
————————————————————
#!/usr/local/bin/perl -w use strict; use IO:: Dir; use ExtUtils:: Packlist; use ExtUtils:: Installed; sub emptydir($) { my ($dir) = @_; my $dh = IO:: Dir->new($dir) || return(0); my @count = $dh->read(); $dh->close(); return(@count == 2 ? 1 : 0); } # Find all the installed packages print("Finding all installed modules...n"); my $installed = ExtUtils::Installed->new(); foreach my $module (grep(/^Padre/, $installed->modules())) { my $version = $installed->version($module) || "???"; print("Found module $module Version $versionn"); print("Do you want to delete $module? [n] "); my $r = <STDIN>; chomp($r); if ($r && $r =~ /^y/i) { # Remove all the files foreach my $file (sort($installed->files($module))) { print("rm $filen"); unlink($file); } my $pf = $installed->packlist($module)->packlist_file(); print("rm $pfn"); unlink($pf); foreach my $dir (sort($installed->directory_tree($module))) { if (emptydir($dir)) { print("rmdir $dirn"); rmdir($dir); } } } }
————————————————————