Perl script to parse xml file

I have a perl script that I want to find the part number (PN) in an xml file and display the Description but when I run it doesn't display anything. see Script and xml file below.


# Script to parse a simple XML file and pick out a particular element, in this case, the
# description of the product with the PN '7045'.

use strict;
use XML::Simple;

my $prodlist = XMLin('ProductList.xml', KeyAttr => {Product => 'PN'});

print $prodlist->{Product}->{7045}->{Description} . "\n";


xml file: - PorductList.xml
                <Description>75C200BA3 3/4-10 X 2 A325 STRUCTURAL BOLT PLAIN</Description>
                <Description>50C200BA3 1/2-10 X 2 A325 STRUCTURAL BOLT PLAIN</Description>
                <Description>25C200BA3 1/4-10 X 2 A325 STRUCTURAL BOLT PLAIN</Description>
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

When I run that code, it prints
What do you get if you dump $prodlist?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmac44Author Commented:
Well that's weird. I ran the script this morning and it works. I must have a buggy debian install. To answer your question I get the entire output of the xml file. See below. Thanks for checking out the script. It looks like I wasted your time but at least you get 500 points! :)
$VAR1 = {
          'Product' => [
                         'Code' => '75C200BA3',
                         'PN' => '7045',
                         'BuyLine' => 'BA3',
                         'Description' => '75C200BA3 3/4-10 X 2 A325 STRUCTURAL BOLT PLAIN'
                         'Description' => '50C200BA3 1/2-10 X 2 A325 STRUCTURAL BOLT PLAIN',
                         'PN' => '7046',
                         'BuyLine' => 'BA3',
                         'Code' => '50C200BA3'
                         'PN' => '7047',
                         'BuyLine' => 'BA3',
                         'Description' => '25C200BA3 1/4-10 X 2 A325 STRUCTURAL BOLT PLAIN',
                         'Code' => '25C200BA3'
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.