PerlScholar has asked for the wisdom of the Perl Monks concerning the following question:
Hi All, need some help looping through a hash structure generated by XML::Simple config. So far this is what I have:
use strict; use XML::Simple; use Data::Dumper; my $config = XMLin('config.xml'); print Dumper($config); for my $record (@{my $VAR1->{Application}}) { my $environment = $record->{Environment}->{Name}; my $region = $record->{Environment}->{Region}->{Name}; my $Idrive = $record->{Environment}->{Region}->{Idrive}; my $Zdrive = $record->{Environment}->{Region}->{Zdrive}; print "$environment"; print "$region"; print "$Idrive"; print "$Zdrive"; }
$VAR1 = { 'Application' => { 'Environment' => [ { 'Region' => [ { 'Zdrive' => ' +\\\\otherpath', 'Idrive' => ' +\\\\somepath', 'Name' => 'LN +' }, { 'Zdrive' => ' +\\\\otherpath', 'Idrive' => ' +\\\\somepath', 'Name' => 'NY +' } ], 'Name' => 'A' }, { 'Region' => [ { 'Zdrive' => ' +\\\\otherpath', 'Idrive' => ' +\\\\somepath', 'Name' => 'LN +' }, { 'Zdrive' => ' +otherpath', 'Idrive' => ' +\\\\somepath', 'Name' => 'NY +' } ], 'Name' => 'B' } ], 'Name' => 'App1' } };
20100908 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loop through hash structure
by planetscape (Chancellor) on Sep 06, 2010 at 11:18 UTC | |
by ikegami (Patriarch) on Sep 06, 2010 at 16:57 UTC | |
|
Re: Loop through hash structure
by psini (Deacon) on Sep 06, 2010 at 10:36 UTC | |
by ikegami (Patriarch) on Sep 06, 2010 at 16:54 UTC | |
by psini (Deacon) on Sep 06, 2010 at 17:36 UTC | |
|
Re: Loop through hash structure
by roboticus (Chancellor) on Sep 06, 2010 at 10:32 UTC | |
|
Re: Loop through hash structure
by dasgar (Priest) on Sep 06, 2010 at 16:09 UTC | |
by PerlScholar (Acolyte) on Sep 08, 2010 at 15:16 UTC | |
|
Re: Loop through hash structure
by nvivek (Vicar) on Sep 07, 2010 at 05:28 UTC | |
by PerlScholar (Acolyte) on Sep 07, 2010 at 11:43 UTC | |
by Corion (Patriarch) on Sep 07, 2010 at 13:21 UTC | |
by PerlScholar (Acolyte) on Sep 08, 2010 at 13:14 UTC | |
by Corion (Patriarch) on Sep 08, 2010 at 13:22 UTC |