Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Modules included more than once

by bart (Canon)
on Aug 22, 2002 at 11:11 UTC ( #191979=note: print w/replies, xml ) Need Help??

in reply to Modules included more than once

Subroutine XXXX redefined at 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 twice, as 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,, 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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2022-09-28 06:56 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (124 votes). Check out past polls.