Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Installing Modules

What modules do I have installed? by missbarbell
Posted: 3 Feb 05

Every so often someone asks how to get a difinitive list of the Perl modules on their system. There are a few ways of doing it, but most are incomplete. You can use your local automatic installer (eg PPM) but they don't generally give you the full picture.

The piece of code below looks at what is really available to you, by using the @INC list. This contains the paths (and code blocks) to where perl can go and find the additional libraries when you ask it to 'use' or 'require' one.

In addition the following will also take into account the fact that some module libraries can contain more than one package


#!/usr/bin/perl -w
use strict;

use File::Find;

my %modlist;
find(\&print_package, @INC);

sub print_package {                                   
    if ($File::Find::name =~ /\.pm$/) {
        return unless open(PM, $File::Find::name);
        foreach (<PM>) {
            if (/^ *package +(\S+);/) {

print "$_\n"    for(sort keys %modlist);

Back to Perl FAQ Index
Back to Perl Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close