use strict; use warnings; my $line_count = -1; my $accum; while () { # ignore first line of file. It is a header line # nonetheless, increment line count if ($line_count == -1) { print; ++$line_count; next; } s!\n!!g; if ($line_count % 2) { print "$accum$_\n"; $accum = ''; } else { $accum = $_; } ++$line_count; }