http://www.perlmonks.org?node_id=944058

petr999 has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have a kind of a backup solution that requires parsing for certain case (mysql insert statement).

Currently this is implemented with Parse::RecDescent as it took me some while to get feet wet with its grammars. But the parser seems to be the performance bottleneck so recently I decided to try the brand new Marpa::XS and it cracked my nut head to make it work for me.

I am still very sure it should be the right tool for the case but just see no any (simple) explanation on how to turn the single line of input into the data structure ( arrayref of arrayrefs ). E. g.,:

INSERT INTO `tehtable` ( `field00`, `field01` ) VALUES ( 123, `abcd\'e +fgh` );
into arrayref like this:
[ [ qw/field00 field01/ ], [ 123, 'abcd\'efgh' ] ]

I can see the Marpa::HTML code but it's not that explanarory yet to me since it's about much more complicated than what I need, e. g. it does use that mysterious BNF stuff that I'm very unsure I will need for that particular task.

Marpa's 'Calculator' example isn't useful for me neither because it takes input token by token. Does it mean to me that I need to split my INSERT statement by myself for Marpa's input?

I have also tried with SQL::Translator but it seems to parse only the database schemas, e. g., CREATE TABLE only. Am I wrong on that?

Thank you.