Re: Substitute <br> for newlines
am 26.12.2007 22:55:49 von jurgenex
monkeys paw wrote:
>I need to display in HTML exactly the way a sentence is typed
>by a user. i.e.
Typically the element in HTML would be used for this purpose.
>user types: a
>line that
>wraps
>around
>
>I need to put
at the end of each line
> or it will display all on one line in HTML.
Although this has nothing to do with Perl: you are aware that echoing user
input as HTML is a major security hole? And that line wrapping is only one
minor of many changes that will happen?
> What is the perl substitution for this?
That depends upon how that text is being stored in Perl. Is each line an
entry in an array? Then you can just join() them using
as the
separator.
jue
Re: Substitute <br> for newlines
am 26.12.2007 22:58:39 von Gunnar Hjalmarsson
monkeys paw wrote:
> I need to display in HTML exactly the way a sentence is typed
> by a user. i.e.
>
> user types: a
> line that
> wraps
> around
>
> I need to put
at the end of each line or it will display
> all on one line in HTML. What is the perl substitution for this?
s/\r?\n|\r/
\n/g
But it may be better to use the
element.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Re: Substitute <br> for newlines
am 27.12.2007 14:35:25 von Abigail
_
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCXXX September MCMXCIII
in :
~~ monkeys paw wrote:
~~ > I need to display in HTML exactly the way a sentence is typed
~~ > by a user. i.e.
~~ >
~~ > user types: a
~~ > line that
~~ > wraps
~~ > around
~~ >
~~ > I need to put
at the end of each line or it will display
~~ > all on one line in HTML. What is the perl substitution for this?
~~
~~ s/\r?\n|\r/
\n/g
~~
~~ But it may be better to use the element.
If you want to replace generic newlines, I'd use:
s!\R!
!g;
Abigail
--
sub camel (^#87=i@J&&]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o }00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^, *&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*# ==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',. | |d)&&$llama."\n");