You shouldn't need to solve this problem.

If you do, the best solution should be to make one module use the other, and the other one require the first inside of the function(s) that need it. This gives a predictable loading order. For an example look at the source to Carp and Exporter.

If each really does need stuff from the other, and you're unwilling to use/require, then I would still suggest the cleaner pattern:

use Exporter qw(import); BEGIN {@EXPORT_OK = qw( ... );}
That makes the magic BEGIN block much shorter. And it avoids inheriting all of Exporter.

Also you need to warn people that it is very important that neither module in its initialization can do anything that relies on the other module being fully loaded yet. Because if the other module is used first, then its compilation will be put on hold to load this one, and therefore while this module gets loaded, that one will not be loaded. I've seen people get badly bitten by this, and get in a situation where one module breaks if the other is loaded first, or worse yet where neither works if the other is loaded first. (And that is one reason that I recommend the use/require relationship instead of use/use.)

If this scares you, then I'd suggest thinking through your problem clearly enough to not need to do circular dependencies. Many other languages don't even allow them, and I don't think that is a particularly bad restriction.

In reply to Re: Mini-Tutorial: Mutual Use of Exporting Modules by tilly
in thread Mini-Tutorial: Mutual Use of Exporting Modules by ikegami

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":