turbodizik has asked for the wisdom of the Perl Monks concerning the following question:
My xml file looks like:use XML::Simple qw(:strict); $config = XMLin('config.xml', KeyAttr => {item=>'filename'}, ForceArra +y => ['item']);
<?xml version="1.0" encoding="UTF-8"?> <config> <item> <id>0</id> <filename>AMEX</filename> <destination_dir>test</destination_dir> </item> <item> <id>1</id> <filename>bla</filename> <destination_dir>test1</destination_dir> </item> <item> <id>2</id> <filename>alb</filename> <destination_dir>test2</destination_dir> </item> </config>
for (my $i = 0; $i < $theNumberOfItems; $i++) { print $config->{item}[$i]->{destination_dir}; }
for (my $i = 0; $i < $theNumberOfItems; $i++) { print $config->{item}{$i}->{destination_dir}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I access values in a hash by two different keys?
by hdb (Monsignor) on Jul 19, 2013 at 08:51 UTC | |
by turbodizik (Initiate) on Jul 19, 2013 at 09:12 UTC | |
by hdb (Monsignor) on Jul 19, 2013 at 09:22 UTC | |
by turbodizik (Initiate) on Jul 19, 2013 at 09:45 UTC | |
|
Re: How do I access values in a hash by two different keys?
by kcott (Archbishop) on Jul 19, 2013 at 10:01 UTC | |
|
Re: How do I access values in a hash by two different keys?
by Loops (Curate) on Jul 19, 2013 at 08:50 UTC | |
|
Re: How do I access values in a hash by two different keys? (XML DOM)
by Anonymous Monk on Jul 19, 2013 at 09:32 UTC |