Smaug has asked for the wisdom of the Perl Monks concerning the following question:


I have been battling with this for two days and I now have gone in so may circles I don't know what's left to try.

I have the following XML file (This is just a small section) which is output from another system:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Import format="3.0" fileId="54630000-3141-1404-4310-7F0000014030" fil +eCreationDateTime="2012-07-23T06:04:31.415" catalogSource="TLCMz"> <Catalog> <Vendors> <Vendor name="Allen Systems" vendorUniqueKey="ALLENGRP"/> <Vendor name="Aonix North America" vendorUniqueKey="AONIX"/> <Vendor name="Beta Systems Software" vendorUniqueKey="BETASY +S"/> <Vendor name="BMC Software" vendorUniqueKey="BMC"/> </Vendors> </Catalog> </Import>

I have used XML::Simple and have reach the point where just to try get anything, I have reduced the code to:
use strict; use warnings; my $xmldoc = XMLin("C:\\dsys.xml"); print Dumper($xmldoc);

At this point all is well, but what I'd like is the values in the <Vendor> tag in a hash with the vendorUniqueKey as the key and the name as the value.
I've tried:
my $vendors = "$xmldoc->{'Catalog'}->{'Vendors'}";
Which returns a reference to the hash (I think), but I can' t seem to find a way to step through the data in the hash. When I try:
my $vendors = "$xmldoc->{'Catalog'}->{'Vendors'}"; foreach my $vendor (@{$vendors->{Vendor}}) { print $vendor->{name} . "\n"; }

I get Can't use string ("HASH(0x31d7078)") as a HASH ref while "strict refs" in use and I get similar errors if I try a host of other ways. Clearly I'm lost and don't know where to go from here. I don't even know if the data I need is in the hash or if I've completely messed it up.
Any help would be appreciated.
Peddle faster monkeys!! I need more power!!