try this
~s/\n/<br>/gs;
Main Topics
Browse All Topicshi All,
I have a htl form submitting to a perl file. I want to replaice all \n by a <br> to display properly.
I tried
~ s/\n/<BR>/g
dosent work :(
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
from what it looks like you are doing, you are going through a html or cgi and replacing the '\n' in the perl script to <br>.
I have a file called cold.pl contents are:
print "I really can’t stay (Baby, it’s cold outside)\n";
print "I’ve got to go ‘way (Baby, it’s cold outside)\n";
print "The evening has been (I’ve been hopin’ that you’d drop in)\n";
print "So very nice (I’ll hold your hand, they’re just like ice)\n\n";
print "My mother will start to worry (Hey beautiful, what’s your hurry)\n";
print "And father will be pacing the floor (Listen to that fireplace roar)\n";
print "So really, I’d better scurry (Beautiful, please don’t hurry)\n";
print "Well, maybe just a half a drink more (Put some music on while I pour)\n";
When I run this script:
while($this = <>) {
$this =~ s/\\n/<br>/gi;
print $this;
}
like this:
waht.pl cold.pl > what.txt
the output in what.txt is:
print "I really can’t stay (Baby, it’s cold outside)<br>";
print "I’ve got to go ‘way (Baby, it’s cold outside)<br>";
print "The evening has been (I’ve been hopin’ that you’d drop in)<br>";
print "So very nice (I’ll hold your hand, they’re just like ice)<br><br>";
print "My mother will start to worry (Hey beautiful, what’s your hurry)<br>";
print "And father will be pacing the floor (Listen to that fireplace roar)<br>";
print "So really, I’d better scurry (Beautiful, please don’t hurry)<br>";
print "Well, maybe just a half a drink more (Put some music on while I pour)<br>";
Is this what you are looking for?
Here is a sample script that should do what you want (change end-of-line characters to <br>EOL)
#!/usr/bin/perl
use warnings;
use strict;
while(my $line = <>)
{
$line =~ s/[\r\n]+/<br>\n/g;
print $line;
}
Example of using this script:
(Without the script)
echo -e "1\n2\n3\n4\n5\n"
1
2
3
4
5
(With the script)
echo -e "1\n2\n3\n4\n5\n" | ./test.pl
1<br>
2<br>
3<br>
4<br>
5<br>
<br>
Business Accounts
Answer for Membership
by: hongjunPosted on 2005-11-22 at 08:03:10ID: 15342854
try this
~ s/\n|\r/\$/ig);