Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

use seems to be case INSENSITIVE!!

by MarkovChain (Sexton)
on Oct 12, 2009 at 18:52 UTC ( #800770=perlquestion: print w/replies, xml ) Need Help??
MarkovChain has asked for the wisdom of the Perl Monks concerning the following question:

Hi Folks,

I am posting here after reading doing perldoc -f use. Now perl is a case-sensitive language.

Recently, I have had trouble loading a bunch of classes that lead me to investigate into how useworked and found out that it's basically a requirefollowed by an import that happens at compile time. Nothing fancy.

However, this threw my socks off:

$perl use IO::Socket; print "Hello" . "\n"; Hello

So far so good; but now changing the case of the .pm module file:

$perl use IO::socket; print "Hello" . "\n"; Hello

I did not expect the second part to work!!

Followed by:

$perldoc -l IO::Socket; /usr/local/ActivePerl-5.10/lib/IO/ $perldoc -l IO::socket; /usr/local/ActivePerl-5.10/lib/IO/
$ls -l /usr/local/ActivePerl-5.10/lib/IO/ total 216 drwxr-xr-x 13 root admin 442 Sep 24 15:51 Compress -r--r--r-- 1 root admin 5372 Aug 24 17:00 -r--r--r-- 1 root admin 4907 Aug 24 17:00 -r--r--r-- 1 root admin 16421 Aug 24 17:00 -r--r--r-- 1 root admin 5473 Aug 24 17:00 -r--r--r-- 1 root admin 4554 Aug 24 17:00 -r--r--r-- 1 root admin 2935 Aug 24 17:00 -r--r--r-- 1 root admin 8021 Aug 24 17:00 drwxr-xr-x 4 root admin 136 Sep 24 15:51 Socket -r--r--r-- 1 root admin 13572 Sep 24 17:06 -r--r--r-- 1 root admin 11461 Dec 5 2005 drwxr-xr-x 11 root admin 374 Sep 24 15:51 Uncompress -r--r--r-- 1 root admin 15015 Jul 14 17:30

Thank You Fellas!!

Replies are listed 'Best First'.
Re: use seems to be case INSENSITIVE!!
by rcaputo (Chaplain) on Oct 12, 2009 at 19:14 UTC

    Your filesystem is probably case insensitive. Perl decides whether you have the module by seeing whether it can find the corresponding file. Since your filesystem doesn't seem to know the difference between and, it happily reports that IO::socket is available.

        Mac is case insensitive, despite its BSD heritage.

        Takes two seconds to test...

Re: use seems to be case INSENSITIVE!!
by ikegami (Pope) on Oct 12, 2009 at 19:52 UTC
    Note that two problems surface from using the wrong case:
    • You can load the same module twice.
    • The module's import won't get called since Perl will be looking in the wrong package.
Re: use seems to be case INSENSITIVE!!
by lamprecht (Friar) on Oct 12, 2009 at 19:05 UTC

    You can always see that on Win:

    C:\Dokumente und Einstellungen\chris\Desktop>perldoc -l IO::Socket C:\strawberry-perl\perl\site\lib\IO\ C:\Dokumente und Einstellungen\chris\Desktop>perldoc -l IO::sOCket C:\strawberry-perl\perl\site\lib\IO\

    Cheers, Christoph

      Well I would not be surprised on windows as file-paths in windows are case insensitive anyway.

      If this is indeed an ActiveState issue, then this is a serious bug. I read up the perldoc for require and it does not indicate that the search be case insensitive. For example, try below:

      File listing:

      $ls -al total 112 $ls -1 Interface Parser

      Test code:

      $cat #!/usr/local/ActivePerl-5.10/bin/perl #=============================================== # # FILE: # # USAGE: ./ # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # VERSION: 1.0 # CREATED: 10/12/2009 15:16:25 EDT # REVISION: --- #=============================================== use strict; use warnings; use FindBin qw($Bin); my $good_filename = ''; my $bad_filename = ''; print "Found $Bin/$good_filename" . "\n" if (-e $Bin . '/' . $good_fil +ename); print "Found $Bin/$bad_filename" . "\n" if (-e $Bin . '/' . $bad_filen +ame);

      Run results:

      $./ Found /Volumes/UserData/Users/dattanik/Programs/Perl/Work_area/Admin_s +erver/lib/Admin_server/ Found /Volumes/UserData/Users/dattanik/Programs/Perl/Work_area/Admin_s +erver/lib/Admin_server/
        ...does not indicate that the search be case insensitive

        No, but clearly indicated, in the equivalent code, is the fact that each module name is held as a key in %INC i.e. the underlying OS is responsible only for returning the/a requested file - thus only on a case-sensitive OS will require Foo; and require FoO; equate to different module implementation files being included i.e. on a case-insensitive OS, both require Foo; & require FoO; equate to the same module implementation file being included.

        A user level that continues to overstate my experience :-))
Re: use seems to be case INSENSITIVE!!
by bobr (Monk) on Oct 12, 2009 at 19:13 UTC
    With ActiveState Perl and windows you have case insensitive filesystem and also both slash and backslash work for path separator.
    C:\>perldoc -l IO::Socket IO::socket CGI C:\Perl\lib\IO\ C:\Perl\lib\IO\ C:\Perl\lib\

    Are you using cygwin? It has also similar methods to ensure unix programs work.

    -- regards, Roman
Re: use seems to be case INSENSITIVE!!
by linuxer (Curate) on Oct 12, 2009 at 19:02 UTC

    Looks to me as if it is a local issue with your perl installation (maybe ActivePerl?).

    I gave it a try with my self compiled perl and got:

    $ perldoc -l IO::Socket IO::socket CGI No documentation found for "IO::socket". /usr/local/lib/perl5/5.10.1/i686-linux/IO/ /usr/local/lib/perl5/5.10.1/ $ perl -MIO::socket -e1 Can't locate IO/ in @INC (@INC contains: /usr/local/lib/perl5 +/5.10.1/i686-linux /usr/local/lib/perl5/5.10.1 /usr/local/lib/perl5/s +ite_perl/5.10.1/i686-linux /usr/local/lib/perl5/site_perl/5.10.1 .). BEGIN failed--compilation aborted.

    (I added CGI to test if multiple arguments are OK)

    As I currently don't have an ActivePerl at hand, I cannot test furthermore.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://800770]
Approved by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-04-25 05:36 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (449 votes). Check out past polls.