How can I tell if a Perl module is core or part of the standard install?

前端 未结 7 705
猫巷女王i
猫巷女王i 2020-12-13 06:04

How can I check if a Perl module is part of the core - i.e. it is part of the standard installation?

I\'m looking for:

  • a command-line command:
7条回答
  •  抹茶落季
    2020-12-13 06:29

    The corelist command from the Module::CoreList module will determine if a module is Core or not.

    > corelist Carp
    
    Carp was first release with perl 5
    
    > corelist XML::Twig
    
    XML::Twig was not in CORE (or so I think)
    

    Here is one way to use it in a script. The Module::CoreList POD is too terse -- you have to go hunting through the source code to find what methods to call:

    use strict;
    use warnings;
    use Module::CoreList;
    
    my $mod = 'Carp';
    #my $mod = 'XML::Twig';
    my @ms = Module::CoreList->find_modules(qr/^$mod$/);
    if (@ms) {
        print "$mod in core\n";
    }
    else {
        print "$mod not in core\n";
    }
    
    __END__
    
    Carp in core
    

提交回复
热议问题