[ The need to use this technique is a very strong indicator of a design flaw in your system, but I recognize that the resources are not always available to fix design flaws. ]

If ModA uses ModB, ModB uses ModA, and ModA or ModB imports symbols from the other, one needs to pay attention to code execution order. The best way I've found to avoid problems is to setup Exporter before loading any other module.

# ModA.pm package ModA; use strict; use warnings; use Exporter qw( import ); BEGIN { our @EXPORT = qw( ... ); } use This; use ModB; use That; ... 1;
# ModB.pm package ModB; use strict; use warnings; use Exporter qw( import ); BEGIN { our @EXPORT = qw( ... ); } use This; use ModA; use That; ... 1;

Update: Added preamble. Details can be found in Jenda's and tilly's replies.
Update: Now uses Exporter more modern interface.


In reply to Mini-Tutorial: Mutual Use of Exporting Modules by ikegami

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