in reply to use Module and case-insensitive file names

I'll see what I can do. The pseudocode is:
include file warn if file ne filename_in_INC_hash;
I'll see if I can put something in the source that works. It looks like I need to modify pp_ctl.c:pp_require().

_____________________________________________________
Jeff japhy Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: use Module and case-insensitive file names
by John M. Dlugosz (Monsignor) on Jul 31, 2001 at 00:37 UTC
    Why would the filename put in %INC be the "proper" name? I would think it would use whatever the user typed, unless it somehow gets canonized during the search process?

    Yup, it shows the name in the program, not the actual file name:

    [D:\download\public\Perl]perl -MData::Dumper -e "use cArP; print Dumpe +r (\%%INC)" VAR1 = { 'Exporter.pm' => 'D:/Program Files/Perl-5.6/lib/Exporter.pm', 'Carp.pm' => 'D:/Program Files/Perl-5.6/lib/Carp.pm', 'XSLoader.pm' => 'D:/Program Files/Perl-5.6/lib/XSLoader.pm', 'warnings/register.pm' => 'D:/Program Files/Perl-5.6/lib/warn +ings/register.pm', 'warnings.pm' => 'D:/Program Files/Perl-5.6/lib/warnings.pm', 'overload.pm' => 'D:/Program Files/Perl-5.6/lib/overload.pm', 'Data/Dumper.pm' => 'D:/Program Files/Perl-5.6/lib/Data/Dumpe +r.pm', 'cArP.pm' => 'D:/Program Files/Perl-5.6/lib/cArP.pm' };
    Perhaps the right place would be in the code that searches @INC for the module? If it finds something that differs only in case, and it's a case-insentive OS, issue a warning and take the file name that was actually found, so things import properly.

    I don't know why, but Data::Dumper for example just doesn't work if called DaTA::Dumper, even though there is no error of any kind.

    —John

      Ok. I've changed my strategy:
      if ( running_under_windows and Foo.pm loaded and package_Foo doesn't exist ) { warn about case of Foo }
      The reason that
      use Strict; $x = 10;
      is valid is because use is merely:
      BEGIN { require Strict; Strict->import; }
      And on Windows, require Strict goes through fine, thanks to the caseless OS. And import silently fails (as is documented).

      The DaTA::Dumper thing didn't give an error because you didn't turn on warnings. If warnings were on, you'd have seen:

      Name "main::Dumper" used only once: possible typo at -e line 1. Filehandle main::Dumper never opened at -e line 1.

      _____________________________________________________
      Jeff japhy Pinyan: Perl, regex, and perl hacker.
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

        Importing a non-existent package calls Universal::import rather than giving an error? Why do we want that behavior?

        It seems to me that something like you propose used to exist! I recall getting an error when the package didn't match the name. Maybe this was in there before, or still is but doesn't work anymore?

        If you warn that package_Foo doesn't exist after reading Foo.pm, that's a general warning that's good anywhere: the file may have been renamed, you might have fat-fingered the package line when writing it, it might be a symlink, etc. If you are going to make it windows-only, check that some package does exist that's a case mismatch, rather than the target just not existing. To make it complete, need a no warnings 'package_load' as well.

        —John