Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Module not loading completely?

by zork42 (Monk)
on Oct 29, 2013 at 18:55 UTC ( [id://1060202]=note: print w/replies, xml ) Need Help??


in reply to Module not loading completely?

This logic module (called CORE)
Won't that risk clashing with CORE: "CORE - Namespace for Perl's core routines"?
And this showed me something very interesting: some of the subroutines were being redefined! 9 of them, in fact, were already loaded and defined; the program is now working properly.
Can you post the error messages?
The specific error is Undefined subroutine &Module::subroutine called at /home/path/module.pm line 128, <FILE> line 30.
Can you post a few lines of code around the line that generated that error?

Replies are listed 'Best First'.
Re^2: Module not loading completely?
by ric00015 (Beadle) on Oct 29, 2013 at 19:27 UTC

    The full package name is CG::CORE2. I didn't even know about Perl's CORE, and it never interfered.

    Subroutine sub1 redefined at /home/path/module.pm line 68. Subroutine sub2 redefined at /home/path/module.pm line 197. etc.

    where module.pm is used from CG::CORE2.

    sub do_something { my $var1 = shift; my $var2 = shift; my %hash = %{module::subroutine($var1, $var2)}; }

    model::subroutine is supposed to return a hash reference, and exists within the code of module.pm. However, it doesn't seem to be loading all the subroutines of module.pm.

      One scenario where the message "Subroutine xyz redefined ..." appears for every function in a Module, is when you have the module on a case insensitive filesystem (such as FAT32) and you required/used it with the wrong case. For example:
      # script.pl: use XML::twig; # wrong case, should be XML::Twig # some Module used by script.pl: use XML::Twig;
      If you write it with differing upper-/lowercase, then Perl considers them to be different files. As such loading twig.pm and Twig.pm. This works due to the case insensitive filesystem. Since it is however the same file, and it is loaded twice, it will cause all the functions of the package to be redefined. If you 'use' or 'require' the Module with the proper case, then it is only loaded once, and the error will go away.

      You say the error message is:
      Undefined subroutine &Module::subroutine called at /home/path/module. +pm line 128, <FILE> line 30.
      The filename of a Module should typically be the same as the package name (case sensitive!). Check that the package name matches the filename. Also check that the case of &Module::subroutine is correct. &module::subroutine is not the same as &Module::subroutine.

        Thanks for responding.

        First, I am on Red Hat Linux, so the case-insensitive issue is not a problem. This program will never be run on Windows either.

        Second, the case used in my error message is kind of moot, as they are separate modules. (I also edited out the names of the actual modules used, as they are considered proprietary information for work.) I should have specified that earlier. Thanks for pointing it out. The revised error would look something like this:

        Undefined subroutine &ONE::Module::subroutine called at /home/path/Other_module.pm line 128, <FILE> line 30.

        And not only that, but only 9 of at least 15 functions are redefined. It seems like the module is only partially loading.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1060202]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-20 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found