in reply to Replace new line char with br

Okay. No one actually explains why your regex doesn't work, so I will take a stab at it.

1) If you want to do a substitution the form is $post =~ s/matching bit/replacement bits/modifier bits; (note the s instead of the m- s is for substitute, m is for match)

2) When you start a matching expression with ^ it will match the beginning of the line. $ is for the end of the line. Neither of these are necessary to match a new line character, really. Since the character you are looking for defines where lines begin and end.

3) You probably want to put a modifier or two at the end of your expression to make sure that you match and substitute all of the \n's in your $post. I suggest /sg. Adding s will make the RE treat your entire $post as one string. Adding g will make the RE test and match until it can't find anymore matches-- otherwise it will only match/substitute once.

So just to clarify, I suggest using $post =~ s/\n/<br>/sg; . And don't be afraid to read the regex docs at perldoc perlre.