impossiblerobot has asked for the wisdom of the Perl Monks concerning the following question:
My intent is to be able to use the module as follows:package SiteConfig; use strict; use XML::Simple; BEGIN { use vars qw( @configs ); @configs = qw( site search survey editor ); } use vars qw( @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT ); require Exporter; @ISA = qw(Exporter); %EXPORT_TAGS = ( ); @EXPORT = qw( ); @EXPORT_OK = map ('%'.$_, @configs2); # Config Starts Here use vars map ('%'.$_, @configs2); # Import config files %site = %{ XMLin('./site.xml') }; %search = %{ XMLin('./search.xml') }; %survey = %{ XMLin('./survey.xml') }; %editor = %{ XMLin('./editor.xml') }; 1;
importing in only the config hashes I need for that app. My first (and most important) question is: how do I do the final import section without explicitly listing each hash, and without using symbolic refs?use SiteConfig qw( %site %search );
but I also know that in most cases that is a taboo. Is there an alternative that will allow me to keep my clean and simple interface without resorting to evil?no strict; for (@configs) { %{$_} = %{ XMLin("./$_.xml") }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Another config file module (any alternative to symbolic refs?)
by tye (Sage) on Oct 30, 2001 at 22:15 UTC | |
|
Re (tilly) 1: Another config file module (any alternative to symbolic refs?)
by tilly (Archbishop) on Oct 30, 2001 at 22:17 UTC | |
|
Re: Another config file module (any alternative to symbolic refs?)
by doc (Scribe) on Oct 30, 2001 at 22:28 UTC | |
|
Okay, I'll bite:
by perrin (Chancellor) on Oct 30, 2001 at 23:32 UTC | |
|
Re: Another config file module (any alternative to symbolic refs?)
by impossiblerobot (Deacon) on Oct 30, 2001 at 23:56 UTC |