http://qs1969.pair.com?node_id=191979


in reply to Modules included more than once

Subroutine XXXX redefined at YYYY.pm line 1584

which forms a list of all subroutines in YYYY. This implies that the package is being included more than once.

What I would like to know is if there is any way to stop this happening, or will I just have to live with the warnings? The feature I have in mind is similar to the PHP command 'require_once'.

You shouldn't have to remove those interdependencies. They shouldn't matter.

What platform? Windows? I bet it is.

My guess is that there's a problem with the case. If you do

use Foo; use foo;
on Windows, that will indeed load Foo.pm twice, as foo.pm is the same file.

Just use the proper case everywhere.

Replies are listed 'Best First'.
Re: Re: Modules included more than once
by physgreg (Scribe) on Aug 22, 2002 at 11:24 UTC
    Thanks for the input, however we're running on a Linux box, so the use command is working as expected. These packages are used by each other, but are also used in other modules, which may or may not use both of them. It really is terrible spaghetti code, and I'm the poor sucker who's got the job of maintaining it!
      Thanks for the input, however we're running on a Linux box, so the use command is working as expected.

      Blimey, there goes the simple theory. Whatever you do, do not simply ignore these warnings! There's something really fishy going on.

      As for your snippet:

      use SUPPORT; use SUPPORT qw( %typeConvert %enumeratedTypes);
      This should be perfectly fine. What happens is that the module, SUPPORT.pm, is loaded (thus compiled) once, but that SUPPORT->import is called twice, once without any extra parameters, and once with those two (as strings). So this can't trigger this warning.

      I do suspect that indeed the same subs are defined twice, perhaps in different files. Scan your library file tree.

      And perhaps one of the development tool modules can help analyze your compiled code. I'd try with B::Xref (call script with -MO=Xref) first.