in reply to Re: end of line anchor in regex
in thread end of line anchor in regex

Captures in the split regex does have an effect, but setting $1 shouldn't be relied on. The effect of captures in the split regex is to return the captured data.

split(/\n/, "hello\nworld") -> ("hello", "world") split(/(\n)/, "hello\nworld") -> ("hello", "\n", "world")

I'd recommend

$text = join '', grep $_ ne "$word\n", split /(?<=\n)/, $text;

if you wanted to use split.