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.

#!/usr/bin/perl

# 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
<Productlist>
        <Product>
                <PN>7045</PN>
                <Description>75C200BA3 3/4-10 X 2 A325 STRUCTURAL BOLT PLAIN</Description>
                <BuyLine>BA3</BuyLine>
                <Code>75C200BA3</Code>
        </Product>
        <Product>
                <PN>7046</PN>
                <Description>50C200BA3 1/2-10 X 2 A325 STRUCTURAL BOLT PLAIN</Description>
                <BuyLine>BA3</BuyLine>
                <Code>50C200BA3</Code>
        </Product>
        <Product>
                <PN>7047</PN>
                <Description>25C200BA3 1/4-10 X 2 A325 STRUCTURAL BOLT PLAIN</Description>
                <BuyLine>BA3</BuyLine>
                <Code>25C200BA3</Code>
        </Product>
</Productlist>
LVL 9
jmac44Asked:
Who is Participating?
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.

ozoCommented:
When I run that code, it prints
75C200BA3 3/4-10 X 2 A325 STRUCTURAL BOLT PLAIN
What do you get if you dump $prodlist?
0

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'
                       }
                     ]
        };
0
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
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.