use strict; use warnings; open(CPROG, ") { if ($line =~ /\(/s) { $concat_line = $line; } else { $concat_line .= $line if ($concat_line); } if ($concat_line && ($concat_line =~ /\(.*\)/s)) { print $concat_line; $concat_line = undef; } } close(CPROG);