Surely I'm doing something wrong here! There is now way a 27 line XML file can bring XML::Simple to it's knees.

When I run this code:

use strict; use warnings; use XML::Simple; my $associate = XMLin('./amazon.xml', forcearray=>0); my $books = $associate->{books}->{item}; my $cds = $associate->{cds}->{item}; my $dvds = $associate->{dvds}->{item}; my $wish = $associate->{ wish}->{item}; foreach my $books (values %$books) { print "$books->{'asin'} \n"; }

I get this error:  Out of memory!

Here is my XML file:

<associate> <books> <item item_name="Mysql and Perl for the Web" asin="0735710546" + /> <item item_name="Macromedia Flash MX: Training from the Source +" asin="0201794829" /> <item item_name="XSLT" asin="0596000537" /> <item item_name="Learning XML" asin="0596000464" /> <item item_name="Programming Perl (3rd Edition)" asin="0596000 +278" /> <item item_name="Network Programming with Perl" asin="02016157 +11" /> <item item_name="Cisco Networking Academy Program: Fundamental +s of UNIX Companion Guide" asin="1587130440" /> </books> <dvds> <item item_name="Gladiator (2000)" asin="B00003CXE7" /> <item item_name="The Princess Bride (Special Edition) (1987)" +asin="B00005LOKQ" /> <item item_name="Pi" asin="078401213X" /> </dvds> <cds> <item item_name="OK Computer (Radiohead)" asin="B000002UJQ" /> <item item_name="Pablo Honey (Radiohead)" asin="B000002UR7" /> <item item_name="Parachutes (Coldplay)" asin="B0000508U6" /> <item item_name="Hatful of Hollow (The Smiths)" asin="B000002M +IF" /> </cds> <wish> <item item_name="The Usual Suspects (Special Edition) (1995)" +asin="B00005V9HH" /> <item item_name="How to Win Friends and Influence People" asin +="0671723650" /> <item item_name="ActionScript for Flash MX: The Definitive Gui +de, Second Edition " asin="059600396X" /> </wish> </associate>


Windows 2000
perl 5.6.1
XML::Simple 1.06


-Silent11

In reply to 'Out of memory!' Error with XML::Simple by silent11

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.