in reply to Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval

Is it feasible to output the Excel data in a known structured format, such as XML? That would open up the world of XML::XPath where you could query the XML-formatted data ... in effect letting something else (namely, XPath) do the dirty-work of pulling out the data you need.

The “model file” would not need to be the same format. If it consists of a series of lines containing “cell-address, and what should be in it,”then your code could work by constructing an XPath-string, letting XPath dredge the file for that piece of data, compare it, and move on.

“The model file” is the part that you can easily control; the student's homework is the Great Unknown. But if the complexity were hidden from view (XPath is very good at what it does, and XPath expressions are very powerful), the complexity of your program would be reduced by at-least half. I'd call that “a win.”

Replies are listed 'Best First'.
Re^2: Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval
by polypompholyx (Chaplain) on Feb 29, 2008 at 20:21 UTC
    Pulling the data out of Excel isn't too difficult (Win32::OLE), it's the parsing of the model file that's the problem. The model file, in its simplest form, is exactly what you say: a list of cells and what should be in them, in terms of strings, calculations, etc. I leverage Perl's regexes to grade things like graph axis titles - as you guessed, there's a hideous number of ways for them to write µmol min−1 mg−1, which makes me ache for the /x modifier. Using <perl_quotelike> seemed like an easy way out for both strings and regexes, but it looks increasingly like it'd be better to hand-roll something more limited.