my @arr; while ( my $line = ) { if ( $line =~ m/^\S/ ) { push @arr, $line; } else { $arr[-1] .= $line; } }