You have a case where ModA uses ModB (indirectly) and ModB uses ModA.
If ModA uses ModB, ModB uses ModA, and both ModA and ModB export symbols, you have a bad design.
If ModA uses ModB, ModB uses ModA, and both ModA and ModB export symbols, one needs to pay attention to code execution order. The best way I've found to avoid problems is to do:
# ModA.pm use strict; use warnings; package ModA; BEGIN { our @ISA = qw( Exporter ); our @EXPORT_OK = qw( ... ); require Exporter; } use This; use ModB; use That; ... 1;
# ModB.pm use strict; use warnings; package ModB; BEGIN { our @ISA = qw( Exporter ); our @EXPORT_OK = qw( ... ); require Exporter; } use This; use ModA; use That; ... 1;
Basically, move your use statments from where they to after your BEGIN.
In reply to Re: Module Undefined Subroutines, works one way - not another
by ikegami
in thread Module Undefined Subroutines, works one way - not another
by duane_ellis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |