in reply to EXPORT_OKed function refusing to import

I presume you use use MyNameSpace::Faction ...; in Player and use MyNameSpace::Player ...; in Faction? If so, something I previously wrote should help you.

If ModA uses ModB, ModB uses ModA, and ModA or ModB exports 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( ... ); our @EXPORT_OK = qw( ... ); require Exporter; *import = \&Exporter::import; } use This; use ModB; use That; ... 1;
# ModB.pm use strict; use warnings; package ModB; BEGIN { our @ISA = qw( ... ); our @EXPORT_OK = qw( ... ); require Exporter; *import = \&Exporter::import; } use This; use ModA; use That; ... 1;

Replies are listed 'Best First'.
Re^2: EXPORT_OKed function refusing to import
by dsheroh (Monsignor) on Feb 06, 2007 at 20:40 UTC
    Hmmm... Very interesting. I was under the impression that all the BEGIN blocks would run first, unconditionally, so it wouldn't matter where they were placed in the source file, but moving them to before my use lines seems to have cleared this right up. Thanks!
      use Foo qw( bar );

      is a shortcut for

      BEGIN { require Foo; Foo->import(qw( bar )); }