nl2br in Perl? - Need to format output and add newlines

Experts,

I am outputting a longtext field from my db to html.  I need to show line breaks as the output is one continuous string.

I know in PHP you can use nl2br which adds <br> however I cant find a function in Perl to do this.

Please help.
mhouldridgeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nitinsawhneyCommented:
In perl you do it with power of regex string replacement

$longTextFile =~ s/n/<br>/g;

Here longTextFile is the scalar containing your output.

Cheers
0
nitinsawhneyCommented:
sorry missed a slash...

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SmartIntelCommented:
Store each line in a variable and add <br> at the end using regular expression

$ine=~s/(.)+/$1<br>/g;
 
now print each line in a HTML file
0
mhouldridgeAuthor Commented:
Hi,

Thanks for the comments.  How would I store each line as a variable from a longtext field within a database.  I could understand how this would be done from a text file, reading line by line, but I dont understand how I would read a line of a longtext field?
0
mhouldridgeAuthor Commented:
Sorted now. thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.