in reply to end of line anchor in regex

You can use the /m modifier to make $ match newlines: $text =~ s/hello$//gm;

See perlre for more information