## Sunday, January 23, 2005

### The power of perl

The LaTeX-style of my publisher has some special definitions for environements. When starting to write my JBoss book, I started to use just the normal LaTeX figure environement. Today I thought that it is time to convert those about 230 occurences of

\begin{figure}
... some text
\caption{bla}
\label{foo} % only sometimes set
\end{figure}

into

\begin{fighere}{always a label}{the caption text}
... some text
\end{fighere}

I decided to take perl for the task. Ok, it took me some time to get into perl again after not having it used for years. But at the end the complete task took me 3 hours.

I am sure, doing it by hand, I would sit there the whole week. The pattern matching ability of perl and the associative arrays just make it a pleasure job.