dsheroh has asked for the wisdom of the Perl Monks concerning the following question:
every time I used this code. So, naturally, I thought, I'd just re-export those from the core:use Base::Module; Base::Module::Config->import(qw( %conf ));
This comes deceptively close to working, but I'm seeing some users of Base::Module getting one %conf and others getting a different %conf. I suspect that it's related to whether they import it usingpackage Base::Module; use strict; use warnings; sub config_module { "Base::Module::Config" } use base 'Exporter'; BEGIN { our @EXPORT_OK = qw( &%conf ); eval 'require ' . config_module; no strict 'refs'; no warnings 'once'; *conf = \%{config_module . '::conf'}; }
oruse Base::Module qw( %conf );
but I'm not positive. It could also be the distinction between being used in the final program (first form) vs. being used by other modules which are a part of this structure (second form).sub base_module { "Base::Module" } BEGIN { eval 'require ' . base_module; base_module()->import(qw( %conf )); }
In any case, what would be the correct (or at least a fully-working) way to accomplish this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re-exporting dynamically-included variables
by tilly (Archbishop) on Jan 09, 2009 at 23:51 UTC | |
by dsheroh (Monsignor) on Jan 10, 2009 at 00:05 UTC | |
by tilly (Archbishop) on Jan 10, 2009 at 00:14 UTC | |
by dsheroh (Monsignor) on Jan 10, 2009 at 00:51 UTC |