If time is of the essence, why not utilise the depth of knowledge already in CPAN e.g. Parse::RecDescent, or has this become a problem that you now have to solve for yourself ?
Just a(nother:-) thought ...
A user level that continues to overstate my experience :-))