Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Monks,
I'm trying to map a list of tags in xml into an array in perl. At the moment i have:
XML:
<Players> <PlayerA>Name_A</PlayerA> <PlayerB>Name_B</PlayerB> ... <PlayerN>Name_N</PlayerN> <Players>
Perl:
use XML::Simple; use Text::Iconv; my $iconv; my $xmlconf = XMLin("players.xml"); my $players = $iconv->convert($xmlconf->{Players}); my $player = 'J'; my @players_list = \$players; foreach my $play (@players_list) { if($play eq $player) { print "Player found"; last; } }
However, I'm getting an error saying that Hash cannot be used a array while strict refs are in use.
Is there any other way to convert the map of hash to array?
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Map multiple xml tags to array
by AppleFritter (Vicar) on Aug 14, 2014 at 11:30 UTC | |
by Anonymous Monk on Aug 14, 2014 at 13:09 UTC | |
by soonix (Chancellor) on Aug 14, 2014 at 13:47 UTC | |
by GotToBTru (Prior) on Aug 14, 2014 at 13:31 UTC | |
Re: Map multiple xml tags to array
by scorpio17 (Canon) on Aug 14, 2014 at 13:46 UTC | |
Re: Map multiple xml tags to array
by Monk::Thomas (Friar) on Aug 14, 2014 at 12:14 UTC | |
by Anonymous Monk on Aug 15, 2014 at 11:17 UTC | |
by Jenda (Abbot) on Aug 15, 2014 at 19:31 UTC |