in reply to Appending lines starting with white space to the previous line

Try using  <code> </code> blocks to show your file contents.

As to the question, i would try using regular expressions in multiline mode and replacing the newline if it's followed by whitespace with a single space character.

Update:

This should work:
#!/usr/bin/perl -w use strict; $/ = undef; my $filecontents = <>; $filecontents =~ s/\n\s+//gm; print $filecontents;

Regards, Luke