Skip to Content
Mastering Perl, 2nd Edition
book

Mastering Perl, 2nd Edition

by brian d foy
January 2014
Intermediate to advanced
400 pages
9h 23m
English
O'Reilly Media, Inc.
Content preview from Mastering Perl, 2nd Edition

Chapter 10. Configuring Perl Programs

It seems that whenever I write what I think is a useless or short-term program, then show it to someone, I ultimately end up supporting a new application. People ask me to write a similar program for them or slightly modify a program for them. The change never seems to actually be slight, either.

I don’t get trapped into creating or maintaining multiple versions of a program. I can make the programs configurable, and do it so users don’t have to touch the code. Otherwise they are going to modify the code themselves and come back to me when they don’t know how to fix the syntax error from the semicolon they forgot. A little work making my program configurable saves me headaches later.

Things Not to Do

The easiest, and worst, way to configure my Perl program is simply to put a bunch of variables in it and tell people to change those values if they need different settings. The user then has to open my program and change the values to change the behavior of my program. This gives people the confidence to change other things too, despite my warning to not change anything past the configuration section. Even if those users stay within the section where I intend them to edit code, they might make a syntax error. That is, they will make syntax errors. Not only that, if they have to install this program on several machines, they’ll end up with different versions on each machine. Any change or update in the program requires them to edit every version:

#!/usr/bin/perl ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Perl Programming, 2nd Edition

Advanced Perl Programming, 2nd Edition

Simon Cozens
Intermediate Perl, 2nd Edition

Intermediate Perl, 2nd Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Mastering Perl

Mastering Perl

brian d foy
Perl in a Nutshell, 2nd Edition

Perl in a Nutshell, 2nd Edition

Nathan Patwardhan, Ellen Siever, Stephen Spainhour

Publisher Resources

ISBN: 9781449364946Errata Page