Book Reviews   Digital Libraries   Astronomy Log   Software   About  

Another cool perl module: Commands::Guarded
09 November 2005 19:21

Today while scouring CPAN for a Perl module that wrapped the 'chkconfig' command I bumped into the Commands::Guarded module. This module is based around the concept of idempotency. Idempotency is basically this: a function f(x) is idempotent if f(f(x)) = f(x). In other words, evaluating such a function more than once (and even many times) still yields the same result as evaluating it only once.

As a sysadmin, I very much like scripts and tools that are idempotent. That is, no matter how many times I run them, they always move the system towards the desired end state. Once the system is in that desired end state, running the script has no further effect. This is the main concept espoused by cfengine, in which each run of the agent brings the system towards (but no further) than the state defined by the configuration.

This module is particularly useful for sysadmins writing scripts which execute a sequence of actions, each of which depends upon the successful execution of the previous action. It makes for much cleaner and almost declarative code, in that I can define the state each step needs to effectuate, and the code required to bring that state into being. Thus if you run your script and it dies on step 3 of 20, you can run it again, and it will recognize that steps 1 and 2 have already happened, and that it needs to try step 3 again and go from there. A good read through the module docs is highly recommended.


Comments
Happiness
True love begins when the needs of others become more important than your own.
The practice of true love begets true happiness

Me

Daniel Hanks

I'm a system administrator working for Omniture

Interested in

perl
books
python
databases
genealogy
astronomy
digital archival
digital libraries
web applications
web infrastructure
distributed storage

among other things . . .

Storyteller


Pamela Hanks

is an excellent storyteller.

(She also happens to be my wife :-)

A storyteller makes a wonderful and unique addition to family, school, church or other group events. Schedule her for your next gathering.


Utah Open Source

Kiva.org
Kiva - loans that change lives

Recent Blog Entries

Subscribe with Bloglines
- OpenWest Conference 2014 Presentation Slides - Ansible
- OpenWest Conference 2013 Presentation Slides
- Utah Open Source Conference 2012 - Presentation slides
- E-Book Review: Data Mashups in R
- Book Review: Illustrated Guide to Astronomical Wonders
- Book Review: Wicked Cool Shell Scripts
- PLUG Presentation Slides: The Open Source Data Center
- Harnessing human computational power from computer games
- I love a good roadtrip
- FamilySearch Developers Conference 2008 presentations now available online
- FHT follow up: an idea for a mobile genealogical application
- Family history and technology: it's only getting better
- President Hinckley passes away
- December is NaBoMoReMo - National Book of Mormon Reading Month
- Family History, Photos, Blogs, and Books
- The Compact Oxford English Dictionary
- 1830s English and the Book of Mormon
- Google adds My Library feature to Book Search
- Utah Open Source Conference
- Wiki diagrammer (Steal this idea!)

All Entries . . .

LDSOSS
LDS Open Source Software
A website discussing the use of Open-source software for applications useful to those sharing values of the Latter-day Saint (Mormon) faith.

© 2009, Daniel C. Hanks