sriram83.life has asked for the wisdom of the Perl Monks concerning the following question:
I am sending this hash reference $packagehash to a function which generates my desired xml file. I call the function as$packagehash = { ' IBM Tivoli Runtime Security Services Client ' => { 'Publis +her' => 'IBM', 'Versio +n' => ' 7.1.0.2 ', 'Produc +tCode' => ' com.ibm.rtss.client', 'Produc +tName' => ' IBM Tivoli Runtime Security Services Client ' }, ' IBM Tivoli Runtime Security Services Software Development +Kit ' => { + 'Publisher' => 'IBM', + 'Version' => ' 7.1.0.2 ', + 'ProductCode' => ' com.ibm.rtss.sdk', + 'ProductName' => ' IBM Tivoli Runtime Security Services So +ftware Development Kit ' + }, ' IBM Tivoli Runtime Security Services Server ' => { 'Publis +her' => 'IBM', 'Versio +n' => ' 7.1.0.2 ', 'Produc +tCode' => ' com.ibm.rtss.server', 'Produc +tName' => ' IBM Tivoli Runtime Security Services Server ' } };
My logic in the function to retrieve inner hash key values i.e 'ProductName','ProductCode','Version' and 'Publisher' is not working.Output is blank. Here is the code i wrote:&getxml($packagehash);
When i print just $key, it prints outer hash keys,which is correct i.e productnames.But,if i want to extract their corresponding inner hash key and values,Output is showing blank.Please help me where i am making mistake.sub getxml($) { my $hashref = shift; foreach my $key ( keys %${hashref} ){ print $key->{'ProductName'} print $key->{'ProductCode'} print $key->{'Publisher'} ...xml logic... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting HOH to a XML not working
by kcott (Archbishop) on Mar 14, 2014 at 19:01 UTC | |
|
Re: Converting HOH to a XML not working
by toolic (Bishop) on Mar 14, 2014 at 18:25 UTC | |
by sriram83.life (Acolyte) on Mar 14, 2014 at 18:40 UTC | |
|
Re: Converting HOH to a XML not working
by clueless newbie (Curate) on Mar 14, 2014 at 18:35 UTC | |
by sriram83.life (Acolyte) on Mar 14, 2014 at 18:44 UTC | |
|
Re: Converting HOH to a XML not working
by hazylife (Monk) on Mar 14, 2014 at 18:27 UTC |