ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-Agents
perl5-Agents
Re: configuration package
by Diego Zamboni other posts by this author
Oct 11 2000 4:27PM messages near this date
ADV: Search Engine Registration | unsubscribe
bulfon@[...].EDU said:
>  my problem is: I'd really like to naming the global array in main
>  program like @Site or @Configuration rather than "@Configuration::Site"
>   ..  I read in Perl CookBook that I have to use @EXPORT but doesn't
>  work 

You could make Configuration.pm not a package in itself, but just contain the 
corresponding variable declarations. Here's what I have done in some programs 
that require a configuration file. The file is called Config.pl, and it only 
contains the following:

#---------- start of Config.pl
%Config=(
	param1 =>  value1,
	param2 =>  value2,
	...
	);

1;
#----------- end of Config.pl

Then in the main program I do:

eval 'require "Config.pl"';
die "Error: $@" if $@;

and then I can just use $Config{param1} etc to access the configuration 
parameters. I use a hash, but you could just as well use simple variables like 
@Site, @Semaphore, etc.

Hope this helps,
--Diego
Thread:
Diego Zamboni
Chris Fryburger
Cristina Bulfon
Steve Purkis
Don Catino

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved