in reply to error from XML::Simple

Here's an example of another way to do it:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use XML::Simple qw(:strict); my $file = <DATA>; my $ref = XMLin($file, KeyAttr => {item => 'firstname'}, ForceArray => [ 'item' ], ContentKey => '-content' ); print Dumper($ref); __DATA__ <opt> <person key="jsmith" firstname="Joe" lastname="Smith" /> <person key="tsmith" firstname="Tom" lastname="Smith" /> <person key="jbloggs" firstname="Joe" lastname="Bloggs" /> </opt>