I came upon the need to ensure that the keys for values slurped into a nested hash via XML::Simple reading an XML config file matched what I was referring to them as in my script. After playing around with various Tie::* modules I decided it was just easier for me to force the entire nested hash into one or the other case for my access. The following was the outcome of my trials:
Note that duplicate name keys with differing case will be squashed.
Now this hash:
$nestedhash = {
'REJECTED' => 'REJECTED',
'FREQUENCY' => 'FREQUENCY',
'INCOMING' => {
'DIR' => 'DIR'
},
'CONNECTIONSTRING' => 'CONNECTIONSTRING',
'REGEX' => 'REGEX',
'EMAIL' => {
'GENERAL' => 'GENERAL',
'CRITICAL' => 'CRITICAL',
'SMTPSERVER' => 'SMTPSERVER'
},
'DIR' => ['DIR1', 'DIR2']
};
becomes this:
$VAR1 = {
'incoming' => {
'dir' => 'DIR'
},
'frequency' => 'FREQUENCY',
'regex' => 'REGEX',
'rejected' => 'REJECTED',
'dir' => [
'DIR1',
'DIR2'
],
'connectionstring' => 'CONNECTIONSTRING',
'email' => {
'general' => 'GENERAL',
'critical' => 'CRITICAL',
'smtpserver' => 'SMTPSERVER'
}
};
Update: Good eye,
blakem, I never had occasion to run my hash through twice, but the added check fixes that problem.