http://www.perlmonks.org?node_id=655973


in reply to end of line anchor in regex

Less efficient, still possible:
$text = join($1, grep(/[^hello]/, split(/(\n)/, $text)));

perlrequick, perlretut, split, grep, join.