in reply to Clubbing array elements together:
I prefer to solve such problems using a FiniteState Machine (FSM) algorithm, because it represents a generalized and easilyadaptable approach to the problem.
For example, from an initial state (that is to say, “while not in final state ...”), you read a line and have one of three possibilities: endoffile, a blank string, or notallblanks. That would lead to final, skip_blanks, or first_string. And so on. The FSM can be drawn out on a piece of paper as the WikiPedia article describes. When you determine (on paper) that the graph is entirely correct, the programming is a snap.
Since the FSM graph can be tricky to correctly design, I suggest that you build a testsuite using e.g. Test::Most to prove that it works as intended in all cases.
Re^2: Clubbing array elements together: by karlgoethebier (Parson) on Jan 29, 2013 at 20:17 UTC 
sundialsvc4:
"I prefer to solve such problems using a FiniteState Machine (FSM) algorithm, because it represents a generalized and easilyadaptable approach to the problem."
Sounds really cool. I'd like very much to see how you code it.
Thanks in advance for advice and best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
 [reply] 
