G
Gupit
Hi,
I have a configuration file which is in a perl hash (of hashes and
arrays) format.
$hash = {
key1 => { key2 => val2,
key3 => val3,
},
key4 => [ vala,valb,],
key1 => {key5 => val5,
key6 => val6
),
};
In my script I do
use vars ($hash);
if (eval "require config_file") {
print "Required config_file";
} else {
print "Couldn't require config_file\n";
}
Now if you notice in the config_file, $hash has two duplicate keys
i.e. key1 has been specified twice. When using require, perl simply
keeps the last value it encountered for key1.
I would like to detect these duplicates. Is there a stricter mode in
perl that will print warnings when perl encounters duplicate keys in
hashes. I could turn it on for the eval require bit.
Is there any other way to detect these duplicates? Unfortunately the
config_file is really huge and uses hash of hashes of hashes and
arrays and so on and writing a script to parse the file would be
painful.
Thanks in advance
G
I have a configuration file which is in a perl hash (of hashes and
arrays) format.
$hash = {
key1 => { key2 => val2,
key3 => val3,
},
key4 => [ vala,valb,],
key1 => {key5 => val5,
key6 => val6
),
};
In my script I do
use vars ($hash);
if (eval "require config_file") {
print "Required config_file";
} else {
print "Couldn't require config_file\n";
}
Now if you notice in the config_file, $hash has two duplicate keys
i.e. key1 has been specified twice. When using require, perl simply
keeps the last value it encountered for key1.
I would like to detect these duplicates. Is there a stricter mode in
perl that will print warnings when perl encounters duplicate keys in
hashes. I could turn it on for the eval require bit.
Is there any other way to detect these duplicates? Unfortunately the
config_file is really huge and uses hash of hashes of hashes and
arrays and so on and writing a script to parse the file would be
painful.
Thanks in advance
G