in reply to Accessing 2nd level elements in XML::Simple and using the data in an SNMP call
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing 2nd level elements in XML::Simple and using the data in an SNMP call
by wruehl (Acolyte) on Jul 31, 2007 at 13:05 UTC | |
by radiantmatrix (Parson) on Jul 31, 2007 at 14:01 UTC | |
by wruehl (Acolyte) on Jul 31, 2007 at 17:03 UTC |