use strict; use warnings; while (my $line = ) { if ($line =~ /CLI/) { chomp $line; while (my $line2 = ) { next unless $line2 =~ /\S/; # ignore blank lines $line .= " $line2"; last; } } print $line; } __END__ MVC DOWO(8),WCPA CLI WCPA+2,C'.' BNE UPCC22