cosmicperl has asked for the wisdom of the Perl Monks concerning the following question:
So If I included another variable file later it would just replace and doubling up of variables which I what I want:-$::Config->{group1}->{opt1} = 'A'; $::Config->{group1}->{opt2} = 'B'; $::Config->{group1}->{opt3} = 'C'; $::Config->{group2}->{opt1} = 'D';
The problem is now that I'm using data dumper, the variables files are looking like:-$::Config->{group1}->{opt3} = 'C2'; $::Config->{group2}->{opt2} = 'E';
And:-$::Config = { group1 => { opt1 => 'A', opt2 => 'B', opt3 => 'C', }, group2 => { opt1 => 'D', }, };
So if I load the second file after the first it's loosing data rather than updating the hash it's replacing it.$::Config = { group1 => { opt3 => 'C2', }, group2 => { opt1 => 'E', }, };
A) Get Data::Dumper to dump in the old format, problem is that after looking at the examples I can't see a way of doing this. So it could mean dropping Data::Dumper and writing my own dumper...Is there a simpler solution that I'm missing?
B) Rename the first config hash then merge it with the new one using Hash::Merge. Problem with this is that it's going to be way less efficient and slower than a).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Last hurdle.. Merge hash refs or change data dump?
by moritz (Cardinal) on Apr 16, 2008 at 13:04 UTC | |
by cosmicperl (Chaplain) on Apr 16, 2008 at 13:26 UTC | |
by moritz (Cardinal) on Apr 16, 2008 at 13:35 UTC | |
by cosmicperl (Chaplain) on Apr 16, 2008 at 13:48 UTC | |
by chromatic (Archbishop) on Apr 16, 2008 at 16:43 UTC |