Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PERL TUTORIALS > THE ROAD TO BETTER PROGRAMMING: CHAPTER 7. TOP LEVEL CONTROL FLOW


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

The road to better programming: Chapter 7. Top-level control flow
By Teodor Zlatanov - 2004-03-15 Page:  1 2 3 4 5

Top-level control flow and configuration

Perl expert Ted Zlatanov continues his top-down development of the cfperl project, a cfengine interpreter written in Perl, starting with the control flow and configuration handling.

This chapter is from Ted's book, At the Helm, being published serially on the Web in the developerWorks column The road to better programming. Catch up on Ted's earlier chapters.

In the previous installment, Chapter 6. Developing cfperl, from the beginning, we covered some of the preliminary steps of undertaking a new project, including research, choice of license, and basic architecture decisions. Having dispensed with these, I was ready to begin coding!

The first steps in writing the cfperl interpreter were to write the main loop, determine the control flow, and adopt a configuration style similar (as much as possible) to the cfengine configuration style.

Because cfperl is a small project, a top-down approach was feasible. I could keep the main loop in my head, and develop each part of the interpreter cycle sequentially. Furthermore, I documented the main loop in POD form at the end of the script, for my benefit as much as for others'.

The control flow was determined by my choice of parsing module. Using Parse::RecDescent enabled me to do a 2-level parse, first with a generic parser and then (by using section-keyed grammars) with grammars appropriate to the situation or a default grammar.



View The road to better programming: Chapter 7. Top-level control flow Discussion

Page:  1 2 3 4 5 Next Page: The main loop

First published by IBM developerWorks


Copyright 2004-2017 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.