Be careful. The line endings in your database could be
inconsistent. Try:
s/\r\n?|\n\r?/<br>/g;
which should work no matter which line ending is in the
database whether you are on Windows, Unix, or a Mac.
If you are (as it looks) trying to define a set of
conversions for turning text into somewhat equivalent HTML,
you might also want to look at Parse::RecDescent
for a much better way to do parsing than just throwing a
few regular expressions at it. Or you can go for the
hand-rolled version at Why I like functional programming (see the bottom of the
thread for a cleaner rewrite through). The rule here could
be done by adding the handler
sub {'<br>'}
for each of "\r\n", "\n\n", "\r", and "\n". Why would you
do that you ask? Well because with that code you can
readily implement markup rules based on user defined
choices without getting into a mess of custom logic. | [reply] [d/l] [select] |