Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

uninstalling modules

by CassJ (Sexton)
on Jul 20, 2004 at 11:53 UTC ( #375874=perlquestion: print w/replies, xml ) Need Help??

CassJ has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Quick question on uninstalling modules...
I don't have permissions for /usr/local, so I've installed stuff in a local library. Now I want to remove a module.
I had a look at ExtUtils::Installed but it just gives me a list of modules installed in /usr/local/, even if my local library is in my path, or I add a use lib line to the script. I couldn't see any way of specifying another library in the docs - am I missing something? How does ExtUtils::Installed determine where it looks for modules?

Thanks for any help,

Cass

Replies are listed 'Best First'.
Re: uninstalling modules
by gellyfish (Monsignor) on Jul 20, 2004 at 12:42 UTC

    ExtUtils::Installed uses the $Config{sitearchlibexp} and $Config{archlibexp} values as defined in the Config module - you can assign the appropriate values to these before you call ExtUtils::Installed->new() and everything should work fine.

    /J\

      I'm probably being deeply gormless, but I can't figure out how to do what you suggest.
      I don't have write access to Config.pm file and if I use it and try to change the values in the hash it just tells me that it's read-only (does this mean it's tied to the file?). How can I fake these values for the duration of my call to ExtUtils::Installed->new()? I thought maybe I could copy the file to the lib I was using, correcting the lines on the way, but then how do I make sure that my fake Config.pm is used in preference to the real one in /usr/local?

      thanks again!

      Cxx

        No it's not you at all. I have made a patch for ExtUtils::Installed that will allow you to supply a list of locations which are outside the perl install prefix - I need to add some tests and change the documentation before I send it to p5p but this:

        --- Installed.pm.orig 2004-07-20 16:37:50.000000000 +0100 +++ Installed.pm 2004-07-20 17:23:53.000000000 +0100 @@ -77,24 +77,32 @@ } sub new { - my ($class) = @_; + my ($class, @dirs) = @_; $class = ref($class) || $class; my $self = {}; - my $archlib = $Config{archlibexp}; - my $sitearch = $Config{sitearchexp}; + push @dirs, $Config{sitearchexp}, $Config{archlibexp}; # File::Find does not know how to deal with VMS filepaths. - if( $Is_VMS ) { - $archlib = VMS::Filespec::unixify($archlib); - $sitearch = VMS::Filespec::unixify($sitearch); - } - if ($DOSISH) { - $archlib =~ s|\\|/|g; - $sitearch =~ s|\\|/|g; + foreach ( @dirs ) { + if (!m!$Config{archname}/?$!) { + $_ = File::Spec->catfile($_, $Config{archname}); + } + + if( $Is_VMS ) { + $_ = VMS::Filespec::unixify($_); + } + + if ($DOSISH) { + s|\\|/|g; + } + } + my $archlib = @dirs[-1]; + + # Read the core packlist $self->{Perl}{packlist} = ExtUtils::Packlist->new( File::Spec->catfile($archlib, '.packli +st') ); @@ -108,11 +116,15 @@ # Hack of the leading bits of the paths & convert to a module + name my $module = $File::Find::name; - $module =~ s!\Q$archlib\E/?auto/(.*)/.packlist!$1!s or - $module =~ s!\Q$sitearch\E/?auto/(.*)/.packlist!$1!s; + + foreach my $dir ( @dirs ) { + $module =~ s!\Q$dir\E/?auto/(.*)/.packlist!$1!s and last; + } + my $modfile = "$module.pm"; $module =~ s!/!::!g; + print $module,"\n"; # Find the top-level module file in @INC $self->{$module}{version} = ''; foreach my $dir (@INC) { @@ -131,8 +143,8 @@ ExtUtils::Packlist->new($File::Find::name); }; - my(@dirs) = grep { -e } ($archlib, $sitearch); - find($sub, @dirs) if @dirs; + my(@search_dirs) = grep { -e } (@dirs); + find($sub, @search_dirs) if @search_dirs; return(bless($self, $class)); }
        Will allow you to do something like:
        use ExtUtils::Installed; + + use lib qw( /home/jonathan/foo/lib/perl5/site_perl/5.8.1); + my $ff = ExtUtils::Installed->new('/home/jonathan/foo/lib/perl5/site_p +erl/5.8.1'); + print $ff->files('Foo','all');
        where I have installed the module 'Foo' with a PREFIX of '/home/jonathan/foo'

        /J\

      How do you know that?

        Er, because I looked at the code ....

        /J\

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://375874]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2020-10-23 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (238 votes). Check out past polls.

    Notices?