Hi all,
I've been trying to iterate thru an array of elements that's buried
within a larger Hash. The Hash was created from XML::Simple and using
Data Dumper it produces the following output:
$VAR1 = {
'directories' => {
'directory' => {
'inbound' => {
'content' => 'inbound'
},
'base' => {
'content' => '..'
},
'working' => {
'content' => 'working'
},
'logs' => {
'content' => 'logs'
}
}
},
'notifications' => {
'email-addr' => [
{
'content' =>
'[EMAIL PROTECTED]',
'type' => 'development'
},
{
'content' =>
'[EMAIL PROTECTED]',
'type' => 'business'
}
]
},
'server' => {
'sid' => 'some-database',
'pwd' => 'some-pwd',
'usr' => 'some-usr'
}
};
When I try and iterate thru the 'email-addr' array, I can't seem to get
the syntax quite correct:
<code-snip>
printf "Email Entry
[".$ltheConfig->{'notifications'}->{'email-addr'}[0]->{content}."]\n";
printf "Email Entry
[".$ltheConfig->{'notifications'}->{'email-addr'}[1]->{content}."]\n";
my $ltheEntry;
foreach $ltheEntry ($ltheConfig->{'notifications'}->{'email-addr'}) {
printf $ltheEntry;
printf $ltheEntry->{content}.":".$ltheEntry->{type};
}
</code-snip>
<console-output>
Email Entry [EMAIL PROTECTED]
Email Entry [EMAIL PROTECTED]
Pseudo-hashes are deprecated at ./test-xml.pl line 160.
Argument "\x{61}\x{64}..." isn't numeric in hash element at
./test-xml.pl line 160.
Bad index while coercing array into hash at ./test-xml.pl line 160.
ARRAY(0x101e1554)
</console-output>
What is the correct snytax in the foreach loop that will fetch me the
array @(email-addr) out of the larger Hash $ltheConfig.
thx in advance,
Adym Lincoln
I/S Corporate - I/S Internal Applications
603-245-3744
Ext : 53744
[EMAIL PROTECTED]
...
It's a bug planet!!! It's an ugly planet!!! Ever feel like your
software project is going in the wrong direction.
...
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs