in reply to Text Conversion

I like recipe 8.1, already posted by someone else, to read the continuation lines. It only affects the top of the loop: change your while to the block of several lines. A little messier in your case since you have to stay one line ahead.

But if that's too much, an elegant idea that's half way between this and the pipeline as a separate process/script is to use a tied file handle. Have the "read a line" logic do the continuation, reading one ahead. This isolates the state into the object and doesn't change your main code at all.

—John