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

Hello Monks,

I have never had this happen before..

$perl sockettest.pl Socket defines neither package nor VERSION--version check failed at /u +sr/local/ActivePerl-5.10/lib/IO/Socket.pm line 12. BEGIN failed--compilation aborted at /usr/local/ActivePerl-5.10/lib/IO +/Socket.pm line 12. Compilation failed in require at sockettest.pl line 25. BEGIN failed--compilation aborted at sockettest.pl line 25.

And I am not sure what to do.... it is a standard perl installation that I have used all along.. I checked IO::Socket.pm and Socket.pm just for kicks and everything seemed to be fine. (As it should be... these are standard perl modules)

Any thoughts?

P.S.: The same code works ferpectly well on other hosts... effectively it is the same as:

$perl use IO::Socket;

Replies are listed 'Best First'.
Re: IO::Socket fails!!
by ikegami (Patriarch) on Sep 24, 2009 at 21:41 UTC

    The error originates from UNIVERSAL::VERSION, which is called as Socket->VERSION(1.3); by use Socket 1.3;

    The error can be recreated by executing that line without first loading the module.

    $ perl -e'Socket->VERSION(1.3)' Socket defines neither package nor VERSION--version check failed at -e + line 1.

    The only explanation I can fathom (other than a bug) is that Perl thinks the module has been loaded when it hasn't.

    $ perl -e'BEGIN { $INC{"Socket.pm"}=1; } use Socket 1.3' Socket defines neither package nor VERSION--version check failed at -e + line 1. BEGIN failed--compilation aborted at -e line 1.

    Are you playing with %INC or using some kind of packager?

    Even looking at it can vivify it in some circumstances.

    $ perl -e'BEGIN { 1 for $INC{"Socket.pm"}; } use Socket 1.3' Socket defines neither package nor VERSION--version check failed at -e + line 1. BEGIN failed--compilation aborted at -e line 1.

    What do you get if you place the following before use IO::Socket;

    BEGIN { if (exists($INC{"Socket.pm"}) { if (defined($INC{"Socket.pm"}) { warn(">>> \"$INC{"Socket.pm"}\"\n"); } else { warn(">>> undef\n"); } } else { warn(">>> absent\n"); } }

      OP msged:

      Hi Ikegami... thank you for the note... [...] problem... had created a 'random' file named Socket.pm during my navigation trials. A find did the trick.

Re: IO::Socket fails!!
by MarkovChain (Sexton) on Sep 24, 2009 at 21:01 UTC

    This befuddles me...

    1 # IO::Socket.pm 2 # 3 # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights r +eserved. 4 # This program is free software; you can redistribute it and/or 5 # modify it under the same terms as Perl itself. 6 7 package IO::Socket; 8 9 require 5.006; 10 11 use IO::Handle; 12 use Socket 1.3; 13 use Carp; 14 use strict; 15 our(@ISA, $VERSION, @EXPORT_OK); 16 use Exporter; 17 use Errno; 18

    And then in Socket....

    1 package Socket; 2 3 our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 4 $VERSION = "1.82";

    So package and version are defined.....

Re: IO::Socket fails!!
by Anonymous Monk on Sep 25, 2009 at 06:52 UTC