Gossamer Forum
Home : General : Perl Programming :

Changing line break to br html tag how to?

Quote Reply
Changing line break to br html tag how to?
Hello,
We've tried this snippet to change it when someone hits enter in their message to a html br tag but doesn't seem to work, is it not right, well that's a stupid questions of course it's not right, does anyone know what we did wrong here and what would be the right code.

Code in question:
$Message =~ s/\\n/<br>/g;

Thanks
Quote Reply
Re: Changing line break to br html tag how to? In reply to
The problem is that you're escaping the slash.

That should be

$Message =~ s/\n/<br>/g;

You only put the "\" in front of another "\" when you want that slash to be literal (IE you litterally want to match a slash followed by an n". Since "\n" is it's own meaning, the escape is not needed.

--mark


------------------
Due to repeated requests for support via ICQ, I am once again offering support online.

The ONLY number I will accept requests on is #53788453. Messages sent to my other numbers will not pass through to me, as I have security settings set to ignore messages from users not on that list.

I don't know how often I will be active on this number, as it is for only when I am free to offer assistance.

Could this signature be any longer? :)