Current Issue


Table of contents

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 12.0

Version 12.0 delivers every issue of Sys Admin from 1992 through 2006 and every
issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!

Sys Admin Magazine > Archives > 2005 > July 2005
SysAdminMag.com

Nicer Configuration Files

Randal L. Schwartz

I see a lot of configuration file modules in the CPAN. Perhaps too many. Perhaps this is a task that (like so many others) attracts every new junior Perl programmer into the "I can do better than those" mindset.

I can't claim to have used every one, and perhaps I haven't even looked at every one. However, let me spend a bit of time talking about one that I used rather heavily on a recent project and that I am definitely liking for future projects.

One of my favorite clients is http://geekcruises.com, mostly because the typical work location for GeekCruises is aboard a cruise ship traveling between the Caribbean islands. I recently completed a major overhaul of the company's administrative interface to the "booking engine": the portion of the Web site that makes money for them by allowing random geeks to sign up for future cruises.

The core of my overhaul used the emerging standard CGI::Prototype framework, along with Template Toolkit and Class::DBI for the data model. One of the problems I face when programming is how to write each important fact in only one location, because cut-and-paste is a maintenance nightmare. I found myself wanting to record meta-information about each of the database fields (there are some 500 columns in 50 tables for this application) in a common location.

I wanted to access the information from both Perl code and Template Toolkit code, because a lot of the meta-information bridges the "model" (the precise column of that table) to the "view" (how the user sees the data and how the inputs are interpreted). I decided rather early on that I wanted to call a method named Config against a given Class::DBI table class, or a specific row instance, and that this should return a hashref of all the meta-information about this row.




MarketPlace

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.

Six Sigma Certification
100% Online-Six Sigma Certificate from Villanova - Find Out More Now.

Workflow Enabled Help Desk & IT Service Management
Automate service desk activities and integrate processes across IT. Learn more here.

Flowcharts from C/C++ code -- Free trial download
Understand C/C++ code in less time. A new team member ? Inherited legacy code ? Get up to speed faster with Crystal Flow for C/C++. Code-formatting improves readability. Flowcharts are integrated with code browser. Export flowcharts to Visio.

Wanna see your ad here?