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

I recently ran this on my system:
perl -MCPAN -e 'CPAN::Shell->r'
If the CPAN module is installed, that will give you recommendations about which modules to upgrade on your system. I think that's a great trick!

In my case, I found that most of the result list was comprised of modules that we'd installed, tried out, and then abandoned, and that's way they are out of date now.

So now I'd like the answer to a more difficult question: "Show me which modules haven't been used in last X Months". A function like that would be useful to find which modules we could just nuke, or not re-install if we need to re-create everything.

The solution that comes to mind is some sort of "module logging" which would keep track of the last time a module was "used". I know of no such facility in Perl, though. How do other folks handle the process of weeding out abandoned modules? Any good automated solutions out there?

-mark

Replies are listed 'Best First'.
Re: tracking module usage, and abandoning them
by TheoPetersen (Priest) on Feb 20, 2001 at 20:29 UTC
    Short of help from the file system or modifying use and require yourself, there isn't any easy way to do this. You could try searching all text files on your system for the module names, but even then you have to account for all the syntaxes (syntaxi?):
    use module; use module VERSION; use moudle LIST; require module; require "path/to/module.pm";
    require with a quoted path leads particularly to madness, when you consider all the paths you'd need to check. And that doesn't account for other ways the code could get loaded via do and so on.

    I've just convinced myself that I could modify Perl to do this faster than I could write an exhaustive search :)

Re: tracking module usage, and abandoning them
by gaspodethewonderdog (Monk) on Feb 20, 2001 at 20:01 UTC
    I haven't seen anything too fancy for keeping track of module usage. If the OS keeps track of it in the file system you might be able to scoop off a last accessed date and roll your own.

    Where I am working basically we all go through one person for module instalation. Otherwise you have to play with the modules in your own user space. It keeps things pretty clean, and if something breaks you know who to go bug :)

    Personally though I don't see what the big deal of removing modules would be, and it may be a little dangerous to just go remove them even if they hadn't been used in a few months. Who's to say that somebody didn't bury a use command in an if statement and it just hadn't been called yet.

    I guess I don't see the harm in keeping a few extra megs worth of unused modules around myself.

      If you're on a Unix system, you should be able to use the atime flag on find. However, by checking the CPAN reinstall recommendations, you just accessed all those files, so they'll have short atimes even if they've been abandoned for quite some time.

      -marius