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

I was going to write a utility for identifying all the modules used in an application. However, one of things I wanted to leave out were the Perl Core modules. Is there a list or a way of identifying if a module is part of the core installation?

Replies are listed 'Best First'.
Re: Core Modules
by kyle (Abbot) on Jun 20, 2008 at 19:25 UTC

      The documentation is a little unclear so tell me if I am reading it correctly. It looks like it has an entry for every module that was included with Perl by version, correct? So if I do,

      use Module::CoreList; if (not Module::CoreList->first_release_by_date('Foo::Bar')) { print "Foo::bar is not a part of core\n"; }

      That should return what I want?

      Update: Adding the code to my program, I still had these modules show up that I am sure are a part of Core.

      1. strict
      2. vars
      3. constant
      4. Exporter
      5. overload

      OK, they are in the core list I just have to change my check, I believe to find them, because they have no version number.

        The corelist utility script, which is part of the Module::CoreList download, can be used as an example of using the module to give you the type of list you are looking for.

        For example, to find all core modules for Perl version 5.8.8:

        % corelist -v 5.8.8 The following modules were in perl v5.008008 CORE AnyDBM_File 1.00 Attribute::Handlers 0.78_02 AutoLoader 5.60 AutoSplit 1.04 B 1.09_01 B::Asmdata 1.01 B::Assembler 0.07 B::Bblock 1.02_01 ...

        I think you should check using the version of Perl that's running.

        if ( exists $Module::CoreList::version{$]}{'Foo::Bar'} ) { print "Foo::Bar is core in this version of Perl.\n"; }

        This way you don't false positive on something that's core in a version other than the one you have. I haven't used Module::CoreList, however, so I'm not sure.

Re: Core Modules
by Anonymous Monk on Jun 21, 2008 at 05:58 UTC
    However, one of things I wanted to leave out were the Perl Core modules.
    You shouldn't do that because core modules can be upgraded, and bugs are occasionally fixed in them.

    On a side note, that utility has been written already, its scandeps

    depend