Config-Std - Return list consistently

Posted on Tue Feb 6 23:59:09 2007 by kenm
Return list consistently
I want to replace code in a legacy application using Config::Std. The existing code uses a series of arrays, some of which could be empty. The module uses list generation for the values with more than one element, but not for those with zero or 1 element. The legacy code would have to post-process the configuration to generate the complete data structure. I'd like to avoid that.
Legacy Code:
# There are several arrays that contain the prerequisite process ids for each table # that will be loaded. @IDF = (); @ANF = ('IDF','TDF'); @CDF = ('IDF'); @CNF = ('IDF'); @CPP = (); . . .

My first stab at an INI setup:
[TablePreReq] IDF: ANF: IDF ANF: TDF CDF: IDF CNF: IDF CPP: . . .

The problem with this is that only the multi-part entries produce arrays:
DB<4> x $config{TablePreReq} 0 HASH(0x1ebd120) 'ANF' => ARRAY(0x1c6d344) 0 'IDF' 1 'TDF' 'CDF' => 'IDF' 'CNF' => 'IDF' 'CPP' => '' 'IDF' => '' . . .

What I really want is something like this
0 HASH(0x1ebd120) 'ANF' => ARRAY(0x1c6d344) 0 'IDF' 1 'TDF' 'CDF' => ARRAY(0x1111111) 0 'IDF' 'CNF' => ARRAY(0x2222222) 0 'IDF' 'CPP' => ARRAY(0x3333333) empty array 'IDF' => ARRAY(0x4444444) empty array . . .

What's the best way to get this done? Thanks in advance
Write a response