After fixing up your sample data (it's missing a closing bracket & brace) and shortening it, your code runs fine:
my $data = { 'PairedDevices' => [ { 'PairName' => 'Chestnut', 'MetricSeverity' => '34', 'MinPercent' => '20', 'HostOwningGroup' => 'AIX Team', 'StatusAlertThisPair' => 'Y', 'StatusSeverity' => '31', 'HostedEnvironment' => 'Test', 'MetricAlertThisPair' => 'Y', 'MaxPercent' => '80', 'HostedApplication' => 'IEOR', 'HostOS' => 'AIX' } ] }; foreach my $e (@{$data->{PairedDevices}}) { print "Pairname is: " . $e->{PairName} . "\n "; print "Hosted Apps are: " . $e->{HostedApplication} . "\n" ; print "HostOS is: " . $e->{HostOS} . "\n"; }
Output:
Pairname is: Chestnut Hosted Apps are: IEOR HostOS is: AIX
You don't really want to comment out use strict. Really, you don't. Removing strict doesn't fix problems, it just hides them. The problems lurk, hidden, until the time you least want them to reappear.
In reply to Re: Accessing 2nd level elements in XML::Simple and using the data in an SNMP call
by FunkyMonk
in thread Accessing 2nd level elements in XML::Simple and using the data in an SNMP call
by wruehl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |