Re: configuration package
by Cristina Bulfon other posts by this author
Oct 11 2000 4:41PM messages near this date
unsubscribe
|
Re: configuration package
Hi Diego,
thanks, but in the meanwhile I found the solution :
BEGIN {
use Exporter();
use vars qw (@ISA @EXPORT $VERSION);
$VERSION= 1.00;
@ISA = qw (Exporter);
@EXPORT = qw (@Site
@Semaphore
$ConfigDir
$BaseDir
$ReleaseDir
);
}
use vars @EXPORT;
# Define global variable
........
END {}
cristina
On Wed, 11 Oct 2000, Diego Zamboni wrote:
>
> 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
>
>
>
_____________________________________________________________________________
Cristina Bulfon E-mail Cristina.Bulfon@[...].edu
Stanford Linear Accelerator Center Phone +1-650-926-5028
PO Box 4349, M/S 88 Fax +1-650-926-3329
Stanford, CA 94309, USA
_____________________________________________________________________________
Thread:
Diego Zamboni
Chris Fryburger
Cristina Bulfon
Steve Purkis
Don Catino
|