It should be fairly easy to write a script to do what you want. For example, to collect the questions, I'd probably use an array @exertext, read the file line by line concatening as the lines are read; each time \begin{exertext} is matched, I'd start a new array element, and each time \end{exertext} is matched, I'd stop concatenating. Then, I could remove the 2 tags from the array element if I wished (but maybe they should be saved.) You can do the same for the solutions or answers. The only time you might have a problem is if, for example, \end{exertext} and \begin{soln} occur on the same line, but maybe that doesn't occur. So each exercise would be a new array element. Then you can easily print them to a new file (maybe with numbering or other formatting.) I've done things very similar many many times and rolled my own script. Sometimes something won't be quite right, and you have to make a small change to correct things, but that's in the nature of coding.
I don't know of a convenient module to use, but if there is one, I'm sure you'll get the info in a reply soon.
chas
(Update: If the file is formatted in a very disorganized way, it becomes more difficult to extract the data, but that doesn't seem to be the case in the example you gave. Using a module is fine if there is an appropriate one, but sometimes it can take a while to install and understand, while a handrolled script might be written in 20 minutes. Also fixed an error.)

In reply to Re: Parsing Exercise set by chas
in thread Parsing Exercise set by David Arnold

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.