laziness, impatience, and hubris | |
PerlMonks |
Re^3: XML Parsing,by graff (Chancellor) |
on Sep 09, 2009 at 23:14 UTC ( [id://794471]=note: print w/replies, xml ) | Need Help?? |
the script stops. it doesn't give an error. ...
That's odd... when I ran the OP script on the xml file in your reply, I got an error message: In my copy of the script, line 46 was this one: Apparently, when the xml file contains only one "Vehicle", the default behavior of XML::Simple is to provide you with something that is not an array reference (e.g. maybe it's a reference to a hash instead of a reference to an array of hashes). That is why moritz, in the first reply, suggested that you include the ForceArray=>1 parameter when you invoke XMLin to create your $config object, like this: When I made that change and ran it again, I didn't get the error message, and I got more output in addition to just Other Cars<br>. Anyway, as others have pointed out, there seem to be quite a few points where your code could use some improvement, and where it may even be doing things you don't intend (and/or not doing things you meant to do). Using more data structures, more loops, and better indentation will help a lot. (updated to fix a mistake in wording)
In Section
Seekers of Perl Wisdom
|
|