Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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/Socket.pm $perldoc -l IO::socket; /usr/local/ActivePerl-5.10/lib/IO/socket.pm
$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 Dir.pm -r--r--r-- 1 root admin 4907 Aug 24 17:00 File.pm -r--r--r-- 1 root admin 16421 Aug 24 17:00 Handle.pm -r--r--r-- 1 root admin 5473 Aug 24 17:00 Pipe.pm -r--r--r-- 1 root admin 4554 Aug 24 17:00 Poll.pm -r--r--r-- 1 root admin 2935 Aug 24 17:00 Seekable.pm -r--r--r-- 1 root admin 8021 Aug 24 17:00 Select.pm drwxr-xr-x 4 root admin 136 Sep 24 15:51 Socket -r--r--r-- 1 root admin 13572 Sep 24 17:06 Socket.pm -r--r--r-- 1 root admin 11461 Dec 5 2005 String.pm drwxr-xr-x 11 root admin 374 Sep 24 15:51 Uncompress -r--r--r-- 1 root admin 15015 Jul 14 17:30 Zlib.pm

Thank You Fellas!!

Comment on use seems to be case INSENSITIVE!!
Select or Download Code
Re: use seems to be case INSENSITIVE!!
by linuxer (Deacon) 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/Socket.pm /usr/local/lib/perl5/5.10.1/CGI.pm $ perl -MIO::socket -e1 Can't locate IO/socket.pm 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.

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\Socket.pm C:\Dokumente und Einstellungen\chris\Desktop>perldoc -l IO::sOCket C:\strawberry-perl\perl\site\lib\IO\sOCket.pm

    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 Parser.pm filetest.pl loadme.pl


      Test code:

      $cat filetest.pl #!/usr/local/ActivePerl-5.10/bin/perl #=============================================== # # FILE: filetest.pl # # USAGE: ./filetest.pl # # 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 = 'loadme.pl'; my $bad_filename = 'Loadme.pl'; 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:

      $./filetest.pl Found /Volumes/UserData/Users/dattanik/Programs/Perl/Work_area/Admin_s +erver/lib/Admin_server/loadme.pl Found /Volumes/UserData/Users/dattanik/Programs/Perl/Work_area/Admin_s +erver/lib/Admin_server/Loadme.pl
        ...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\Socket.pm C:\Perl\lib\IO\socket.pm C:\Perl\lib\CGI.pm

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

    -- regards, Roman
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 Socket.pm and socket.pm, 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://800770]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-08-01 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls