Ask a Question related to PERL Beginners, Design and Development.
-
Henq #1
config file: a) what Module ? b) conditionals in config (for multiple hosts)
Hi,
a) I am looking for a module to handle config files. There are a number of
these modules, like AppCconig. Any consensus about The Right Module for
this?
b) As I develop one one machine and test/deploy on another, I want
constructs in my config file like:
if (`hostname` eq 'dev_box') {
mysql_dsn = 'foobar';
} elsif ((`hostname` eq 'test_box'}
mysql_dsn = 'abracadabra';
...
Any support for that in your module of choice?
I know of the use-just-perl-code approach (with 'do') in the Perl Cookbook,
but I am wondering if new insights exist.
TIA
~henq
Henq Guest
-
j2ee config and virtual hosts
I'm attempting to use the j2ee configuration of mx7 and am having difficulty determining how I can setup virtual hosts. I am using tomcat and can... -
Noob Q: Ways for module to find config file?
What are the techniques for a module to find its config file? It's a chicken/egg problem, since the location of the config file is itself a... -
Req advice on new module to be uploaded: Config::Magic?
Hello, I'm new to developing perl modules for CPAN, but I just finished a lot of work on something I think others will find useful. Basically,... -
Error loading XML file c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config
I had many ASP.NET web applications that I created before I had to rebuild my machine. After a fresh install of XP Pro, VS.NET 2003, etc, I now... -
[RCR] Include CONFIG::Config['rubydocdir'] in rbconfig.rb
Hi folks, I apologise if people have read this RCR and are not interested, but this is what I consider to be an important RCR, not a merely... -
Wiggins D Anconia #2
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
Whichever module gets the job done the way you want it. I have used> Hi,
>
> a) I am looking for a module to handle config files. There are a number of
> these modules, like AppCconig. Any consensus about The Right Module for
> this?
>
AppConfig with some success but it fails to handle overly complex
structures (not its claim to fame either) some people (read: myself)
have come to expect in a config file so I switched to using XML::Simple
for more complex tasks. Since I started out in the web world that
transition was obviously easy for me. I have found in general the
module that is chosen is based more on the format of the config file,
which is usually left up to the person editing it and how comfortable
they are with doing so, or whether there will be an interface to editing
it. If the config file changes a lot and non-developers will edit it go
with something simple like AppConfig because it is relatively powerful
without complex layout restrictions, if the config file changes in
frequently, is updated by knowledgeable users, and/or has an interface
for making updates then go with a module that is easily written back out
and allows for arbitrarily complex data structures....
Cookbook,>
> b) As I develop one one machine and test/deploy on another, I want
> constructs in my config file like:
>
> if (`hostname` eq 'dev_box') {
> mysql_dsn = 'foobar';
> } elsif ((`hostname` eq 'test_box'}
> mysql_dsn = 'abracadabra';
> ...
>
> Any support for that in your module of choice?
>
> I know of the use-just-perl-code approach (with 'do') in the PerlNot that I know of, that is a rather complex deal, where is hostname? is> but I am wondering if new insights exist.
>
it in the path? what about machines that may not supply it? If you
want a dev/q-a/prod set of config files i have found it more appropriate
to use the same structure in a set of 3 different config files, then
migrate the unique config files to each of the environments. Granted
when you change the structure you have to update 3 copies, but it
simplifies the programming, which *should* be the expensive part.
Just my $.02,
[url]http://danconia.org[/url]
Wiggins D Anconia Guest
-
Jenda Krynicky #3
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
From: "Wiggins d Anconia" <wiggins@danconia.org>
To simplify this you may consider using two configs. One "global"> Cookbook,> > b) As I develop one one machine and test/deploy on another, I want
> > constructs in my config file like:
> >
> > if (`hostname` eq 'dev_box') {
> > mysql_dsn = 'foobar';
> > } elsif ((`hostname` eq 'test_box'}
> > mysql_dsn = 'abracadabra';
> > ...
> >
> > Any support for that in your module of choice?
> >
> > I know of the use-just-perl-code approach (with 'do') in the Perl>> > but I am wondering if new insights exist.
> >
> Not that I know of, that is a rather complex deal, where is hostname?
> is it in the path? what about machines that may not supply it? If
> you want a dev/q-a/prod set of config files i have found it more
> appropriate to use the same structure in a set of 3 different config
> files, then migrate the unique config files to each of the
> environments. Granted when you change the structure you have to update
> 3 copies, but it simplifies the programming, which *should* be the
> expensive part.
that contains the settings that are the same everywhere (which will
probably be most of them) and one "local" that will contain the
specialties. And then read both the configs and merge them so that
the "local" overwrites the "global".
That was if you need to make the same change to all machines you can
do it in the "global" config and then just copy the file.
Jenda
===== [email]Jenda@Krynicky.cz[/email] === [url]http://Jenda.Krynicky.cz[/url] =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Jenda Krynicky Guest
-
Henq #4
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
"Wiggins D Anconia" <wiggins@danconia.org> schreef in bericht
news:200310301436.h9UEaDq18612@residualselfimage.c om...> I have found in general the> > Hi,
> module that is chosen is based more on the format of the config file,
YAML is a rising star as formats go, I believe.
it's a system command (back ticks).> > where is hostname? is
Henq Guest
-
Henq #5
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
"Jenda Krynicky" <Jenda@Krynicky.cz> schreef in bericht
news:3FA1332B.19987.48CF3554@localhost...> From: "Wiggins d Anconia" <wiggins@danconia.org>> To simplify this you may consider using two configs. One "global"
> that contains the settings that are the same everywhere (which will
> probably be most of them) and one "local" that will contain the
> specialties. And then read both the configs and merge them so that
> the "local" overwrites the "global".
yes, that sunds like the rigtht solution. Funny, It was right under my nose
as this method is explained in the chapter of the Cookbook I mentioned...
like: my %config = {%standard, %override};
Henq Guest
-
Jenda Krynicky #6
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
From: "henq" <@onion.perl.org henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
You want ( instead of { !> "Jenda Krynicky" <Jenda@Krynicky.cz> schreef in bericht
> news:3FA1332B.19987.48CF3554@localhost...>> > From: "Wiggins d Anconia" <wiggins@danconia.org>>> > To simplify this you may consider using two configs. One "global"
> > that contains the settings that are the same everywhere (which will
> > probably be most of them) and one "local" that will contain the
> > specialties. And then read both the configs and merge them so that
> > the "local" overwrites the "global".
> yes, that sunds like the rigtht solution. Funny, It was right under my
> nose as this method is explained in the chapter of the Cookbook I
> mentioned...
>
> like: my %config = {%standard, %override};
Jenda
===== [email]Jenda@Krynicky.cz[/email] === [url]http://Jenda.Krynicky.cz[/url] =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Jenda Krynicky Guest
-
Wiggins D Anconia #7
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
You missed the point, *I* know what 'hostname' is, but you restrict>
> "Wiggins D Anconia" <wiggins@danconia.org> schreef in bericht
> news:200310301436.h9UEaDq18612@residualselfimage.c om...>> > I have found in general the> > > Hi,
> > module that is chosen is based more on the format of the config file,
>
> YAML is a rising star as formats go, I believe.
>
>
>
>>> > > where is hostname? is
> it's a system command (back ticks).
>
yourself to platforms and environments that have it defined and open
yourself to security issues by attempting to use it in the manner you
stated.
On my RH 9.0 box hostname is in, /bin, on solaris 8 it is in /usr/bin,
other systems could put it in any of /usr/local/bin, /opt/bin,
/usr/sbin, /sbin, /my/really/long/weird/location/bin, etc., who knows if
windows even has 'hostname' and where it would be.... ok so you depend
on it being in the path, is the path setup correctly? what happens when
you put it in cron? how about under a chroot? What happens when someone
throws, ~/bin in their path and wants to have a 'hostname' command that
logs into their NAT box and updates an IP address, ok they chose a dumb
name, but your script is now broke......
[url]http://danconia.org[/url]
Wiggins D Anconia Guest



Reply With Quote

