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

perl -MModule::Metadata -MData::Dumper -le "print(Dumper(Module::Metad +ata->new_from_module('CGI')))" perl -MModule::Metadata -MData::Dumper -le "print(Dumper(Module::Metad +ata->new_from_module('cgi')))"
In the second example searching for "cgi" returns the metadata for "CGI" but both module and filename keys contain "cgi" and are not valid as a package or file for the "CGI" distribution?

Replies are listed 'Best First'.
Re: Module::Metadata case sensitivity
by tobyink (Canon) on Aug 19, 2018 at 03:29 UTC

    Second one just returns undef for me. There does exist a (lowercase) cgi.pm though.

      Undef? That's what I expected. On my system (5.26.2 on osx) the case-typo unexpectedly triggers the proper search but then unexpectedly propagates the wrong case to the filename and module values:
      > perl -MModule::Metadata -MData::Dumper -le "print(Dumper(Module::Met +adata->new_from_module('Data::DUMPer')))" $VAR1 = bless( { 'inc' => [ '/path/to' ], 'pod' => {}, 'packages' => [ 'Data::Dumper' ], 'version' => undef, 'collect_pod' => undef, 'versions' => { 'Data::Dumper' => bless( { 'original' + => '2.167', 'version' +=> [ + 2, + 167 + ] }, 'version' + ) }, 'pod_headings' => [ 'NAME', 'SYNOPSIS', 'DESCRIPTION', 'Methods', 'Functions', 'Configuration Variables or Metho +ds', 'Exports', 'EXAMPLES', 'BUGS', 'NOTE', 'AUTHOR', 'VERSION', 'SEE ALSO' ], 'module' => 'Data::DUMPer', 'filename' => '/path/to/Data/DUMPer.pm' }, 'Module::Metadata' ); > perl -MModule::Metadata -le'print $Module::Metadata::VERSION' 1.000033 (current)

        Oh, you're using OS X? That makes sense then. The OS X file system (HFS) is case-insensitive. CGI.pm and cgi.pm are the same file.

        It will report the same case for the module name but not the package name, because modules are files but packages are namespaces.

      That's not a cgi.pm but a script with a =head1 NAME section indicating its name is 'cgi'. PAUSE no longer considers modules of different casing to be separately indexed, for many reasons like this.
Re: Module::Metadata case sensitivity
by Anonymous Monk on Aug 19, 2018 at 06:59 UTC
    Windows filesystem is case-insensitive, so looking for cgi.pm you will find one that should have been called CGI.pm. Of course, the package it defines is called CGI, not cgi, so use cgi; fails.