I just spent two hours tracking down a bug in a program where some text comes in with two spaces at one point in a paragraph and leaves (via email) with what appeared to be 7.
As it turns out, the text is being formatted using the Text::Wrap package, an excellent little module for wrapping a paragraph of text at a particular column.
What I didn't know was that the wrap() function uses routines in Text::Tabs to optimize whitespace, replacing them with tabs where it can.
That's just great, but why isn't this aspect of wrap() documented in the POD documentation? There is no mention of its use of Text::Tabs at all!
In order to work around this, I had to set $Text::Tabs::tabstop to some high magic number to keep it from altering my whitespace like that.
NB: I contacted Text::Wrap author David Muir Sharnoff and he tells me that the next release of Text::Wrap will document this 'feature'.
Thanks, David. It never hurts to ask.
I put together a little templating processor yesterday. It uses HTML::TokeParser (once again, thanks CPAN!) to do the dirty work. Currently, it supports in-line scripting, includes and if/else testing. The syntax is XML-oriented and even uses a namespace so it can coexist in XHTML files easily. I like it.
It didn't take very long to write-- the main function is about 75 lines long.
I love Perl.