in reply to Replacing line returns with br
Use
$text =~ s/\n/<br>/;
instead of
$text =~ s/\\r\\n/<br>/;
Good luck!