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

Re: Appending lines starting with white space to the previous line reads the entire file into memory. This version processes the file line by line thanks to redo and a one line lookahead.

chomp( my $line = <$fh> ); while (defined($line)) { chomp( my $next = <$fh> ); if (defined($next) && $next =~ s/^\s+//) { $line .= $next; redo; } ... do something with $line ... $line = $next; }

Update: Tested. Small syntax fix.