in reply to When every 2 lines of a file (sans first) should be 1...
There are a few interesting edge cases you may care to take care of. Consider:
use strict; use warnings; <DATA>; print ''.(chomp, s/\s*$/ /, $_).($_ = <DATA>, s/^\s*(?=\S)//, $_) whil +e <DATA>; __DATA__ Header line First line part 1. Part 2 of first line. Second line parts one and two. Third line - second part empty. Fourth and last line
Prints:
First line part 1. Part 2 of first line. Second line parts one and two. Third line - second part empty. Fourth and last line
which handles a number of cases, but spits warnings if the last line of the final pair is missing.
|
|---|