open(HTML,"<$html_file") || die "Could not open $html_file:$!\n"; open(TXT,"<$txt_file") || die "Could not open $txt_file:$!\n"; open(OUT,">$output_file) || die "Could not open $ouput_file:$!\n"; while () { print OUT $_; if (/this is how you recognise the specific point/) { while () { print OUT $_; } } }