Search code examples
perlmodulecpan

Why are Perl modules case sensitive?


Although I haven't seen any modules with same name but with different cases, but just for curiosity, I was trying to install Log::Log4perl and during installation I misspelled it 'Perl' in place of 'perl':

% cpan -i Log::Log4Perl 
Cannot install Log::Log4Perl, don't know what it is.

When I used correct name then things went well:

% cpan -i Log::Log4perl 

Same names but different cases can create conflicts. Is there any specific reason behind that?


Solution

  • Because

    use Foo::Bar;
    

    would be ambiguous on case-sensitive file systems (Foo/Bar.pm? foo/bar.pm? FOO/BAR.pm? Foo/Bar.PM? etc), and it would require traversing the directory's contents to find the file's name. (Up to 9 directories per element of @INC would need traversing for Foo::Bar.)