in reply to Perl with XML

Is there any reason you're using your own code rather than standard CPAN XML modules? XML::Parser is good for creating flexible XML parsing code, and XML::Simple is great if you want to convert XML into Perl data structures.

To answer your questions:

1. It's always a good idea to pass data rather than referring to it directly to reduce the number of global variables. This makes your code more scalable.

2. You're missing a / from the closing divriskgrade tag. Why have you offered a hint, though? Can you already answer this question? If so, why ask it? If you were to use standard XML modules, they would report where the error occurs.

3. 4. & 5. Why can't you answer these questions yourself? Run the code and find out! For question 5, though, you'd be much better off using CPAN modules such as HTML::Parser instead of writing your own HTML parsing code which is liable to failure.

As for good Web sites that discuss Perl and XML, search Google for perl xml or learn how to find information on Perl Monks. Super Search is very useful. Tutorials and Module Reviews contain information that will help you with XML parsing.

If you're not sure why writing your own parsing code is a bad idea, take a look at Re: Parsing HTML and (tye)Re: parsing HTML.

Update: We've been discussing this thread on the CB, and several monks let me know they have downvoted this post because it answers a homework question. I've considered editing my response to question 2, but the questioner has probably read it by now, and the response might help someone else. Overall, I think my answers were vague enough to make the questioner think, and might be useful to others.