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
In reply to Loop through hash structure by PerlScholar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |