open $fh,"<","yourfile"; open $out,">>","youroutfile"; undef $/; $str=<$fh>; print $out split(/\n^$\n^$\n/s,$str,2)[0];