martinvi has asked for the wisdom of the Perl Monks concerning the following question:
I've a lot of small scripts working with databases. I like to initialize those scripts from an INI-file using the BEGIN-block of my scripts:
BEGIN { my ( $IniFile, $SectionName, $IniConfig, @ParamNames, $ParamName, $IniValue ); $IniFile = "RefPin.ini"; $SectionName = "DbAttr"; $IniConfig = new Config::IniFiles ( -file => "$IniFile", -default => "$SectionName" ); @ParamNames = $IniConfig->Parameters($SectionName); foreach $ParamName (@ParamNames) { $IniValue = $IniConfig->val($SectionName, $ParamName); $DbAttr{$ParamName} = $IniValue; } }
That code work, so my quest for knowledge involves just the question: Smart? Silly? Outright braindead?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Initializing a script from an INI-file using BEGIN-block
by Taulmarill (Deacon) on Mar 01, 2005 at 10:52 UTC | |
|
Re: Initializing a script from an INI-file using BEGIN-block
by halley (Prior) on Mar 01, 2005 at 15:17 UTC | |
by martinvi (Monk) on Mar 04, 2005 at 10:31 UTC |