This is covered in the XML::Simple FAQ. The cause of the problem is that you're treating an arrayref as if it was a hashref (as gjb pointed out).
There are a few more things worthy of consideration and I'd recommend you take a look at Does your XML::Simple code pass the strict test? for more complete coverage. But in brief:
- you are not setting a value for the keyattr option (if you don't know what it does, set keyattr => [])
- you are turning off forcearray which is a bad idea for two reasons:
- your code will break if you only have one <item>
- enabling array folding (which you're doing by letting keyattr default) is inherently incompatible with disabling forcearray
- your <item> elements have an 'item_name' attribute where 'name' might be a more natural choice - I'm guessing you tried using name but "weird stuff happened" (because you didn't set keyattr to disable array folding)
The 'strict mode' link above has more detail.