spawned345 has asked for the wisdom of the Perl Monks concerning the following question:
I'm getting the following error while trying to print the value in the following code for the below xml. I have similar scripts working w/o issue, but can't figure this one out. Any assistance would be appreciated.
XML:
<response_xml> <exec_command> <command> show resource usage context brn0ace01 </command> <status code="100" text="XML_CMD_SUCCESS"/> <xml_show_result> <xml_show_resource_usage> <ru_entry> <ru_resource>bandwidth </ru_resource> <ru_current> 2744</ru_current> </ru_entry> <ru_entry> <ru_resource>conn </ru_resource> <ru_current> 500</ru_current> </ru_entry> </xml_show_resource_usage> </xml_show_result> </exec_command> </response_xml>
Script:
use XML::Simple qw(:strict); my $xml = XMLin($tmpfile, ForceArray => 0, SuppressEmpty => 1, KeyAttr + => 'ru_resource' ); my $bandwidth = $xml->{exec_command}->{xml_show_result}->{xml_show_re +source_usage}->{ru_entry}->{bandwidth}->{ru_current}; print $bandwidth;
I get "Use of uninitialized value in print" and don't know why.
The following is the output of Dumper:
$VAR1 = { 'exec_command' => { 'xml_show_result' => { 'xml_show_resource_us +age' => { + 'ru_entry' => { + 'conn ' => { + 'ru_current' => ' 500 +' + }, + 'bandwidth ' => { + 'ru_current' => ' + 2744' + } + } + } }, 'status' => { 'text' => 'XML_CMD_SUCCESS', 'code' => '100' }, 'command' => ' show resource usage context brn0ace01 ' } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issue with using XML::Simple
by toolic (Bishop) on Jul 07, 2011 at 17:01 UTC | |
by spawned345 (Initiate) on Jul 07, 2011 at 17:21 UTC |